on master help sign in
feat(ui): treat slashes as word separators in prompt (#2315)
2687b8funrelentingtech
helix-term/src/ui/prompt.rs+7−3
@@ -56,6 +56,10 @@ pub enum Movement {
56 None,
56 None,
57}
57}
58
58
59+fn is_word_sep(c: char) -> bool {
60+ c == std::path::MAIN_SEPARATOR || c.is_whitespace()
61+}
62+
59impl Prompt {
63impl Prompt {
60 pub fn new(
64 pub fn new(
61 prompt: Cow<'static, str>,
65 prompt: Cow<'static, str>,
@@ -118,7 +122,7 @@ impl Prompt {
118
122
119 let mut found = None;
123 let mut found = None;
120 for prev in (0..char_position - 1).rev() {
124 for prev in (0..char_position - 1).rev() {
121− if char_indices[prev].1.is_whitespace() {
125+ if is_word_sep(char_indices[prev].1) {
122 found = Some(prev + 1);
126 found = Some(prev + 1);
123 break;
127 break;
124 }
128 }
@@ -141,14 +145,14 @@ impl Prompt {
141 for _ in 0..rep {
145 for _ in 0..rep {
142 // Skip any non-whitespace characters
146 // Skip any non-whitespace characters
143 while char_position < char_indices.len()
147 while char_position < char_indices.len()
144− && !char_indices[char_position].1.is_whitespace()
148+ && !is_word_sep(char_indices[char_position].1)
145 {
149 {
146 char_position += 1;
150 char_position += 1;
147 }
151 }
148
152
149 // Skip any whitespace characters
153 // Skip any whitespace characters
150 while char_position < char_indices.len()
154 while char_position < char_indices.len()
151− && char_indices[char_position].1.is_whitespace()
155+ && is_word_sep(char_indices[char_position].1)
152 {
156 {
153 char_position += 1;
157 char_position += 1;
154 }
158 }