From ef9c115245663a0ba8cc6aae428511fe98233062 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 6 Apr 2020 23:13:52 +0200 Subject: Fix behaviour for commands on too-empty stack with non-empty buffer --- src/main.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') 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 { if st.input_buffer.len() != 0 { match st.input_buffer.parse::() { 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 { 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; -- cgit v1.2.3-70-g09d2