This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 250180 - Code template for "for"
Summary: Code template for "for"
Status: RESOLVED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-03 13:24 UTC by Ondrej Brejla
Modified: 2015-02-03 16:07 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ondrej Brejla 2015-02-03 13:24:31 UTC
Please, change default code template for "for" from this:

for (var ${var default="i"} = 0, ${max} = ${limit default="10"}; ${var} < ${max}; ${var}++) {
    ${selection}${cursor}
}

to this:

for (var ${var default="i"} = 0; ${var} < ${max}; ${var}++) {
    ${selection}${cursor}
}

That "max" part is really annoying there ;) If you think that we need such a code template, then you can create new with e.g. abbr: "fom" which will mean "FO with Max" and put it there :) Thanks in advance!
Comment 1 Vladimir Riha 2015-02-03 13:31:00 UTC
It was originally my idea to put it there for performance reasons with common arrays. But I'm fine with "fom"
Comment 2 Ondrej Brejla 2015-02-03 13:54:41 UTC
Caching array length is not as cool as it could look like [1] [2] ;) 

But if you are ok with "fom", then we can of course have both versions.

[1] http://mrale.ph/blog/2014/12/24/array-length-caching.html
[2] http://architects.dzone.com/articles/javascript-shoud-i-have-cache
Comment 3 Vladimir Riha 2015-02-03 14:23:38 UTC
Depends on the test and what are you iterating :)

[1] http://jsperf.com/array-length-vs-cached
Comment 4 Petr Pisl 2015-02-03 15:43:22 UTC
Changed in web-main as requested:).
Comment 5 Ondrej Brejla 2015-02-03 16:07:17 UTC
Yep I know, that's why I didn't write that it doesn't work at all ;))

Thanks!