summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRory Dudley2024-12-16 22:51:45 -0700
committerRory Dudley2024-12-16 22:51:45 -0700
commitb4128c1cbd14216d29811640dfd0bc44f143b8ca (patch)
tree5b009e1dc02dd893d022961372c4ca934b3723a4
parent960b0123ee202aef0cfcd294d56af1713cb91de1 (diff)
downloaddwarvish-b4128c1cbd14216d29811640dfd0bc44f143b8ca.tar.gz
Only ignore double slashes after comp was initiated
This patch changes the check for and removal of a second slash by enabling it only after the user as initiated completion (i.e. presed Tab or Shift+Tab). This makes it possible to type two forward slashes (for instance, when typing or pasting in a URL) without having to go back and edit the buffer after the fact.
-rw-r--r--src/buffer.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/buffer.rs b/src/buffer.rs
index a9d925b..7ed05ba 100644
--- a/src/buffer.rs
+++ b/src/buffer.rs
@@ -565,7 +565,7 @@ pub fn getline(
Key::Else(c) => {
let mut buffer = buffer.lock().unwrap();
match buffer.last() {
- Some(last) if *last == '/' && c == '/' => {
+ Some(last) if *comp_pos.lock().unwrap() != 0 && *last == '/' && c == '/' => {
buffer.pop();
*pos.lock().unwrap() -= 1;
print!("\u{8} \u{8}")
@@ -577,7 +577,6 @@ pub fn getline(
let trunc_width = UnicodeWidthStr::width(trunc.as_str());
buffer.insert(*pos.lock().unwrap(), c);
*pos.lock().unwrap() += 1;
- // *pos.lock().unwrap() += UnicodeWidthChar::width(c).unwrap_or(1);
if *pos.lock().unwrap() == buffer.len() {
print!("{}", c);
} else {