Added binding for accepting an autosuggestion

Fixes https://github.com/fish-shell/fish-shell/issues/226
This commit is contained in:
ridiculousfish
2012-07-15 14:02:34 -07:00
parent 4755c5f8c8
commit 548ea1e54a
3 changed files with 25 additions and 13 deletions

View File

@@ -1204,6 +1204,18 @@ static void update_autosuggestion(void) {
#endif
}
static void accept_autosuggestion(void) {
/* Accept any autosuggestion by replacing the command line with it. */
if (! data->autosuggestion.empty()) {
/* Accept the autosuggestion */
data->command_line = data->autosuggestion;
data->buff_pos = data->command_line.size();
data->command_line_changed();
reader_super_highlight_me_plenty(data->buff_pos);
reader_repaint();
}
}
/**
Flash the screen. This function only changed the color of the
current line, since the flash_screen sequnce is rather painful to
@@ -3015,15 +3027,7 @@ const wchar_t *reader_readline()
data->buff_pos++;
reader_repaint();
} else {
/* We're at the end of our buffer, and the user hit right. Try autosuggestion. */
if (! data->autosuggestion.empty()) {
/* Accept the autosuggestion */
data->command_line = data->autosuggestion;
data->buff_pos = data->command_line.size();
data->command_line_changed();
reader_super_highlight_me_plenty(data->buff_pos);
reader_repaint();
}
accept_autosuggestion();
}
break;
}
@@ -3113,7 +3117,7 @@ const wchar_t *reader_readline()
break;
}
case R_SUPPRESS_AUTOSUGGESTION:
{
data->suppress_autosuggestion = true;
@@ -3121,6 +3125,12 @@ const wchar_t *reader_readline()
reader_repaint();
break;
}
case R_ACCEPT_AUTOSUGGESTION:
{
accept_autosuggestion();
break;
}
/* Other, if a normal character, we add it to the command */
default: