on master help sign in
Fix completion on paths containing spaces (#6779)
2cccb3fIvan Gulakov
helix-term/src/commands/typed.rs+4−7
@@ -2847,13 +2847,10 @@ pub(super) fn command_mode(cx: &mut Context) {
2847 } else {
2847 } else {
2848 // Otherwise, use the command's completer and the last shellword
2848 // Otherwise, use the command's completer and the last shellword
2849 // as completion input.
2849 // as completion input.
2850− let (part, part_len) = if words.len() == 1 || shellwords.ends_with_whitespace() {
2850+ let (word, word_len) = if words.len() == 1 || shellwords.ends_with_whitespace() {
2851 (&Cow::Borrowed(""), 0)
2851 (&Cow::Borrowed(""), 0)
2852 } else {
2852 } else {
2853− (
2854− words.last().unwrap(),
2853+ (words.last().unwrap(), words.last().unwrap().len())
2855− shellwords.parts().last().unwrap().len(),
2856− )
2857 };
2854 };
2858
2855
2859 let argument_number = argument_number_of(&shellwords);
2856 let argument_number = argument_number_of(&shellwords);
@@ -2862,13 +2859,13 @@ pub(super) fn command_mode(cx: &mut Context) {
2862 .get(&words[0] as &str)
2859 .get(&words[0] as &str)
2863 .map(|tc| tc.completer_for_argument_number(argument_number))
2860 .map(|tc| tc.completer_for_argument_number(argument_number))
2864 {
2861 {
2865− completer(editor, part)
2862+ completer(editor, word)
2866 .into_iter()
2863 .into_iter()
2867 .map(|(range, file)| {
2864 .map(|(range, file)| {
2868 let file = shellwords::escape(file);
2865 let file = shellwords::escape(file);
2869
2866
2870 // offset ranges to input
2867 // offset ranges to input
2871− let offset = input.len() - part_len;
2868+ let offset = input.len() - word_len;
2872 let range = (range.start + offset)..;
2869 let range = (range.start + offset)..;
2873 (range, file)
2870 (range, file)
2874 })
2871 })