mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
Suppress autosuggesting during backspacing like browsers do
This commit is contained in:
parent
0dba7b3313
commit
e5b34d5cd5
13
reader.cpp
13
reader.cpp
@ -193,9 +193,10 @@ class reader_data_t
|
|||||||
/** String containing the autosuggestion */
|
/** String containing the autosuggestion */
|
||||||
wcstring autosuggestion;
|
wcstring autosuggestion;
|
||||||
|
|
||||||
/**
|
/** When backspacing, we suppress autosuggestions */
|
||||||
The representation of the current screen contents
|
bool suppress_autosuggestion;
|
||||||
*/
|
|
||||||
|
/** The representation of the current screen contents */
|
||||||
screen_t screen;
|
screen_t screen;
|
||||||
|
|
||||||
/** The history */
|
/** The history */
|
||||||
@ -448,7 +449,7 @@ static void reader_repaint()
|
|||||||
size_t len = std::max((size_t)1, full_line.size());
|
size_t len = std::max((size_t)1, full_line.size());
|
||||||
|
|
||||||
std::vector<color_t> colors = data->colors;
|
std::vector<color_t> colors = data->colors;
|
||||||
colors.resize(len, FISH_COLOR_NORMAL);
|
colors.resize(len, HIGHLIGHT_AUTOSUGGESTION);
|
||||||
|
|
||||||
std::vector<int> indents = data->indents;
|
std::vector<int> indents = data->indents;
|
||||||
indents.resize(len);
|
indents.resize(len);
|
||||||
@ -787,6 +788,7 @@ static void remove_backward()
|
|||||||
data->command_line.erase(data->buff_pos-1, 1);
|
data->command_line.erase(data->buff_pos-1, 1);
|
||||||
data->buff_pos--;
|
data->buff_pos--;
|
||||||
data->check_size();
|
data->check_size();
|
||||||
|
data->suppress_autosuggestion = true;
|
||||||
|
|
||||||
reader_super_highlight_me_plenty( data->buff_pos, 0 );
|
reader_super_highlight_me_plenty( data->buff_pos, 0 );
|
||||||
|
|
||||||
@ -805,6 +807,7 @@ static int insert_string(const wcstring &str)
|
|||||||
data->command_line.insert(data->buff_pos, str);
|
data->command_line.insert(data->buff_pos, str);
|
||||||
data->buff_pos += len;
|
data->buff_pos += len;
|
||||||
data->check_size();
|
data->check_size();
|
||||||
|
data->suppress_autosuggestion = false;
|
||||||
|
|
||||||
/* Syntax highlight */
|
/* Syntax highlight */
|
||||||
reader_super_highlight_me_plenty( data->buff_pos-1, 0 );
|
reader_super_highlight_me_plenty( data->buff_pos-1, 0 );
|
||||||
@ -1285,7 +1288,7 @@ static void run_pager( wchar_t *prefix, int is_quoted, const std::vector<complet
|
|||||||
static void update_autosuggestion(void) {
|
static void update_autosuggestion(void) {
|
||||||
/* Updates autosuggestion. We look for an autosuggestion if the command line is non-empty and if we're not doing a history search. */
|
/* Updates autosuggestion. We look for an autosuggestion if the command line is non-empty and if we're not doing a history search. */
|
||||||
data->autosuggestion.clear();
|
data->autosuggestion.clear();
|
||||||
if (! data->command_line.empty() && data->history_search.is_at_end()) {
|
if (! data->suppress_autosuggestion && ! data->command_line.empty() && data->history_search.is_at_end()) {
|
||||||
history_search_t searcher = history_search_t(*data->history, data->command_line, HISTORY_SEARCH_TYPE_PREFIX);
|
history_search_t searcher = history_search_t(*data->history, data->command_line, HISTORY_SEARCH_TYPE_PREFIX);
|
||||||
if (searcher.go_backwards()) {
|
if (searcher.go_backwards()) {
|
||||||
data->autosuggestion = searcher.current_item();
|
data->autosuggestion = searcher.current_item();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user