From 2af8e55e87c172d707a728a9739f800048e1ed0a Mon Sep 17 00:00:00 2001 From: Rory Dudley Date: Mon, 16 Dec 2024 22:53:57 -0700 Subject: 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. Signed-off-by: Rory Dudley --- src/buffer.rs | 3 +-- 1 file changed, 1 insertion(+), 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 { -- cgit v1.2.3