aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorJonas Maier <>2026-03-05 10:27:10 +0100
committerJonas Maier <>2026-03-05 10:27:10 +0100
commit50fc850f165482a8304681e85a70ffb41dba731d (patch)
tree37d163a5433f6e78eaff116fa09fc09213ecd364 /src/main.rs
parentd62649f0aed0daca805d716819db32d5e9263865 (diff)
downloadpish-50fc850f165482a8304681e85a70ffb41dba731d.tar.gz
allow editing of prev command with backspace
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 9d8f191..4e3bb23 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -195,7 +195,13 @@ fn main() {
// Backspace (127 on most systems)
127 => {
- if line.del_left().is_some() {
+ if line.is_empty() && !line.is_dirty() && !history.is_empty() {
+ // take previous command for editing
+ let cmd = history[history.len() - 1].clone();
+ io::stdout().write_all(&cmd).unwrap();
+ io::stdout().flush().unwrap();
+ line.set_content(cmd);
+ } else if line.del_left().is_some() {
print!("\x08 \x08");
}
}