ctrl-space tra
What Operating System(s) are you seeing this problem on?
Windows
Which Wayland compositor or X11 Window manager(s) are you using?
No response
WezTerm version
20230712-072601-f4abf8fd
Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?
No, and I'll explain why below
Describe the bug
Not sure how to get nightly through winget. I have seen the couple of previous bug from mar/april referring to ctrl /, and ctrl-i. I am seeing an issue with ctrl-space.
I first found this due to being unable to get a keymap working in neovim. If I open the neovim qt terminal, then c-space works ok.
To Reproduce
in wezterm launch nvim with nvim --clean
in nvim, after pressing i to enter insert mode, ctrl + v enters a kind of 'capture' mode. Then enter ctrl + space. The initial ^ from the ctrl-v is present and hasnt been updated from the ctrl-space combination.
Configuration
-- Pull in the wezterm API
local wezterm = require 'wezterm'
local act = wezterm.action
-- This table will hold the configuration.
local config = {}
-- config.debug_key_events = true
-- In newer versions of wezterm, use the config_builder which will
-- help provide clearer error messages
if wezterm.config_builder then
config = wezterm.config_builder()
end
-- This is where you actually apply your config choices
-- For example, changing the color scheme:
--config.color_scheme = 'rose-pine-moon'
config.color_scheme = 'rose-pine-moon'
config.colors = {
scrollbar_thumb = '#555588',
}
config.default_prog = { 'c:\\Program Files\\git\\bin\\bash.exe', '--login' }
config.font = wezterm.font_with_fallback({
"CaskaydiaCove Nerd Font Mono",
"Cascadia Code Mono",
"JetBrains Mono",
})
-- disable ligatures
config.harfbuzz_features = { 'calt=0', 'clig=0', 'liga=0' }
config.enable_scroll_bar = true
config.keys = {
{ key = 'v', mods = 'CTRL|SHIFT', action = act.PasteFrom 'Clipboard' },
{ key = 'c', mods = 'CTRL|SHIFT', action = act.CopyTo 'Clipboard' },
}
-- multiplexing
--config.unix_domains = {
-- {
-- name = 'unix',
-- },
--}
-- This causes `wezterm` to act as though it was started as
-- `wezterm connect unix` by default, connecting to the unix
-- domain on startup.
-- If you prefer to connect manually, leave out this line.
-- config.default_gui_startup_args = { 'connect', 'unix' }
config.initial_rows = 25
config.initial_cols = 120
-- and finally, return the configuration to wezterm
return config
Expected Behavior
launch nvim with nvim --clean
in nvim, after pressing i to enter insert mode, ctrl + v enters a kind of 'capture' mode. Then ctrl + space should result in <C-Space> being inserted.
Check that ctrl+v functionality is working as expected (from insert mode): ctrl + v, ctrl + j should insert ^@
Logs
23:44:53.547 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event RawKeyEvent { key: Physical(LeftControl), modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, phys_code: Some(LeftControl), raw_code: 17, scan_code: 29, repeat_count: 1, key_is_down: true, handled: Handled(false) }
23:44:53.550 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event KeyEvent { key: LeftControl, modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(LeftControl), modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, phys_code: Some(LeftControl), raw_code: 17, scan_code: 29, repeat_count: 1, key_is_down: true, handled: Handled(false) }), win32_uni_char: Some('\0') }
23:44:53.551 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > win32: Encoded input as "\u{1b}[17;29;0;1;8;1_"
23:44:53.850 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event RawKeyEvent { key: Physical(Space), modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, phys_code: Some(Space), raw_code: 32, scan_code: 57, repeat_count: 1, key_is_down: true, handled: Handled(false) }
23:44:53.853 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event KeyEvent { key: Char(' '), modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, repeat_count: 1, key_is_down: true, raw: Some(RawKeyEvent { key: Physical(Space), modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, phys_code: Some(Space), raw_code: 32, scan_code: 57, repeat_count: 1, key_is_down: true, handled: Handled(false) }), win32_uni_char: Some(' ') }
23:44:53.855 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > win32: Encoded input as "\u{1b}[32;57;32;1;8;1_"
23:44:53.943 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event RawKeyEvent { key: Physical(Space), modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, phys_code: Some(Space), raw_code: 32, scan_code: 57, repeat_count: 1, key_is_down: false, handled: Handled(false) }
23:44:53.946 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event KeyEvent { key: Char(' '), modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(Space), modifiers: CTRL | LEFT_CTRL, leds: NUM_LOCK, phys_code: Some(Space), raw_code: 32, scan_code: 57, repeat_count: 1, key_is_down: false, handled: Handled(false) }), win32_uni_char: Some(' ') }
23:44:53.948 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > win32: Encoded input as "\u{1b}[32;57;32;0;8;1_"
23:44:54.124 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event RawKeyEvent { key: Physical(LeftControl), modifiers: NONE, leds: NUM_LOCK, phys_code: Some(LeftControl), raw_code: 17, scan_code: 29, repeat_count: 1, key_is_down: false, handled: Handled(false) }
23:44:54.127 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > key_event KeyEvent { key: LeftControl, modifiers: NONE, leds: NUM_LOCK, repeat_count: 1, key_is_down: false, raw: Some(RawKeyEvent { key: Physical(LeftControl), modifiers: NONE, leds: NUM_LOCK, phys_code: Some(LeftControl), raw_code: 17, scan_code: 29, repeat_count: 1, key_is_down: false, handled: Handled(false) }), win32_uni_char: Some('\0') }
23:44:54.128 ←[32mINFO ←[0m ←[1mwezterm_gui::termwindow::keyevent←[0m > win32: Encoded input as "\u{1b}[17;29;0;0;0;1_"
Anything else?
on windows with nvim installed, launching the nvim qt terminal handles ctrl-space as expected.
Possibly I could use this workaround that was mentioned for win terminal (not sure how to convert to wezterm config) https://github.com/microsoft/terminal/issues/2865#issuecomment-929522127
I'd suggest disabling https://wezfurlong.org/wezterm/config/lua/config/allow_win32_input_mode.html https://wezfurlong.org/wezterm/config/key-encoding.html has more information about keyboard encoding
Thanks for the reply.
I tried different combinations of enable_csi_u_key_encoding and allow_win32_input_mode, but didn't see any differences.
After some experimenting I have had success with this workaround in the context of Neovim (I have not tested it elsewhere):
local act = wezterm.action
local config = {}
config.default_prog = { 'pwsh.exe' }
config.keys = {
{
key = ' ',
mods = 'CTRL',
action = act.SendKey {
key = ' ',
mods = 'CTRL',
},
}
}
return config
Wow, great! This works with git-bash and neovim
If anyone is on OSX and wondering why it's not working, -- ctrl-space is the default "previous input source" hotkey https://apple.stackexchange.com/questions/423971/disable-controlspace-keyboard-shortcut so if it's on (which it is by default) then Wezterm never even sees the hotkey. Disable it in osx and it should just work (none of the keymapping needed)
@Kamholtz Does this still work for you? It does not for me.
do this instead:
{
key = " ",
mods = "CTRL",
action = wezterm.action.SendKey({
key = " ",
mods = "CTRL",
}),
},
I used tmux in wsl.exe before and never encountered this problem.
I find C-Space became weird when I used ssh.exe to connect to linux to use tmux. Because I didn't know I was using C:\Windows\System32\OpenSSH\ssh.exe instead of git\usr\bin\ssh.exe.