[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/12] Add backslashes to words with spaces in autocomplete()
[Thread Prev] | [Thread Next]
- Subject: [PATCH 12/12] Add backslashes to words with spaces in autocomplete()
- From: Rory Dudley <rory@xxxxxxx>
- Reply-to: rory@xxxxxxx
- Date: Mon, 30 Sep 2024 21:43:02 -0600
- To: lore@xxxxxxxxxxxx
This patch makes it so that the autcomplete() function automatically inserts the backslash character (`\`) into words with spaces when cylcing through the options. --- src/buffer.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/buffer.rs b/src/buffer.rs index 366f20a..7ece258 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -152,12 +152,22 @@ fn autocomplete( path.file_name().unwrap().to_str().unwrap().to_string() }; - let path = if word.is_empty() { + let mut path = if word.is_empty() { path } else { path[word.len()..].to_string() }; + let pause_positions = path + .chars() + .enumerate() + .filter(|(_, c)| *c == ' ') + .map(|(i, _)| i) + .collect::<Vec<_>>(); + for pos in pause_positions { + path.insert(pos, '\\'); + } + print!("{}", path); Ok((path, paths.len())) -- 2.46.2
[PATCH 01/12] Ignore patch files | Rory Dudley <rory@xxxxxxx> |