mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 13:23:09 +00:00
Allow 'commandline' to set the commandline from the prompt
This means that running `commandline foo` will indeed set the text of the command line to `foo`; it won't get cleared immediately. Fixes #8807
This commit is contained in:
parent
cf620c829b
commit
299ed9f903
2 changed files with 23 additions and 4 deletions
|
@ -2952,9 +2952,12 @@ static int read_i(parser_t &parser) {
|
|||
while (!check_exit_loop_maybe_warning(data.get())) {
|
||||
++run_count;
|
||||
|
||||
maybe_t<wcstring> tmp = data->readline(0);
|
||||
if (tmp && !tmp->empty()) {
|
||||
const wcstring command = tmp.acquire();
|
||||
if (maybe_t<wcstring> mcmd = data->readline(0)) {
|
||||
const wcstring command = mcmd.acquire();
|
||||
if (command.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
data->update_buff_pos(&data->command_line, 0);
|
||||
data->command_line.clear();
|
||||
data->command_line_changed(&data->command_line);
|
||||
|
@ -2984,6 +2987,10 @@ static int read_i(parser_t &parser) {
|
|||
// Reset the warning.
|
||||
data->did_warn_for_bg_jobs = false;
|
||||
}
|
||||
|
||||
// Apply any command line update from this command or fish_postexec, etc.
|
||||
// See #8807.
|
||||
data->apply_commandline_state_changes();
|
||||
}
|
||||
}
|
||||
reader_pop();
|
||||
|
|
|
@ -2,7 +2,14 @@
|
|||
from pexpect_helper import SpawnedProc
|
||||
|
||||
sp = SpawnedProc()
|
||||
send, sendline, sleep, expect_prompt, expect_str = sp.send, sp.sendline, sp.sleep, sp.expect_prompt, sp.expect_str
|
||||
send, sendline, sleep, expect_prompt, expect_re, expect_str = (
|
||||
sp.send,
|
||||
sp.sendline,
|
||||
sp.sleep,
|
||||
sp.expect_prompt,
|
||||
sp.expect_re,
|
||||
sp.expect_str,
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
sendline("bind '~' 'handle_tilde'")
|
||||
|
@ -47,3 +54,8 @@ sendline("complete -c foo -xa '(commandline)'")
|
|||
expect_prompt()
|
||||
send("foo bar \t")
|
||||
expect_str("foo bar foo\ bar\ ")
|
||||
send("\b" * 64)
|
||||
|
||||
# Commandline works when run on its own (#8807).
|
||||
sendline("commandline whatever")
|
||||
expect_re("prompt [0-9]+>whatever")
|
||||
|
|
Loading…
Reference in a new issue