Fix new-style bindings shadowing raw escape sequence bindings

Given

	bind up "echo user up, new notation"
	bind \e\[A "echo user up, legacy notation"

prior to b9d9e7edc6 (Match bindings with explicit shift
first, 2025-05-24), we prioritized the legacy notation because
input_mapping_insert_sorted() makes us try longer sequences first --
and "up" is only one key compared to the three-key legacy sequence.

This prioritization was broken in b9d9e7edc6, causing plugins that
update to the "bind up" notation to break users who haven't (#11803).

Even worse, it caused preset bindings to shadow user ones:

	bind --preset up "echo preset up, new notation"
	bind \e\[A "echo user up, legacy notation"

Restore backwards compatibility by treating matches against legacy
notation like exact matches again.

(cherry picked from commit 9a04c15894)
This commit is contained in:
Johannes Altmanninger
2025-09-17 14:49:24 +02:00
parent 23c25ffe43
commit 7783505bee
3 changed files with 9 additions and 11 deletions

View File

@@ -1,3 +1,10 @@
fish 4.0.7 (released September 18, 2025)
========================================
This release fixes a regression in 4.0.6 that caused user bindings to be shadowed by either fish's or a plugin's bindings (:issue:`11803`).
--------------
fish 4.0.6 (released September 12, 2025)
========================================

View File

@@ -589,11 +589,7 @@ fn next_is_char(
actual_seq.len()
)
);
return Some(if matches!(style, KeyNameStyle::Terminfo(_)) {
KeyMatchQuality::Exact
} else {
KeyMatchQuality::Legacy
});
return Some(KeyMatchQuality::Exact);
}
if key.modifiers == Modifiers::ALT && seq_char == '\x1b' {
if self.subidx + 1 == actual_seq.len() {
@@ -613,11 +609,7 @@ fn next_is_char(
self.subidx = 0;
}
FLOG!(reader, format!("matched {key} against raw escape sequence"));
return Some(if matches!(style, KeyNameStyle::Terminfo(_)) {
KeyMatchQuality::Exact
} else {
KeyMatchQuality::Legacy
});
return Some(KeyMatchQuality::Exact);
}
}
}

View File

@@ -211,7 +211,6 @@ fn apply_shift(mut key: Key, do_ascii: bool, shifted_codepoint: char) -> Option<
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum KeyMatchQuality {
Legacy,
BaseLayoutModuloShift,
BaseLayout,
ModuloShift,