Bug: Ctrl+U does not clear current line in embedded terminal
What Happened?
In the embedded terminal inside Code, the keyboard shortcut Ctrl+U doesn’t work as expected.
In most terminals (and in any standard shell using GNU Readline or similar), Ctrl+U is the default shortcut to clear the current line — deleting all text from the cursor back to the start of the line.
This behavior works correctly in elementary Terminal and most other terminal emulators, but not inside Code’s embedded terminal.
Steps to Reproduce
- Open Code.
- Open the embedded terminal (bottom panel).
- Type any command (e.g., echo hello world).
- Press
Ctrl+U.
Expected Behavior
Expected result:
The current line should be cleared, just like in any standard readline-based terminal.
Actual result:
Nothing happens — the keybinding appears to be ignored.
OS Version
8.x (Circe)
OS Architecture
amd64 (on most hardwares)
Session Type
Secure Session (Wayland)
Software Version
Latest release (I have run all updates)
Log Output
Hardware Info
No response
After some investigation I got it to work in Code by disabling the system shortcut for "Enable Unicode Typing" (<Shift><Control>U) This shortcut then has the required effect in the terminal pane. However <Ctrl>U is still not working and it is not at all obvious why. In fact it is not obvious why it works in Terminal. Smart copy-paste (which is not currently implemented in Code) allows you to use e.g. <Ctrl>C instead of <Shift><Ctrl>C but I didnt think it affected the <Ctrl>U shortcut. I'll investigate further.
Can it be because of this?
https://github.com/elementary/code/blob/dca3a350a61e784e049ac012e4396158cd2028df/src/MainWindow.vala#L224
Yes! I missed that - thanks. I've never used that accelerator tbh. I don't know how useful it is. I guess it could be changed to something else if it is not standard.
Seems Visual Studioand NotePad use <Control><Shift>U. Outlook and Word use <Shift>F3 I would prefer the former - we could change to that (as well as the corresponding shortcut for lowercase) - except that would clash with the UniCode shortcut 😞
Would it make sense to scope editor-only bindings to the editor widget instead?
Like:
- Remove the case-change accelerators from
MainWindow.action_accelerators. - Add a
Gtk.ShortcutController(orGtk.EventControllerKey) toDocumentView/SourceViewthat registers the text-only shortcuts. - In those controller callbacks, call the existing upper/lower functions (or dispatch to the same actions) so behaviour stays identical while the shortcuts only exist when a document view has focus.
That approach could also cover other text-editing bindings—things like duplicate line, clear line, toggle comment, "sort lines", maybe even undo/redo if we ever want the terminal to keep its shell-centric bindings. Meanwhile, global shortcuts (new tab, open folder, toggle sidebar/terminal, global search, quit, etc.) would continue to live in the main action group.
Does that sound too complex?
@lobre Yes, I also thought of using ShortcutController to localize the accelerator. It shouldn't cause any confusion I guess because the context is clear. We'll have to wait for the Gtk4 port for that though. I am not sure if is possible in Gtk3.
Good catch, that seems accurate, as there doesn't seem to be a clean, built-in way to scope shortcuts per widget in Gtk3.
It might be a wise decision to keep that aside and wait for the Gtk4 port, then?