diff options
author | Rory Dudley | 2024-09-29 00:54:08 -0600 |
---|---|---|
committer | Rory Dudley | 2024-09-29 00:54:08 -0600 |
commit | 821f8dc319c47da512f0b493fd4fea17546d6509 (patch) | |
tree | ed8b803bfebfe8d2c1e79513cfe5e99912f4ea40 | |
parent | 4f62017709220bbc6d60f51720f13fe1ecb19058 (diff) | |
download | dwarvish-escsq.tar.gz |
Add backslashes to words with spaces in autocomplete()escsq
This patch makes it so that the autcomplete() function automatically
inserts the backslash character (`\`) into words with spaces when
cylcing through the options.
-rw-r--r-- | src/buffer.rs | 12 |
1 files changed, 11 insertions, 1 deletions
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())) |