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 132534

Summary: Pressing tab doesn't switch between arguments of a live template
Product: editor Reporter: Tomasz Slota <tslota>
Component: Completion & TemplatesAssignee: Miloslav Metelka <mmetelka>
Status: VERIFIED FIXED    
Severity: blocker CC: jiriprox, sustaining, vstejskal
Priority: P2    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description Tomasz Slota 2008-04-10 14:54:40 UTC
Steps to reproduce:
-in a PHP block invoke code completion for function that has multiple arguments, e.g. array_chunk
- it should be possible to navigate between arguments with the Tab or Enter key, however only Enter works correctly. 

Tab increases indent of the whole block instead, which is quite odd.
Comment 1 Tomasz Slota 2008-04-10 15:14:55 UTC
It is only reproducible for the first code completion with a live template call after IDE start.
It is not PHP-specific, it is also reproducible in JavaScript (only in .js files, it works fine in JS embedded in HTML).
Comment 2 Vitezslav Stejskal 2008-04-11 07:34:32 UTC
Might be a good candidate for the Patch1.
Comment 3 Miloslav Metelka 2008-04-11 09:38:00 UTC
I'm working on this.
Comment 4 Jan Becicka 2008-04-11 19:08:31 UTC
Patch1 candidate?
Comment 5 Miloslav Metelka 2008-04-14 11:43:16 UTC
I agree to make this a patch candidate.

BTW this problem was rather obscure ;) Code template editing needs to override actions on Enter, Tab and Shift-Tab.
Making a keylistener is too agressive (completion's keys wouldn't work etc.) so we have an overriding ActionMap with the
three actions and parented to original AM. We still use Swing's Keymap interface instead of InputMap/ActionMap but it's
fine since Swing has a wrapper. But instead of IM:[keystroke,Action.NAME] AM:[Action.NAME,actionInstance] the Swing's
Keymap wrapper maps IM:[keystroke,actionInstance] AM:[actionInstance,actionInstance]. We are aware of this so we search
by keystrokes so we can work fine even with this. However in this particular case the Keymap instance gets recreated
(probably by some lazy loading in settigs or whatever) so the "actionInstance" gets recreated as well between the code
templates special mode installation and the time when the "Tab" gets clicked. So the Tab finds a new InsertTabAction
instance in "value" of IM but there is no match in our overriden AM because there is an "old" instance of
InsertTabAction so our overriden action does not get triggered. I have considered overriding InputMap too but I have
finally fixed it by having statically defined actions in BaseKit. We should soon migrate to IM/AM instead of Keymap so
that Swing's Keymap wrapper impl no longer bothers us.

BTW I was not able to reproduce in current trunk so I've tested in release61 directly but since this depends on
something in settings it might reappear in trunk too so the fix is useful in trunk too.

http://hg.netbeans.org/main/rev/4a9313234f8f

What should I make to make this go into a Patch1?
Comment 6 pgebauer 2008-04-14 14:50:57 UTC
The issue must be fixed (this part is done) and verified by QE in the trunk. QE should mark the issues with
release61_fixes_candidate1 status-whiteboard value thereafter.
Comment 7 pgebauer 2008-06-10 13:40:24 UTC
This issue has been nominated for NB IDE 6.1 patch2 although it hasn't been verified by QE yet. If it isn't verified by
12-Jun-08, it's nomination will be removed.
Comment 8 Jiri Prox 2008-06-11 09:13:05 UTC
I cannot reproduce it in current trunk build - > verified
Comment 9 pgebauer 2008-06-12 15:12:19 UTC
The fix has been ported into the release61_fixes branch:

http://hg.netbeans.org/release61_fixes/80cbe0d41ffa