From 8584b38cfbe6ffe3e5d539ad953c413e44e90bfa Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Tue, 1 Nov 2022 12:48:37 +0100 Subject: Correctly handle escaping in completion (#4316) * Correctly handle escaping in completion * Added escaping tests--- helix-term/src/ui/prompt.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'helix-term/src/ui') diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index db3bd62d..d0991d3c 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -1,5 +1,6 @@ use crate::compositor::{Component, Compositor, Context, Event, EventResult}; use crate::{alt, ctrl, key, shift, ui}; +use helix_core::shellwords; use helix_view::input::KeyEvent; use helix_view::keyboard::KeyCode; use std::{borrow::Cow, ops::RangeFrom}; @@ -335,7 +336,10 @@ impl Prompt { let (range, item) = &self.completion[index]; - self.line.replace_range(range.clone(), item); + // since we are using shellwords to parse arguments, make sure + // that whitespace in files is properly escaped. + let item = shellwords::escape(item); + self.line.replace_range(range.clone(), &item); self.move_end(); } -- cgit v1.2.3-70-g09d2