From 67f1fe20c32bd7f44dd89bdee2ec4b7e4b81dd50 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sat, 31 May 2025 09:56:54 -0400 Subject: [PATCH] Fix command line completion replacement for quoted items With a directory with spaces in the name (for example `mkdir -p 'Temp/Abc Def'`), completing `Temp/Ab` would create a completion item `'Temp/AbAbc Def'`. Now it correctly completes `'Temp/Abc Def'` --- helix-term/src/commands/typed.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 808c12ca1..2013a9d81 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -3867,10 +3867,12 @@ fn quote_completion<'a>( span.content = Cow::Owned(format!( "'{}{}'", // Escape any inner single quotes by doubling them. - replace(token.content.as_ref().into(), '\'', "''"), + replace(token.content[..range.start].into(), '\'', "''"), replace(span.content, '\'', "''") )); - // Ignore `range.start` here since we're replacing the entire token. + // Ignore `range.start` here since we're replacing the entire token. We used + // `range.start` above to emulate the replacement that using `range.start` would have + // done. ((offset + token.content_start).., span) } TokenKind::Quoted(quote) => {