Skip to content

Light TUI doesn't handle kitty keyboard protocol's arrows without modifiers #4776

@TymekDev

Description

@TymekDev

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.71.0 (v0.71.0)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

I checked both Linux and macOS as Wezterm runs on macOS and SSHs to Linux.

  1. Enable kitty keyboard protocol in Wezterm
  2. Connect to a remote machine via SSH
    • This way Wezterm just forwards escape sequences
  3. Run fzf --height 50% on the remote machine
  4. Arrows don't work and instead insert strings like 1;1A

From what I understand the issue is in the light TUI which only handles arrows with modifiers. I gave fixing this a go and this patch seems to fix this:

fzf-light-tui-arrow-handling.patch
diff --git a/src/tui/light.go b/src/tui/light.go
index 77f15b9a..dd980901 100644
--- a/src/tui/light.go
+++ b/src/tui/light.go
@@ -689,6 +689,7 @@ func (r *LightRenderer) escSequence(sz *int) Event {
 					switch r.buffer[4] {
 					case '1', '2', '3', '4', '5', '6', '7', '8', '9':
 						//                   Kitty      iTerm2     WezTerm
+						// ARROW             "\e[1;1D"
 						// SHIFT-ARROW       "\e[1;2D"
 						// ALT-SHIFT-ARROW   "\e[1;4D"  "\e[1;10D" "\e[1;4D"
 						// CTRL-SHIFT-ARROW  "\e[1;6D"             N/A
@@ -743,6 +744,7 @@ func (r *LightRenderer) escSequence(sz *int) Event {
 							if shift {
 								return Event{ShiftUp, 0, nil}
 							}
+							return Event{Up, 0, nil}
 						case 'B':
 							if ctrlAltShift {
 								return Event{CtrlAltShiftDown, 0, nil}
@@ -765,6 +767,7 @@ func (r *LightRenderer) escSequence(sz *int) Event {
 							if shift {
 								return Event{ShiftDown, 0, nil}
 							}
+							return Event{Down, 0, nil}
 						case 'C':
 							if ctrlAltShift {
 								return Event{CtrlAltShiftRight, 0, nil}
@@ -787,6 +790,7 @@ func (r *LightRenderer) escSequence(sz *int) Event {
 							if alt {
 								return Event{AltRight, 0, nil}
 							}
+							return Event{Right, 0, nil}
 						case 'D':
 							if ctrlAltShift {
 								return Event{CtrlAltShiftLeft, 0, nil}
@@ -809,6 +813,7 @@ func (r *LightRenderer) escSequence(sz *int) Event {
 							if shift {
 								return Event{ShiftLeft, 0, nil}
 							}
+							return Event{Left, 0, nil}
 						case 'H':
 							if ctrlAltShift {
 								return Event{CtrlAltShiftHome, 0, nil}
@@ -831,6 +836,7 @@ func (r *LightRenderer) escSequence(sz *int) Event {
 							if shift {
 								return Event{ShiftHome, 0, nil}
 							}
+							return Event{Home, 0, nil}
 						case 'F':
 							if ctrlAltShift {
 								return Event{CtrlAltShiftEnd, 0, nil}
@@ -853,6 +859,7 @@ func (r *LightRenderer) escSequence(sz *int) Event {
 							if shift {
 								return Event{ShiftEnd, 0, nil}
 							}
+							return Event{End, 0, nil}
 						}
 					} // r.buffer[4]
 				} // r.buffer[3]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions