mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Include the autosuggestion in history if it was truncated
https://github.com/fish-shell/fish-shell/issues/650
This commit is contained in:
parent
69c6b007aa
commit
d6791a836b
3 changed files with 11 additions and 4 deletions
|
@ -3517,9 +3517,9 @@ const wchar_t *reader_readline(void)
|
||||||
data->search_buff.append(data->command_line);
|
data->search_buff.append(data->command_line);
|
||||||
data->history_search = history_search_t(*data->history, data->search_buff, HISTORY_SEARCH_TYPE_CONTAINS);
|
data->history_search = history_search_t(*data->history, data->search_buff, HISTORY_SEARCH_TYPE_CONTAINS);
|
||||||
|
|
||||||
/* Skip the autosuggestion as history */
|
/* Skip the autosuggestion as history unless it was truncated */
|
||||||
const wcstring &suggest = data->autosuggestion;
|
const wcstring &suggest = data->autosuggestion;
|
||||||
if (! suggest.empty())
|
if (! suggest.empty() && ! data->screen.autosuggestion_is_truncated)
|
||||||
{
|
{
|
||||||
data->history_search.skip_matches(wcstring_list_t(&suggest, 1 + &suggest));
|
data->history_search.skip_matches(wcstring_list_t(&suggest, 1 + &suggest));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1245,6 +1245,9 @@ void s_write(screen_t *s,
|
||||||
/* Compute a layout */
|
/* Compute a layout */
|
||||||
const screen_layout_t layout = compute_layout(s, screen_width, left_prompt, right_prompt, explicit_command_line, autosuggestion, indent);
|
const screen_layout_t layout = compute_layout(s, screen_width, left_prompt, right_prompt, explicit_command_line, autosuggestion, indent);
|
||||||
|
|
||||||
|
/* Determine whether, if we have an autosuggestion, it was truncated */
|
||||||
|
s->autosuggestion_is_truncated = ! autosuggestion.empty() && autosuggestion != layout.autosuggestion;
|
||||||
|
|
||||||
/* Clear the desired screen */
|
/* Clear the desired screen */
|
||||||
s->desired.resize(0);
|
s->desired.resize(0);
|
||||||
s->desired.cursor.x = s->desired.cursor.y = 0;
|
s->desired.cursor.x = s->desired.cursor.y = 0;
|
||||||
|
@ -1402,6 +1405,7 @@ screen_t::screen_t() :
|
||||||
last_right_prompt_width(),
|
last_right_prompt_width(),
|
||||||
actual_width(SCREEN_WIDTH_UNINITIALIZED),
|
actual_width(SCREEN_WIDTH_UNINITIALIZED),
|
||||||
soft_wrap_location(INVALID_LOCATION),
|
soft_wrap_location(INVALID_LOCATION),
|
||||||
|
autosuggestion_is_truncated(false),
|
||||||
need_clear_lines(false),
|
need_clear_lines(false),
|
||||||
need_clear_screen(false),
|
need_clear_screen(false),
|
||||||
actual_lines_before_reset(0),
|
actual_lines_before_reset(0),
|
||||||
|
|
3
screen.h
3
screen.h
|
@ -141,6 +141,9 @@ public:
|
||||||
/** If we support soft wrapping, we can output to this location without any cursor motion. */
|
/** If we support soft wrapping, we can output to this location without any cursor motion. */
|
||||||
screen_data_t::cursor_t soft_wrap_location;
|
screen_data_t::cursor_t soft_wrap_location;
|
||||||
|
|
||||||
|
/** Whether the last-drawn autosuggestion (if any) is truncated, or hidden entirely */
|
||||||
|
bool autosuggestion_is_truncated;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This flag is set to true when there is reason to suspect that
|
This flag is set to true when there is reason to suspect that
|
||||||
the parts of the screen lines where the actual content is not
|
the parts of the screen lines where the actual content is not
|
||||||
|
|
Loading…
Reference in a new issue