Update commandline state before completion

Fixes #8175.
This commit is contained in:
Fabian Homborg 2021-07-27 18:49:55 +02:00
parent 04b9a8b3b5
commit 48e696bbb4
2 changed files with 10 additions and 1 deletions

View file

@ -3115,6 +3115,9 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
// up to the end of the token we're completing.
const wcstring buffcpy = wcstring(cmdsub_begin, token_end);
// Ensure that `commandline` inside the completions gets the current state.
update_commandline_state();
// std::fwprintf(stderr, L"Complete (%ls)\n", buffcpy.c_str());
completion_request_flags_t complete_flags = {completion_request_t::descriptions,
completion_request_t::fuzzy_match};

View file

@ -2,7 +2,7 @@
from pexpect_helper import SpawnedProc
sp = SpawnedProc()
send, sendline, sleep, expect_prompt = sp.send, sp.sendline, sp.sleep, sp.expect_prompt
send, sendline, sleep, expect_prompt, expect_str = sp.send, sp.sendline, sp.sleep, sp.expect_prompt, sp.expect_str
expect_prompt()
sendline("bind '~' 'handle_tilde'")
@ -41,3 +41,9 @@ expect_prompt("<>")
# TODO: consider removing.
sendline("commandline -I foo")
expect_prompt("foo")
# See that the commandline is updated immediately inside completions.
sendline("complete -c foo -xa '(commandline)'")
expect_prompt()
send("foo bar \t")
expect_str("foo bar foo\ bar\ ")