-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix whitespace handling in command-mode completion #4587
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
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}; | ||
|
@@ -336,10 +335,7 @@ impl Prompt { | |
|
||
let (range, item) = &self.completion[index]; | ||
|
||
// 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.line.replace_range(range.clone(), item); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we pass the entire item instead of just the reference? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. LGTM |
||
|
||
self.move_end(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this undo the previous PR? The idea was that it would complete paths with spaces in quotes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part moved into the
map
incommand_mode
: https://github.com/helix-editor/helix/pull/4587/files#diff-8f2b243886fc16c4a33efa5bd4ef54824301ed882ef62878ad9d4f6188d3d6a1R2227The nice part of moving it there is that the completion results in the prompt show as escaped which matches how you have to input them (for example a file "a b.txt" would show as
a\ b.txt
in the prompt's completion items).