From 1b9e5258b52f68f28bac0b77833734811bbe9265 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 26 Jan 2024 18:26:39 +0100 Subject: [PATCH] Fix regression when erasing word in search field This fixes a crash introduced in the reader port. The tmux tests are not great but at least easy to write. --- src/reader.rs | 2 +- tests/checks/tmux-history-search.fish | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/reader.rs b/src/reader.rs index 85bf99d17..187ed54a2 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -1573,7 +1573,7 @@ fn move_word( let mut buff_pos = el.position(); while buff_pos != boundary { let idx = if move_right { buff_pos } else { buff_pos - 1 }; - let c = self.command_line.at(idx); + let c = el.at(idx); if !state.consume_char(c) { break; } diff --git a/tests/checks/tmux-history-search.fish b/tests/checks/tmux-history-search.fish index 7b2425400..6e51e7902 100644 --- a/tests/checks/tmux-history-search.fish +++ b/tests/checks/tmux-history-search.fish @@ -34,3 +34,11 @@ tmux-sleep isolated-tmux send-keys Enter # CHECK: prompt 2> echo no such command in history isolated-tmux capture-pane -p | grep 'prompt 2' +isolated-tmux send-keys C-c + +isolated-tmux send-keys C-r hay/shmay +isolated-tmux send-keys C-w C-h +isolated-tmux send-keys Enter +# CHECK: prompt 2> true hay ee hay +isolated-tmux capture-pane -p | grep 'prompt 2>' +isolated-tmux send-keys C-c