mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
input: Let function_pop_arg return an Option
This would crash if you ran `commandline -f backward-jump`. The C++ version would read a char (but badly), this doesn't anymore. So, at least instead of crashing, just do nothing.
This commit is contained in:
parent
19d92a9476
commit
c7d878a8d2
3 changed files with 9 additions and 5 deletions
|
@ -495,10 +495,9 @@ impl Inputter {
|
|||
self.input_function_args.push(arg);
|
||||
}
|
||||
|
||||
pub fn function_pop_arg(&mut self) -> char {
|
||||
pub fn function_pop_arg(&mut self) -> Option<char> {
|
||||
self.input_function_args
|
||||
.pop()
|
||||
.expect("function_pop_arg underflow")
|
||||
}
|
||||
|
||||
fn function_push_args(&mut self, code: ReadlineCmd) {
|
||||
|
|
|
@ -3072,10 +3072,11 @@ impl ReaderData {
|
|||
_ => unreachable!(),
|
||||
};
|
||||
let (elt, _el) = self.active_edit_line();
|
||||
let target = self.inputter.function_pop_arg();
|
||||
let success = self.jump(direction, precision, elt, target);
|
||||
if let Some(target) = self.inputter.function_pop_arg() {
|
||||
let success = self.jump(direction, precision, elt, target);
|
||||
|
||||
self.inputter.function_set_status(success);
|
||||
self.inputter.function_set_status(success);
|
||||
}
|
||||
}
|
||||
rl::RepeatJump => {
|
||||
let (elt, _el) = self.active_edit_line();
|
||||
|
|
|
@ -372,6 +372,10 @@ send('\x07') # ctrl-g
|
|||
send('\r')
|
||||
expect_prompt("foobar")
|
||||
|
||||
# This should do nothing instead of crash
|
||||
sendline("commandline -f backward-jump")
|
||||
expect_prompt()
|
||||
|
||||
# Check that the builtin version of `exit` works
|
||||
# (for obvious reasons this MUST BE LAST)
|
||||
sendline("function myexit; echo exit; exit; end; bind ctrl-z myexit")
|
||||
|
|
Loading…
Reference in a new issue