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.
If you mistype a character in a code template that you want completed you cannot get code template generation unless you start the shortcut over. Not a bug but it would be a great enhancement to help adoption so I want to make it a P1 enhancement. System: Product Version: NetBeans IDE 6.5 RC2 (Build 20081028113643) Java: 1.5.0_16; Java HotSpot(TM) Client VM 1.5.0_16-133 System: Mac OS X version 10.5.5 running on i386; MacRoman; en_US (nb) Steps: 1. in a py file type ded (possible typo for def) 2. delete the "d" and replace with "f" and press tab, you will actually get the tab but it would be nice if generation would still work. 3. delete the tab and def 4. start over and enter "def" + tab and generation is good.
This is just how code templates work in NetBeans. I agree with you, and I think we have had some other requests for this in the past. This is probably a duplicate of an existing issue in the editor.
*** This issue has been marked as a duplicate of 57856 ***
verified duplicate
>> "If you mistype a character in a code template that you want completed you cannot get code template generation unless you start the shortcut over." I have this same issue in version 7.0.1 of NetBeans. Depending on what or how you mistype the characters of a code template and press TAB, the code template will not be expanded. Example: type "psvm_" (where _ is a space) and then backspace and TAB. The code template will not be expanded, you have to delete everything and type again. I would like to have this fixed for 7.1. For me this is a bug. I don't know how this is implemented internally, but I think it is easy to fix.
*** Bug 57856 has been marked as a duplicate of this bug. ***
*** Bug 121198 has been marked as a duplicate of this bug. ***
*** Bug 144201 has been marked as a duplicate of this bug. ***
*** Bug 138197 has been marked as a duplicate of this bug. ***
according to bug priority guide line, this is P3 IMHO
Still happening in NetBeans IDE Dev (Build 201110200600).
Copying comments from a duplicate issue: ------- Comment #1 From Petr Dvorak 2008-08-18 12:31:13 (-) ------- Well, I believe this is the way it is designed. For example: If you type "for " (with a space) and then you realize you can actually use a template "fori<tab>", you need to delete all "for " and start over. If you just delete the last space and if you press <tab>, it won't work... I think this issue is probably invalid. What if you want to type "int fori<tab>= 0;", for example because of the nice indentation? You must leave the user some means to do that... If the code template was expanded everytime you press tab after template code, you wouldn't be able to type above mentioned text... I am making this issue "invalid" for now, but please don't hesitate to reopen this issue if you think it should be opened... ------- Comment #2 From saeed_z_f 2008-08-18 15:51:13 (-) ------- Hi I think when a user change the short key of code template to shift + space this is a problem and this is not the way it is designed . ------- Comment #3 From Jiri Prox 2008-08-19 15:59:49 (-) ------- this is not so serious IMHO ------- Comment #4 From Vitezslav Stejskal 2008-08-20 09:20:29 (-) ------- Well, in fact this __is__ the way how code templates expansion was designed. The question is whether this design is good or not. Maybe it is not and maybe the expansion could behave differently depending on what expansion key you choose. But any change in this area may have potentially disastrous consequences for many people who has already become familiar with the way how it is now.
*** Bug 212426 has been marked as a duplicate of this bug. ***
*** Bug 219194 has been marked as a duplicate of this bug. ***
From comment #11: ---------------------------------------- 1) For example: If you type "for " (with a space) and then you realize you can actually use a template "fori<tab>", you need to delete all "for " and start over. If you just delete the last space and if you press <tab>, it won't work... 2) I think this issue is probably invalid. What if you want to type "int fori<tab>= 0;", for example because of the nice indentation? You must leave the user some means to do that... If the code template was expanded everytime you press tab after template code, you wouldn't be able to type above mentioned text... ----------------------------------------------------------- 1) I don't understand why case 1) is designed like that. Why do you have to delete all and start over? Does not make sense for me. 2) Ok, "int fori<tab>= 0;" is a special case with a keyword before the code template. Just keep like that, because this is not the problem. A code template must start with a space or nothing before it in the line. Maybe we should have two types of shortcuts: TAB does the same thing that it is doing now. CTRL SPACE does what everyone wants (see comment #1).
Actually I wanted to say "see comment #0".
*** Bug 89281 has been marked as a duplicate of this bug. ***
*** Bug 90739 has been marked as a duplicate of this bug. ***
I think this is a feature request. BTW it is not a trivial feature because after implementing this one can easily end up in expansion being done when the user doesn't want it to happen. It all depends on whether the expansion shortcut is used also for typing (as with Tab character). If it is used one must be careful not to cause problems when hitting the tab when the user wants to type tab.
(In reply to David Strupl from comment #18) > I think this is a feature request. BTW it is not a trivial feature because > after implementing this one can easily end up in expansion being done when > the user doesn't want it to happen. It all depends on whether the expansion > shortcut is used also for typing (as with Tab character). If it is used one > must be careful not to cause problems when hitting the tab when the user > wants to type tab. It's clear that there must be a way for the user to insert a tab whenever he needs to, even following a fragment that happens to be a code template abbreviation. One solution would be to have Shift+Tab do this (i.e. other than at the beginning of the line where it decrease the indentation). This is what SublimeText does for example, and it would also solve the "int fori<tab>= 0;" case from comment #11. Note that if the user presses Tab behind some text that happens to be a code template abbreviation, but really wants to insert a tab, then he will usually just have typed this text. In this situation he will already get the undesired result of having the code template inserted today. Either this is something that happens rarely in practice, or users are already accustomed to working around it by e.g. pressing Space and Backspace before pressing Tab. If this is the case, then I would argue that they will be capable to get accustomed to pressing Shift+Tab just as easily. Another possible solution could be to include code templates in the auto-completion popup (Ctrl+Space) as a way to insert a code template after a corrected abbreviation witout having to re-type the abbreviation. This already happens for some stuff; for example pressing Ctrl+Space after "for" presents a list of for-loop completions that correspond to code templates. (This is apparently context-sensitive, as it only happens within a code block.) But pressing Ctrl+Space after e.g. "psvm" doesn't suggest the public static void main code template. Yet another possible solution would be for code template expansion to require only that either (a) the last character of the code template abbreviation must have been typed directly before pressing Tab or (b) Backspace must have been pressed directly before pressing Tab. This would solve many if not the majority of cases of correcting typos when entering code template abbreviations and would at most require having to re-type the last character of the code template.
We may also consider putting template activation as a separate step in Undo history (as it is done in MS Word) so if template was activated when it was not needed, Ctrl-Z should undo it. This looks natural to me. We can also consider backspace to undo it but this is more questionable to me. Looks like some usability study is needed.
(In reply to matthies from comment #19) > Another possible solution could be to include code templates in the > auto-completion popup (Ctrl+Space) as a way to insert a code template after > a corrected abbreviation witout having to re-type the abbreviation. This > already happens for some stuff; for example pressing Ctrl+Space after "for" > presents a list of for-loop completions that correspond to code templates. > (This is apparently context-sensitive, as it only happens within a code > block.) But pressing Ctrl+Space after e.g. "psvm" doesn't suggest the public > static void main code template. > FYI: Code completion for code templates was introduced by [1] [2]. Yes it would be nice to see "psvm" (and all the other templates) in code completion too, but this would be overkill and "was in fact the main reason for introducing contexts" (cite of [3]) [1] https://netbeans.org/bugzilla/show_bug.cgi?id=160771 [2] https://netbeans.org/bugzilla/show_bug.cgi?id=184604 [3] https://netbeans.org/bugzilla/show_bug.cgi?id=212176#c7
(In reply to markiewb from comment #21) > FYI: Code completion for code templates was introduced by [1] [2]. Yes it > would be nice to see "psvm" (and all the other templates) in code > completion too, but this would be overkill and "was in fact the main reason > for introducing contexts" (cite of [3]) Then I wonder why the code templates dialog does not allow specification/editing of the context of a code template (whether custom or pre-defined). For example being able to specify a "class scope" context for "psvm" so that it appears in code completion. I'd be in favor of reopening Bug 212176 to have this feature added.
Created attachment 139093 [details] Show the context tab (In reply to matthies from comment #22) > Then I wonder why the code templates dialog does not allow > specification/editing of the context of a code template (whether custom or > pre-defined). For example being able to specify a "class scope" context for > "psvm" so that it appears in code completion. I'd be in favor of reopening > Bug 212176 to have this feature added. It is already possible. See the context tab (only for Java code templates) in the screenshot
(In reply to markiewb from comment #23) > Created attachment 139093 [details] > Show the context tab > > (In reply to matthies from comment #22) > > Then I wonder why the code templates dialog does not allow > > specification/editing of the context of a code template (whether custom or > > pre-defined). For example being able to specify a "class scope" context for > > "psvm" so that it appears in code completion. I'd be in favor of reopening > > Bug 212176 to have this feature added. > > It is already possible. See the context tab (only for Java code templates) > in the screenshot Ah, that's new in 7.4; I'm still using 7.3.1.
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue. Thanks for your cooperation, NetBeans IDE 8.2 Release Boss
Still relevant in current dev build.