summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-04-06 23:13:52 +0200
committerTom Smeding <tom.smeding@gmail.com>2020-04-06 23:13:52 +0200
commitef9c115245663a0ba8cc6aae428511fe98233062 (patch)
tree05fce73297407bcc37083bec11a1788f697cc2b4
parent3775e0e0ce079d12e40aef18f2b5b5598831c380 (diff)
Fix behaviour for commands on too-empty stack with non-empty bufferHEADmaster
-rw-r--r--src/main.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 3b8547f..42b9460 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -200,6 +200,10 @@ fn handle_key(key: Key, st: &mut State<'_>) -> Option<bool> {
if st.input_buffer.len() != 0 {
match st.input_buffer.parse::<Entry>() {
Ok(val) => {
+ if st.stk.len() + 1 < nargs {
+ return None;
+ }
+
st.stk.push(val);
print!("{}\r{}{}",
termion::clear::CurrentLine,
@@ -215,12 +219,13 @@ fn handle_key(key: Key, st: &mut State<'_>) -> Option<bool> {
Err(_) => return None,
}
} else {
+ if st.stk.len() < nargs {
+ return None;
+ }
+
delay_lf = 0;
}
- if st.stk.len() < nargs {
- return None;
- }
let prevlen = st.stk.len();
let npushed = f(&mut st.stk);
let sizeincr = st.stk.len() as isize - prevlen as isize;