Cmd-Left and Cmd-Right not as expected on MacOS
See original GitHub issueOn MacOS, Cmd-Left and Cmd-Right are supposed to be basically the same as “Home” and “End.”
However, in QtConsole, Cmd-Left has a strange behavior: it literally brings you to the beginning of the line - aka before the prompt. Then, since the cursor is positioned at an “invalid” location, once you type anything it brings you right back to the end of the line.
Adding 8 lines of code to _event_filter_console_keypress(self, event)
in console-widget.py
yields the correct behavior:
...
def _event_filter_console_keypress(self, event):
""" Filter key events for the underlying text widget to create a
console-like interface.
"""
intercepted = False
cursor = self._control.textCursor()
position = cursor.position()
key = event.key()
ctrl_down = self._control_key_down(event.modifiers())
alt_down = event.modifiers() & QtCore.Qt.AltModifier
shift_down = event.modifiers() & QtCore.Qt.ShiftModifier
#### BEGIN INSERT
cmd_down = \
sys.platform == "darwin" and \
self._control_key_down(event.modifiers(), include_command=True)
if cmd_down:
if key == QtCore.Qt.Key_Left:
key = QtCore.Qt.Key_Home
elif key == QtCore.Qt.Key_Right:
key = QtCore.Qt.Key_End
#### END INSERT
#------ Special modifier logic -----------------------------------------
...
You could also probably make a _cmd_down_remap
similar to the _ctrl_down_remap
that you already have, but this seemed simpler.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
How to get Cmd-left/right working with iTerm2 and Vim ...
To mimic OS X's behavior of sending Cmd-left/right to the beginning/end of a line, I add the following mappings in iTerm2:.
Read more >Apple terminal no home and end key - Use cmd left or cmd right
This keyboard shortcut works on most things on my mac book but not the Terminal. Usually I use the home and end keys...
Read more >MacOS: Text navigation and highlighting w/keyboard ... - GitHub
If anyone wants to fix it for themselfs: In usekeymap.ts (line ~156+) change the following 4 lines: 'Cmd-Left': 'goGroupLeft', 'Cmd-Right': ' ...
Read more >Cmd+left arrow on Mac behaviour - Technical Support
Hi, I am running build 2160 on Mac OS X 10.7.2. I am experiencing non-standard behavior for cmd+left arrow for long word wrapped...
Read more >Wrong behavior of the "HOME" and "END" key on the macOS ...
I'm not sure if this is a Mac issue or an emacs issue, but on my Windows and Linux machines, the "HOME" and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Makes sense. OK, so forgetting that - it seems like the way I’m doing the cmd remapping is alright, so I’ll put these things together in a new PR.
@impact27, your thought about checking the line number is good; I don’t know the easiest way to do that though. Maybe best in a separate issue…
Mike
On Tue, May 4, 2021 at 11:15 PM Carlos Cordoba @.***> wrote:
OK, PR submitted in #488.