mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
Correctly clear pager contents on ctrl-C
This commit is contained in:
parent
998ce1fe89
commit
605c306bef
1 changed files with 20 additions and 8 deletions
24
reader.cpp
24
reader.cpp
|
@ -362,6 +362,9 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
/* Sets the command line contents, without clearing the pager */
|
||||
static void reader_set_buffer_maintaining_pager(const wcstring &b, size_t pos);
|
||||
|
||||
/**
|
||||
The current interactive reading context
|
||||
*/
|
||||
|
@ -1211,7 +1214,7 @@ static void completion_insert(const wchar_t *val, complete_flags_t flags)
|
|||
{
|
||||
size_t cursor = data->buff_pos;
|
||||
wcstring new_command_line = completion_apply_to_command_line(val, flags, data->command_line, &cursor, false /* not append only */);
|
||||
reader_set_buffer(new_command_line, cursor);
|
||||
reader_set_buffer_maintaining_pager(new_command_line, cursor);
|
||||
|
||||
/* Since we just inserted a completion, don't immediately do a new autosuggestion */
|
||||
data->suppress_autosuggestion = true;
|
||||
|
@ -1547,7 +1550,7 @@ static void select_completion_in_direction(enum selection_direction_t dir, const
|
|||
{
|
||||
size_t cursor_pos = cycle_cursor_pos;
|
||||
const wcstring new_cmd_line = completion_apply_to_command_line(next_comp->completion, next_comp->flags, cycle_command_line, &cursor_pos, false);
|
||||
reader_set_buffer(new_cmd_line, cursor_pos);
|
||||
reader_set_buffer_maintaining_pager(new_cmd_line, cursor_pos);
|
||||
|
||||
/* Since we just inserted a completion, don't immediately do a new autosuggestion */
|
||||
data->suppress_autosuggestion = true;
|
||||
|
@ -2376,11 +2379,9 @@ history_t *reader_get_history(void)
|
|||
return data ? data->history : NULL;
|
||||
}
|
||||
|
||||
void reader_set_buffer(const wcstring &b, size_t pos)
|
||||
/* Sets the command line contents, without clearing the pager */
|
||||
static void reader_set_buffer_maintaining_pager(const wcstring &b, size_t pos)
|
||||
{
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
/* Callers like to pass us pointers into ourselves, so be careful! I don't know if we can use operator= with a pointer to our interior, so use an intermediate. */
|
||||
size_t command_line_len = b.size();
|
||||
data->command_line = b;
|
||||
|
@ -2392,6 +2393,7 @@ void reader_set_buffer(const wcstring &b, size_t pos)
|
|||
|
||||
data->buff_pos = pos;
|
||||
|
||||
/* Clear history search and pager contents */
|
||||
data->search_mode = NO_SEARCH;
|
||||
data->search_buff.clear();
|
||||
data->history_search.go_to_end();
|
||||
|
@ -2400,6 +2402,16 @@ void reader_set_buffer(const wcstring &b, size_t pos)
|
|||
reader_repaint_needed();
|
||||
}
|
||||
|
||||
/* Sets the command line contents, clearing the pager */
|
||||
void reader_set_buffer(const wcstring &b, size_t pos)
|
||||
{
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
clear_pager();
|
||||
reader_set_buffer_maintaining_pager(b, pos);
|
||||
}
|
||||
|
||||
|
||||
size_t reader_get_cursor_pos()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue