Increase scope of JS for snippet placeholder

The `Things.length` part of the JS `for` snippet previously did not
include the `.length` portion. Using some regex replacement, we can
include this bit in the placeholder while still only using the `Things`
bit inside the `for` loop. This should make the snippet slightly more
pleasant to use.
This commit is contained in:
Joe Lencioni 2014-01-06 08:22:54 -08:00
parent bd0c576bff
commit 98f88de976

View File

@ -33,14 +33,14 @@ ${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) {
endsnippet endsnippet
snippet for "for (...) {...} (faster)" snippet for "for (...) {...} (faster)"
for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2--) { for (var ${2:i} = ${1:Things.length} - 1; $2 >= 0; $2--) {
${3:$1[$2]}${VISUAL}$0 ${3:${1/([^.]+).*/$1/}[$2]}${VISUAL}$0
} }
endsnippet endsnippet
snippet for "for (...) {...}" snippet for "for (...) {...}"
for (var ${1:i} = 0, ${2:len} = ${3:Things}.length; $1 < $2; $1++) { for (var ${1:i} = 0, ${2:len} = ${3:Things.length}; $1 < $2; $1++) {
${4:${3}[$1]}${VISUAL}$0 ${4:${3/([^.]+).*/$1/}[$1]}${VISUAL}$0
} }
endsnippet endsnippet