mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-04 07:21:14 -03:00
Do not reset terminal color when donating term for running key bindings
fish maintains two tty modes: one for itself and one for external
commands. The external command mode is also used when executing
fish-script key bindings, which was added in 5f16a299a7 (note that
commit had the wrong issue, the correct issue is #2114).
Prior to this fix, when switching to external modes, we would also reset
the tty's foreground color. This bumped tty's timestamp, causing us to
believe that the tty had been modified, and then repainting the prompt. If
the prompt were multi-line, we would repaint the whole prompt starting
from its second line, leaving a trailing line above it.
It would be reasonable to save the tty timestamp after resetting the
color, but given that using external modes for keybindings is new, it's
better to instead not reset the color in this case. So migrate the color
resetting to only when we run external commands.
Fixes #7722
This commit is contained in:
@@ -833,9 +833,7 @@ static void redirect_tty_after_sighup() {
|
||||
}
|
||||
|
||||
/// Give up control of terminal.
|
||||
static void term_donate(outputter_t &outp) {
|
||||
outp.set_color(rgb_color_t::normal(), rgb_color_t::normal());
|
||||
|
||||
static void term_donate() {
|
||||
while (true) {
|
||||
if (tcsetattr(STDIN_FILENO, TCSANOW, &tty_modes_for_external_cmds) == -1) {
|
||||
if (errno == EIO) redirect_tty_output();
|
||||
@@ -2376,7 +2374,8 @@ static eval_res_t reader_run_command(parser_t &parser, const wcstring &cmd) {
|
||||
|
||||
outputter_t &outp = outputter_t::stdoutput();
|
||||
reader_write_title(cmd, parser);
|
||||
term_donate(outp);
|
||||
outp.set_color(rgb_color_t::normal(), rgb_color_t::normal());
|
||||
term_donate();
|
||||
|
||||
gettimeofday(&time_before, nullptr);
|
||||
|
||||
@@ -2798,8 +2797,8 @@ struct readline_loop_state_t {
|
||||
|
||||
/// Run a sequence of commands from an input binding.
|
||||
void reader_data_t::run_input_command_scripts(const wcstring_list_t &cmds) {
|
||||
// Need to donate/steal the tty - see #2214.
|
||||
term_donate(outputter_t::stdoutput());
|
||||
// Need to donate/steal the tty - see #2114.
|
||||
term_donate();
|
||||
auto last_statuses = parser().get_last_statuses();
|
||||
for (const wcstring &cmd : cmds) {
|
||||
parser().eval(cmd, io_chain_t{});
|
||||
|
||||
Reference in New Issue
Block a user