summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/buffer.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/buffer.rs b/src/buffer.rs
index bd5ab60..08c8653 100644
--- a/src/buffer.rs
+++ b/src/buffer.rs
@@ -165,13 +165,21 @@ fn comp(
*bpos -= *len;
}
+ let ori_path: String = buffer[*bpos..].into_iter().collect::<String>();
+ let mut width = UnicodeWidthStr::width(ori_path.as_str());
+
// Remove the last autocomplete value from the buffer
while *len > 0 {
buffer.pop();
- print!("\u{8} \u{8}");
*len -= 1;
}
+ // Remove the last autocomplete value from the shell
+ while width > 0 {
+ print!("\u{8} \u{8}");
+ width -= 1;
+ }
+
// Reverse the buffer, which will make our while loop further down much easier
let mut rev = buffer.iter().rev();
@@ -285,7 +293,7 @@ fn comp(
// Get the path (or only part of the path if we matched with word)
let path = paths[*pos].path();
- let mut path = if paths[*pos].path().is_dir() {
+ let path = if paths[*pos].path().is_dir() {
(path.file_name().unwrap().to_string_lossy()[word.len()..].to_string() + "/").to_string()
} else {
path.file_name().unwrap().to_string_lossy()[word.len()..].to_string()
@@ -324,7 +332,7 @@ fn comp(
}
// Update the length of the last comp
- *len = UnicodeWidthStr::width(path.as_str());
+ *len += path.chars().collect::<Vec<_>>().len();
// Update the buffer position
*bpos += *len;
@@ -523,6 +531,7 @@ 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 {
@@ -586,6 +595,7 @@ pub fn getline(
}
println!();
+ buffer.lock().unwrap().push('\n');
let mut bytes = 0;
buffer