From 983d494752839e7cbd9c75a42da4bfd392047037 Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Mon, 6 Jan 2014 22:16:05 -0800 Subject: [PATCH] Add "b" options to JS `for` and `ford` snippets `for` loops usually appear at the beginning of the line. This commit makes these snippets more context-aware by adding the "b" option that prevents them from being triggered if they are preceded with something other than whitespace, as suggested by @SirVer[1]. [1]: https://github.com/SirVer/ultisnips/pull/123/files#r8686514 --- UltiSnips/javascript.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UltiSnips/javascript.snippets b/UltiSnips/javascript.snippets index 1dff6b1..8389156 100644 --- a/UltiSnips/javascript.snippets +++ b/UltiSnips/javascript.snippets @@ -32,13 +32,13 @@ ${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) { endsnippet -snippet ford "for (...) {...} (counting down, faster)" +snippet ford "for (...) {...} (counting down, faster)" b for (var ${2:i} = ${1:Things.length} - 1; $2 >= 0; $2--) { ${3:${1/([^.]+).*/$1/}[$2]}${VISUAL}$0 } endsnippet -snippet for "for (...) {...} (counting up)" +snippet for "for (...) {...} (counting up)" b for (var ${1:i} = 0, ${2:len} = ${3:Things.length}; $1 < $2; $1++) { ${4:${3/([^.]+).*/$1/}[$1]}${VISUAL}$0 }