diff --git a/src/reader.cpp b/src/reader.cpp index 51900950f..59522a865 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -2952,9 +2952,12 @@ static int read_i(parser_t &parser) { while (!check_exit_loop_maybe_warning(data.get())) { ++run_count; - maybe_t tmp = data->readline(0); - if (tmp && !tmp->empty()) { - const wcstring command = tmp.acquire(); + if (maybe_t 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(); diff --git a/tests/pexpects/commandline.py b/tests/pexpects/commandline.py index 6d03f0da3..79f95aab3 100644 --- a/tests/pexpects/commandline.py +++ b/tests/pexpects/commandline.py @@ -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")