From ac9c339e5a26b70f08727872a2cf2b75e5baa918 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 2 Feb 2026 11:52:38 +1100 Subject: [PATCH] Vi bindings: remove unused special input functions These were only needed before the new approach from 38e633d49b1 (fish_vi_key_bindings: add support for count, 2025-12-16). --- CHANGELOG.rst | 4 +-- doc_src/cmds/bind.rst | 12 --------- share/functions/fish_vi_key_bindings.fish | 1 + src/input.rs | 6 +---- src/input_common.rs | 4 --- src/reader/reader.rs | 31 ++++++++--------------- 6 files changed, 14 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index bc5cc8bf3..eba3884ec 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,12 +10,12 @@ Interactive improvements - The ``bind`` builtin lists mappings from all modes if ``--mode`` is not provided (:issue:`12214`). - Line-wise autosuggestions that don't start a command are no longer shown (739b82c34db, 58e7a50de8a). - Builtin ``history`` now assumes that :envvar:`PAGER` supports ANSI color sequences. -- fish now clears the terminal's ``FLUSHO`` flag at startup, to fix an issue caused by pressing :kbd:`ctrl-o` on macOS (:issue:`12304`). +- fish now clears the terminal's ``FLUSHO`` flag when acquiring control of the terminal, to fix an issue caused by pressing :kbd:`ctrl-o` on macOS (:issue:`12304`). New or improved bindings ------------------------ - Vi mode word movements (``w``, ``W``, ``e``, and ``E``) are now largely in line with Vim. The only exception is that underscores are treated as word separators (:issue:`12269`). -- New special input functions to support these movements: ``forward-word-vi``, ``kill-word-vi``, ``forward-bigword-vi``, ``kill-bigword-vi``, ``forward-word-end``, ``backward-word-end``, ``kill-word-end``, ``backward-kill-word-end``, ``forward-bigword-end``, ``backward-bigword-end``, ``kill-bigword-end``, ``backward-kill-bigword-end``, ``kill-a-word``, ``kill-inner-word``, ``kill-a-bigword``, and ``kill-inner-bigword``. +- New special input functions to support these movements: ``forward-word-vi``, ``kill-word-vi``, ``forward-bigword-vi``, ``kill-bigword-vi``, ````forward-word-end``, ``backward-word-end``, ``forward-bigword-end``, ``backward-bigword-end``, ````kill-a-word``, ``kill-inner-word``, ``kill-a-bigword``, and ``kill-inner-bigword``. - Vi mode key bindings now support counts for movement and deletion commands (e.g. `d3w` or `3l`), via a new operator mode (:issue:`2192`). - New ``catpuccin-*`` color themes. diff --git a/doc_src/cmds/bind.rst b/doc_src/cmds/bind.rst index 5a5fb43b4..665de7464 100644 --- a/doc_src/cmds/bind.rst +++ b/doc_src/cmds/bind.rst @@ -154,12 +154,6 @@ The following special input functions are available: ``backward-kill-bigword`` move the whitespace-delimited word to the left of the cursor to the killring, until the start of the current word (like vim's ``dB``) -``backward-kill-word-end`` - move from the cursor to the end of the previous word to the killring (like vim's ``dge``) - -``backward-kill-bigword-end`` - move from the cursor to the end of the previous whitespace-delimited word to the killring (like vim's ``dgE``) - ``backward-path-component`` move one :ref:`path component ` to the left @@ -370,12 +364,6 @@ The following special input functions are available: ``kill-bigword-vi`` move the next whitespace-delimited word to the killring, stopping at the start of the next word (like vim's ``dW``) -``kill-bigword-end`` - move from the cursor to the end of the current whitespace-delimited word to the killring (like vim's ``dE``) - -``kill-word-end`` - move from the cursor to the end of the current word to the killring (like vim's ``de``) - ``kill-inner-word`` delete the word under the cursor (like vim's ``diw``) diff --git a/share/functions/fish_vi_key_bindings.fish b/share/functions/fish_vi_key_bindings.fish index b66b15b77..e22eec029 100644 --- a/share/functions/fish_vi_key_bindings.fish +++ b/share/functions/fish_vi_key_bindings.fish @@ -83,6 +83,7 @@ function fish_vi_exec_motion set swap_case_hack (string replace -r -- '^forward-((?:big)?word)-vi$' '$1' $motion) else set use_selection false + # kill-word-vi kill-bigword-vi set motion (string replace -- forward kill $motion) end end diff --git a/src/input.rs b/src/input.rs index b634b13d1..961f512d6 100644 --- a/src/input.rs +++ b/src/input.rs @@ -115,12 +115,10 @@ const fn make_md(name: &'static wstr, code: ReadlineCmd) -> InputFunctionMetadat make_md(L!("backward-jump"), ReadlineCmd::BackwardJump), make_md(L!("backward-jump-till"), ReadlineCmd::BackwardJumpTill), make_md(L!("backward-kill-bigword"), ReadlineCmd::BackwardKillBigword), - make_md(L!("backward-kill-bigword-end"), ReadlineCmd::BackwardKillBigwordEnd), make_md(L!("backward-kill-line"), ReadlineCmd::BackwardKillLine), make_md(L!("backward-kill-path-component"), ReadlineCmd::BackwardKillPathComponent), make_md(L!("backward-kill-token"), ReadlineCmd::BackwardKillToken), make_md(L!("backward-kill-word"), ReadlineCmd::BackwardKillWord), - make_md(L!("backward-kill-word-end"), ReadlineCmd::BackwardKillWordEnd), make_md(L!("backward-path-component"), ReadlineCmd::BackwardPathComponent), make_md(L!("backward-token"), ReadlineCmd::BackwardToken), make_md(L!("backward-word"), ReadlineCmd::BackwardWord), @@ -183,7 +181,6 @@ const fn make_md(name: &'static wstr, code: ReadlineCmd) -> InputFunctionMetadat make_md(L!("kill-a-bigword"), ReadlineCmd::KillABigWord), make_md(L!("kill-a-word"), ReadlineCmd::KillAWord), make_md(L!("kill-bigword"), ReadlineCmd::KillBigwordEmacs), - make_md(L!("kill-bigword-end"), ReadlineCmd::KillBigwordEnd), make_md(L!("kill-bigword-vi"), ReadlineCmd::KillBigwordVi), make_md(L!("kill-inner-bigword"), ReadlineCmd::KillInnerBigWord), make_md(L!("kill-inner-line"), ReadlineCmd::KillInnerLine), @@ -194,7 +191,6 @@ const fn make_md(name: &'static wstr, code: ReadlineCmd) -> InputFunctionMetadat make_md(L!("kill-token"), ReadlineCmd::KillToken), make_md(L!("kill-whole-line"), ReadlineCmd::KillWholeLine), make_md(L!("kill-word"), ReadlineCmd::KillWordEmacs), - make_md(L!("kill-word-end"), ReadlineCmd::KillWordEnd), make_md(L!("kill-word-vi"), ReadlineCmd::KillWordVi), make_md(L!("nextd-or-forward-word"), ReadlineCmd::NextdOrForwardWordEmacs), make_md(L!("or"), ReadlineCmd::FuncOr), @@ -229,7 +225,7 @@ const fn _assert_sizes_match() { INPUT_FUNCTION_METADATA.len() == input_function_count, concat!( "input_function_metadata size mismatch with input_common. ", - "Did you forget to update input_function_metadata?" + "Did you forget to update INPUT_FUNCTION_METADATA?" ) ); } diff --git a/src/input_common.rs b/src/input_common.rs index 61fe0c1b6..28b8f0466 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -91,8 +91,6 @@ pub enum ReadlineCmd { KillBigwordEmacs, KillWordVi, KillBigwordVi, - KillWordEnd, - KillBigwordEnd, KillInnerWord, KillInnerBigWord, KillAWord, @@ -100,10 +98,8 @@ pub enum ReadlineCmd { KillPathComponent, KillToken, BackwardKillWord, - BackwardKillWordEnd, BackwardKillPathComponent, BackwardKillBigword, - BackwardKillBigwordEnd, BackwardKillToken, HistoryTokenSearchBackward, HistoryTokenSearchForward, diff --git a/src/reader/reader.rs b/src/reader/reader.rs index 840fec164..a822ddd1b 100644 --- a/src/reader/reader.rs +++ b/src/reader/reader.rs @@ -3653,55 +3653,44 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) { } } } - rl::BackwardKillWord - | rl::BackwardKillPathComponent - | rl::BackwardKillBigword - | rl::BackwardKillWordEnd - | rl::BackwardKillBigwordEnd => { + rl::BackwardKillWord | rl::BackwardKillPathComponent | rl::BackwardKillBigword => { let style = match c { - rl::BackwardKillWord | rl::BackwardKillWordEnd => MoveWordStyle::Punctuation, - rl::BackwardKillBigword | rl::BackwardKillBigwordEnd => { - MoveWordStyle::Whitespace - } + rl::BackwardKillWord => MoveWordStyle::Punctuation, + rl::BackwardKillBigword => MoveWordStyle::Whitespace, rl::BackwardKillPathComponent => MoveWordStyle::PathComponents, _ => unreachable!(), }; - let to_word_end = matches!(c, rl::BackwardKillWordEnd | rl::BackwardKillBigwordEnd); // Is this the same killring item as the last kill? let newv = !matches!( self.rls().last_cmd, Some(rl::BackwardKillWord | rl::BackwardKillBigword) ); + let elt = self.active_edit_line_tag(); self.data.move_word( - self.active_edit_line_tag(), + elt, MoveWordDir::Left, /*erase=*/ true, style, newv, - to_word_end, + /*to_word_end=*/ false, ); } - rl::KillWordVi - | rl::KillBigwordVi - | rl::KillPathComponent - | rl::KillWordEnd - | rl::KillBigwordEnd => { + rl::KillWordVi | rl::KillBigwordVi | rl::KillPathComponent => { // The "bigword" functions differ only in that they move to the next whitespace, not // punctuation. let style = match c { - rl::KillWordVi | rl::KillWordEnd => MoveWordStyle::Punctuation, - rl::KillBigwordVi | rl::KillBigwordEnd => MoveWordStyle::Whitespace, + rl::KillWordVi => MoveWordStyle::Punctuation, + rl::KillBigwordVi => MoveWordStyle::Whitespace, rl::KillPathComponent => MoveWordStyle::PathComponents, _ => unreachable!(), }; - let to_word_end = matches!(c, rl::KillWordEnd | rl::KillBigwordEnd); self.data.move_word( self.active_edit_line_tag(), MoveWordDir::Right, /*erase=*/ true, style, self.rls().last_cmd != Some(c), - to_word_end, + /*to_word_end=*/ false, ); } rl::KillInnerWord | rl::KillInnerBigWord => {