From dc129add9e547d5f6b6eebbb96fb519e9dad85e7 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 16 Jan 2025 23:11:09 +0100 Subject: [PATCH] Assert that autosuggestions are always valid This documents an invariant established by 532abaddae9 (Invalidate stale autosuggestions eagerly, 2024-12-25). It was initially broken but fixed in ba4ead6eada (Stop saving autosuggestions that we can't restore, 2025-01-17). --- src/reader.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/reader.rs b/src/reader.rs index bcf462193..6c7b5d56f 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -4881,7 +4881,13 @@ fn update_autosuggestion(&mut self) { } let el = &self.data.command_line; + let autosuggestion = &self.autosuggestion; if self.is_at_line_with_autosuggestion() { + assert!(string_prefixes_string_maybe_case_insensitive( + autosuggestion.icase, + &el.text()[autosuggestion.search_string_range.clone()], + &autosuggestion.text + )); return; }