From 039011bc817492f4c44aaaf5fa56c02b79c58107 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Wed, 18 Dec 2024 15:58:34 +0100 Subject: [PATCH] Make full autosuggestions case-correcting again Fixes ca21872d14 (Clean up the accept-autosuggestion code path a little bit, 2024-11-14). Fixes #10915 --- src/reader.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/reader.rs b/src/reader.rs index 6cacf8ca3..c652d7a93 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -4470,13 +4470,21 @@ fn accept_autosuggestion(&mut self, amount: AutosuggestionPortion) { match amount { AutosuggestionPortion::Count(count) => { let pos = self.command_line.len(); - let count = count.min(self.autosuggestion.text.len() - pos); - if count != 0 { + if count == usize::MAX { self.data.replace_substring( EditableLineTag::Commandline, - pos..pos, - self.autosuggestion.text[pos..pos + count].to_owned(), + 0..self.command_line.len(), + self.autosuggestion.text.clone(), ); + } else { + let count = count.min(self.autosuggestion.text.len() - pos); + if count != 0 { + self.data.replace_substring( + EditableLineTag::Commandline, + pos..pos, + self.autosuggestion.text[pos..pos + count].to_owned(), + ); + } } } AutosuggestionPortion::PerMoveWordStyle(style) => {