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.
Created attachment 139471 [details] screencast Environment Product Version: NetBeans IDE Dev (Build 201308290001) Java: 1.7.0_40; Java HotSpot(TM) 64-Bit Server VM 24.0-b55 Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b40 System: Mac OS X version 10.7.5 running on x86_64; UTF-8; en_US (nb) User directory: /Users/ionuion/Library/Application Support/NetBeans/dev Cache directory: /Users/ionuion/Library/Caches/NetBeans/dev Steps to reproduce 1. Create the Anagram Game project from the Samples set 2. Open the next two java files: WordLibrary.java and StaticWordLibrary.java 3. Modify WordLibrary.java. Don't save. 4. Move to the other file. Place the cursor on some line. use the shortcut to move the line down (e.g. on Mac Ctrl-Shift-DOWN) Expected result: The line is moved Actual result: the line is moved and duplicated Screencast attached
There was change in shortcuts for mac os. See #228315. I cannot reproduce it on: Product Version: NetBeans IDE Dev (Build 201309030001) Updates: Updates available to version NetBeans 7.3 Patch 2 Java: 1.7.0_25; Java HotSpot(TM) 64-Bit Server VM 23.25-b01 Runtime: Java(TM) SE Runtime Environment 1.7.0_25-b15 System: Linux version 3.0.0-32-generic running on amd64; UTF-8; en_US (nb) I will try mac os, next time.
Still valid with NetBeans 7.4RC1 running on top of JDK7u40.
On both my Windows 7 and 8 systems, I see in Tools->Options->Keymap that Duplicate Line(s) Down Ctrl+Shift+DOWN Move Line(s) Down Alt+Shift+DOWN and these key combinations work correctly in the Anagram Game scenario. Product Version: NetBeans IDE 7.4 RC1 (Build 201309112301) Java: 1.7.0_40; Java HotSpot(TM) Client VM 24.0-b56 Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b43 System: Windows 8 version 6.2 running on x86; Cp1252; en_US (nb) System: Windows 7 version 6.1 running on x86; Cp1252; en_US (nb)
Happens to me too. Mac OS X 10.8.5, JDK 7u40, i.e., 1.7.0_40-b43. Has been happening for all 7.4 versions I've tried. What's weird is, it doesn't ALWAYS happen. But it does happen often enough to be MADDENING! This should be a P1 showstopper bug.
A very annoying bug! I use this feature a lot and it happens most of the time - but not always. I have tried this with java, xml and xsd files all in maven projects. Product Version: NetBeans IDE 7.4 RC1 (Build 201309162201) Java: 1.7.0_25; Java HotSpot(TM) 64-Bit Server VM 23.25-b01 Runtime: Java(TM) SE Runtime Environment 1.7.0_25-b15 System: Mac OS X version 10.8.5 running on x86_64; UTF-8; sv_SE (nb)
Works for me as well on Linux ... so sounds like another Mac specific issue ... Product Version: NetBeans IDE 7.4 (Build 201310012201) Java: 1.7.0_40-ea; Java HotSpot(TM) 64-Bit Server VM 24.0-b55 Runtime: Java(TM) SE Runtime Environment 1.7.0_40-ea-b36 System: Linux version 3.5.0-41-generic running on amd64; UTF-8; en_US (nb)
(In reply to Marian Mirilovic from comment #6) > Works for me as well on Linux ... so sounds like another Mac specific issue > ... > Product Version: NetBeans IDE 7.4 (Build 201310012201) > Java: 1.7.0_40-ea; Java HotSpot(TM) 64-Bit Server VM 24.0-b55 > Runtime: Java(TM) SE Runtime Environment 1.7.0_40-ea-b36 > System: Linux version 3.5.0-41-generic running on amd64; UTF-8; en_US (nb) You're right Marian! I just tried it out on my Linux box (with OpenJDK) and it works well. I can't reproduce it. Product Version: NetBeans IDE 7.4 RC1 (Build 201309162201) Java: 1.7.0_25; OpenJDK 64-Bit Server VM 23.7-b01 Runtime: OpenJDK Runtime Environment 1.7.0_25-b30 System: Linux version 3.8.0-31-generic running on amd64; UTF-8; en_US (nb)
*** Bug 236716 has been marked as a duplicate of this bug. ***
Happens to me too. Very annoying. Especially since the 7.3 and older versions have now become buggy due to installing the newest JDK (7.4 made me do it). Fix this soon please! This is one of my most used shortcuts!
Sorry, forgot to mention my specs: Product Version: NetBeans IDE 7.4 (Build 201310111528) Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08 Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18 System: Mac OS X version 10.7.5 running on x86_64; UTF-8; en_US (nb) Regards Luba
I can confirm that as well. I'm also on OS X Product Version: NetBeans IDE 7.4 (Build 201310111528) Java: 1.7.0_21; Java HotSpot(TM) 64-Bit Server VM 23.21-b01 Runtime: Java(TM) SE Runtime Environment 1.7.0_21-b12 System: Mac OS X version 10.8.5 running on x86_64; UTF-8; en_US (nb)
I just got a new mac book and did a clean reinstall of Netbeans and Java without copying my old configuration. The issue seems to be gone now.
I changed NOTHING on my system. Absolutely NOTHING. Specs still the same. And yet the bug is gone since a couple of days ... it's magic! Specs still: Product Version: NetBeans IDE 7.4 (Build 201310111528) Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08 Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18 System: Mac OS X version 10.7.5 running on x86_64; UTF-8; en_US (nb)
A now it's broken again - Netbeans seems to "forget" other shortcuts completely after some time. Restarting Netbeans helps, all shortcuts are back until it loses them again.
I too have seen the problem go away, but only briefly, only to come back. ARGHH. On the other hand, I just clicked on the notification to "make my IDE up to date" and got 50 patches applied, resulting in 7.4 Development Version. Initial testing indicates that the problem has been fixed, though I won't exactly be comfortable about that until extended testing proves that it is permanently banished instead of only temporarily.
I thought I'd share my work-around routine, however clunky, in hopes maybe it helps determine what's going on. When I want to use the ctrl-shift move line, 1) open preferences (command-comma) 2) close preferences (esc) 2x Now I can move lines without duplication until I switch editor tabs again.
I experience the same strange behavior on Mac OS 10.8.3 and Netbeans 7.4 (did not happen on NB7.3). Very annoying.. Java 1.7.0_25-b15 64-Bit
(In reply to nickroklaus from comment #16) > I thought I'd share my work-around routine, however clunky, in hopes maybe > it helps determine what's going on. > > When I want to use the ctrl-shift move line, > 1) open preferences (command-comma) > 2) close preferences (esc) 2x > > Now I can move lines without duplication until I switch editor tabs again. This works for me, too. Thanks! I hope this also helps fixing the bug.
(In reply to nickroklaus from comment #16) > I thought I'd share my work-around routine, however clunky, in hopes maybe > it helps determine what's going on. > > When I want to use the ctrl-shift move line, > 1) open preferences (command-comma) > 2) close preferences (esc) 2x > > Now I can move lines without duplication until I switch editor tabs again. The errors back in my machine and the above solution does not work for me ;(.
This is another workaround that when followed puts 'Duplicate Line(s) Up/Down' back to the way it to my knowledge worked in 7.3.1. (You loose the more mac-standard 'Extend Selection to Beggining/End of Document' with Shift+Meta+UP/DOWN.) In Netbeans 7.4 Preferences (Options), Keymap: (1) Search for dupli... clear shortcuts Alt+Shift+DOWN and Alt+Shift+UP. (At this point, the bug in question is obviated, but you've lost the main shortcut for duplicating lines with the keyboard. If you want that...) (2) Search for extend... clear shortcuts Shift+Meta+UP and Shift+Meta+DOWN. (3) Search for dupli... add alternatives Shift+Meta+DOWN and Shift+Meta+UP for the corresponding Duplicate Line(s) shortcuts. That's it. If you change your mind, you can always search for the shortcuts and Reset to Default in reverse order. Or, reset to default settings: In the same Keymap tab, click Manage Profiles & then Restore Defaults (NetBeans profile on my list).
(In reply to nickroklaus from comment #20) > This is another workaround that when followed puts 'Duplicate Line(s) > Up/Down' back to the way it to my knowledge worked in 7.3.1. (You loose the > more mac-standard 'Extend Selection to Beggining/End of Document' with > Shift+Meta+UP/DOWN.) > > In Netbeans 7.4 Preferences (Options), Keymap: > > (1) Search for dupli... clear shortcuts Alt+Shift+DOWN and Alt+Shift+UP. (At > this point, the bug in question is obviated, but you've lost the main > shortcut for duplicating lines with the keyboard. If you want that...) > > (2) Search for extend... clear shortcuts Shift+Meta+UP and Shift+Meta+DOWN. > > (3) Search for dupli... add alternatives Shift+Meta+DOWN and Shift+Meta+UP > for the corresponding Duplicate Line(s) shortcuts. > > That's it. If you change your mind, you can always search for the shortcuts > and Reset to Default in reverse order. Or, reset to default settings: In the > same Keymap tab, click Manage Profiles & then Restore Defaults (NetBeans > profile on my list). Another bummer: After deleting the Shift+Meta+DOWN and UP showrtcuts i cannot assign these shortcuts anymore. When pressing the up and down arrow in the shortcut assignment field, it just goes up and down in the select box. right and left arrows are recognized, but up and down aren't. And they're not in the select options. This is silly.
It seems like ctrl+shift+up / ctrl+shift+down is some macos default now. If you assign another combination to the move line action it works. I managed to get all acceptable by setting move line to alt+shift+up/dow and letting crtl+shift+up/down control the duplication. It will take a couple of days to get used to it, and I have to reverse my settings on my home desktop running Linux, too, but it's an acceptable compromise.
Same for me. CTRL+SHIT+UP just fires navigation in combos... Weird. (In reply to luba from comment #21) > (In reply to nickroklaus from comment #20) > > This is another workaround that when followed puts 'Duplicate Line(s) > > Up/Down' back to the way it to my knowledge worked in 7.3.1. (You loose the > > more mac-standard 'Extend Selection to Beggining/End of Document' with > > Shift+Meta+UP/DOWN.) > > > > In Netbeans 7.4 Preferences (Options), Keymap: > > > > (1) Search for dupli... clear shortcuts Alt+Shift+DOWN and Alt+Shift+UP. (At > > this point, the bug in question is obviated, but you've lost the main > > shortcut for duplicating lines with the keyboard. If you want that...) > > > > (2) Search for extend... clear shortcuts Shift+Meta+UP and Shift+Meta+DOWN. > > > > (3) Search for dupli... add alternatives Shift+Meta+DOWN and Shift+Meta+UP > > for the corresponding Duplicate Line(s) shortcuts. > > > > That's it. If you change your mind, you can always search for the shortcuts > > and Reset to Default in reverse order. Or, reset to default settings: In the > > same Keymap tab, click Manage Profiles & then Restore Defaults (NetBeans > > profile on my list). > > Another bummer: After deleting the Shift+Meta+DOWN and UP showrtcuts i > cannot assign these shortcuts anymore. When pressing the up and down arrow > in the shortcut assignment field, it just goes up and down in the select > box. right and left arrows are recognized, but up and down aren't. And > they're not in the select options. This is silly.
I've got the same issue: CTRL+SHIT+UP moves the selected block and then duplicates it! Strange. I double checked my Mac OS Mavericks shortcuts, but this combination seems not to be assigned to any function.
Oh and the suggested work arounds above did not work. Only reassign another combination will work... (In reply to jmborer from comment #24) > I've got the same issue: CTRL+SHIT+UP moves the selected block and then > duplicates it! Strange. I double checked my Mac OS Mavericks shortcuts, but > this combination seems not to be assigned to any function.
I have searched over internet and found that there should be Ctrl+Up assigned (in System Preferences -> Keyboard -> Keyboard Shortcuts) to "Mission Control" and Shift is generally causing a slow motion of the feature (on Snow Leopard; similar for Shift+expose etc.). So remapping the "Mission Control" from Ctrl+Up should also free the Ctrl+Shift+Up. Could anyone please try this? Thanks.
(In reply to Miloslav Metelka from comment #26) > I have searched over internet and found that there should be Ctrl+Up > assigned (in System Preferences -> Keyboard -> Keyboard Shortcuts) to > "Mission Control" and Shift is generally causing a slow motion of the > feature (on Snow Leopard; similar for Shift+expose etc.). So remapping the > "Mission Control" from Ctrl+Up should also free the Ctrl+Shift+Up. > Could anyone please try this? Thanks. That does not help. I have and have always had Ctrl-Up unmapped in System Preferences, purely because I want to use [Shift] Ctrl-Up/Down in NetBeans. Worked in 7.3. Something changed in 7.4, including the betas.
I had Mission Control (Ctrl-up) and Application Windows (Ctrl-down) disabled as well, however I gave it a try and remapped them to Cmd-/ and Cmd-\, respectively. Left them active, checked that they worked. The problem persists in Netbeans. Line duplicated upon moving with Ctrl-Shift-Up/Down Environment: Product Version: NetBeans IDE 7.4 (Build 201310111528) Updates: NetBeans IDE is updated to version NetBeans 7.4 Patch 1 Java: 1.8.0-ea; Java HotSpot(TM) 64-Bit Server VM 25.0-b59 Runtime: Java(TM) SE Runtime Environment 1.8.0-ea-b117 System: Mac OS X version 10.8.5 running on x86_64; UTF-8; en_US (nb) (In reply to Miloslav Metelka from comment #26) > I have searched over internet and found that there should be Ctrl+Up > assigned (in System Preferences -> Keyboard -> Keyboard Shortcuts) to > "Mission Control" and Shift is generally causing a slow motion of the > feature (on Snow Leopard; similar for Shift+expose etc.). So remapping the > "Mission Control" from Ctrl+Up should also free the Ctrl+Shift+Up. > Could anyone please try this? Thanks.
It appears to be some kind of interaction between the "Move Line(s) ..." and the "Duplicate Line(s) ...". For example, with default bindings: Move Line(s) Down: Ctrl+Shift+DOWN Move Line(s) Down (alt): Ctrl+Shift+KP_DOWN Duplicate Line(s) Down: Alt+Shift+KP_DOWN Duplicate Line(s) Down (alt): Alt+Shift+DOWN I get duplicate lines when using the move functionality. However with bindings: Move Line(s) Down: Ctrl+Shift+DOWN Move Line(s) Down (alt): Ctrl+Shift+KP_DOWN Duplicate Line(s) Down: Duplicate Line(s) Down (alt): I get proper functionality with the move functionality and obviously duplicate functionality doesn't work. This implies to me that the issue isn't with the Ctrl+Shift+DOWN binding, but somehow the Alt+Shift+DOWN binding is getting triggered when Ctrl is pressed. I wonder if two key press events are being generated or if the check for which metakeys are pressed is too broad in this case? Is there an easy setup to debug this? I'm willing to give it a shot if you can point me to the general area in the source where the keybindings are applied in the editor.
I did some debugging and I think I narrowed down the problem a little. The ActionFactory.CopySelectionElseLineDownAction is being fired immediately after the ActionFactory.MoveSelectionElseLineDownAction even when only Ctrl+Shift+DOWN is pressed. Looking at the event modifiers, I can see that the Move action is fired with 195 while the Copy is fired with 585 indicating Ctrl+Shift and Alt+Shift respectively. So as far as the actions are concerned, there were two keystrokes, one with Ctrl and one with Alt even though the Alt combination was never pressed. Tracking through the stack trace, I think the issue may be because of some code in org.openide.awt.MenuBar.java around line 224. The method, processKeyBinding has the suspicious JavaDoc: * Overridden to handle mac conversion from Alt to Ctrl and vice versa so * Alt can be used as the compose character on international keyboards. In the method, if Ctrl is pressed and Alt isn't, the modifiers are modified around line 237 to remove Ctrl and add Alt. Even more strange, around line 254 the isOnKeyRelease is negated meaning the original key up with Ctrl pressed event now appears as a key down Alt pressed event. I barely know this code so I'm not sure why it is being done, but this appears to be the root of why both Copy and Move actions are getting fired. The issue only seems to appear when a second editor is open and remains until the IDE is restarted. So maybe the MenuBar code is correct but something about opening a second editor causes the MenuBar to listen for events it shouldn't be handling.
> I barely know this code so I'm not sure why it is being done, but this > appears to be the root of why both Copy and Move actions are getting fired. > The issue only seems to appear when a second editor is open and remains > until the IDE is restarted. So maybe the MenuBar code is correct but > something about opening a second editor causes the MenuBar to listen for > events it shouldn't be handling. Hey, this is great news because a) someone is working on it, and b) it seems like you're close to identifying the source of the problem As an additional hint, however, I would remind you that, as someone else here discovered, opening and closing preferences (Command-comma, escape, escape) also fixes the problem for a while. I have not noticed just what circumstance causes the problem to reappear, but perhaps it is opening another editor tab. In any case, the problem does not necessarily remain until the IDE is restarted, as it can be, at least temporarily, fixed with the open/close preferences trick. Thanks for working on this maddening problem.
Well I wouldn't really say I'm working on the issue but I am trying to gather some more information so someone who knows this code can hopefully provide a fix. It looks like the extra, fake keystroke I described earlier is fired in both the working and broken case. The code to fire that event has been around for a number of years according to SCM logs. What's different is that in the working case, the key binding for the fake Alt+Shift+Down is not found in the MainMenuAction when the MenuBar is processing the key stroke. In the broken case, the key binding is fired and the action is fired. I stepped through the code a few times but I didn't see any obvious reason why the binding was found in one case but not in the other. You're right that opening and canceling the preferences dialog resolves the problem. It looks like the menu system is based on some kind of lazy action loading framework so I'm wondering if opening the preferences clears the menu items which causes the keybinding to not be found until something like opening another editor causes the menu items to be lazily loaded and the key binding is found from that point on. I'm not making too much progress but hopefully someone will find this information useful!
Some more information but still no solution: I can get this to happen with other actions defined in the ActionFactory. For example, with the bindings: Move Line(s) Down: Ctrl+Shift+DOWN Shift Line Right: Alt+Shift+DOWN I get the same broken behavior where the line moves and then shifts when Ctrl+Shift+DOWN is pressed. Again, it is the MenuBar applying the hack/fix for Macs where the Ctrl modified is converted to an Alt modifier and reprocessed. The issue doesn't show up with actions defined in ActionFactory that don't appear in the menu. For example, Extend Selection To First Non-whitespace Char. So The issue is related to the key bindings on menu items. Interestingly, the issue also doesn't appear if I assign the Alt+Shift+DOWN binding to "Find..." which does appear in the menu but not in the ActionFactory. Looking in the Debugger is looks like that menu item extends Action while the others that do fire extend MainMenuAction. So maybe there is a difference in how these actions are handling the keybindings. As pointed out, opening and closing the preferences window restores sanity for a little while. I also found that just opening the Find bar (Cmd+F) does the same.
So question is: what did change in the shortcut and action code between 7.3 and 7.4? PS: Thanks mpilone for your investigations
I have added two loggers for possible tracking of the problem: -J-Dorg.openide.awt.MenuBar.level=FINE -J-Dorg.netbeans.editor.MultiKeymap.level=FINE http://hg.netbeans.org/jet-main/rev/15ed5385984b Could someone please edit netbeans.conf and run the IDE with -J-Dapple.laf.useScreenMenuBar=false whether that makes any difference on the problem or not? (the default is -J-Dapple.laf.useScreenMenuBar=true in netbeans.conf). Thanks.
> Could someone please edit netbeans.conf and run the IDE with > > -J-Dapple.laf.useScreenMenuBar=false I did that, by editing /Applications/NetBeans/NetBeans 7.4.app/Contents/Resources/NetBeans/etc/netbeans.conf No change. Problem is still there. No obvious difference in behavior elsewhere, but I guess I'll change it back now.
Created attachment 143268 [details] Log capture using the extended menubar logging. I attempted to checkout the code from Mercurial but it was taking for ever so I just applied the two changed files over my 7.4 source tar ball. The log includes a period of the issue showing then I opened the preferences window which causes the issue to go away. I only ever typed CTRL+SHIFT+UP/DOWN and never the ALT combination directly. Let me know if you need more information.
Created attachment 143269 [details] Log capture with fine menubar and action logging. I added log statements to the CopySelectionElseLineUpAction and MoveSelectionElseLineUpAction to show the duplicate firing. Again, I only used the CTRL +SHIFT+UP/DOWN shortcut but both actions are fired. I also opened the preferences dialog near the end of the log and the issue resolves temporarily. The command used was: ./netbeans -J-Dorg.openide.awt.MenuBar.level=FINE -J-Dorg.netbeans.editor.MultiKeymap.level=FINE -J-Dorg.netbeans.editor.ActionFactory.level=FINE --userdir ~/tmp/netbeans-debug/
(In reply to mpilone from comment #38) > Created attachment 143269 [details] > Log capture with fine menubar and action logging. > > I added log statements to the CopySelectionElseLineUpAction and > MoveSelectionElseLineUpAction to show the duplicate firing. Again, I only > used the CTRL +SHIFT+UP/DOWN shortcut but both actions are fired. I also > opened the preferences dialog near the end of the log and the issue resolves > temporarily. > > The command used was: > ./netbeans -J-Dorg.openide.awt.MenuBar.level=FINE > -J-Dorg.netbeans.editor.MultiKeymap.level=FINE > -J-Dorg.netbeans.editor.ActionFactory.level=FINE --userdir > ~/tmp/netbeans-debug/ Thanks a lot for the testing. The expected MoveSelectionElseLineUpAction triggers normally through the MultiKeymap as expected. The extra CopySelectionElseLineUpAction is a result of the MenuBar translation. It's not clear to me why it's necessary to translate the events when there are already extra modifiers (e.g. 'D' instead of 'C') that should already serve for that purpose too - javadoc says "Alt can be used as the compose character on international keyboards" but IMHO input methods should capture such input prior key binding processing anyway but I may be missing something here. Reassigning to platform/windows for further evaluation.
It seems that the ctrl <-> alt translation hack is no longer needed so I removed it in core-main d2293d9ae769 Please reopen or file a new bug if you encounter any weird keyboard shortcut behavior on Mac with this fix.
Integrated into 'main-silver', will be available in build *201312190002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/15ed5385984b User: Miloslav Metelka <mmetelka@netbeans.org> Log: #235288 - Move Line(s) Up/Down duplicates line - added two loggers.