mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
Fix autosuggestions for time
This commit is contained in:
parent
664d6fb132
commit
3274dbacf4
2 changed files with 4 additions and 11 deletions
|
@ -39,6 +39,7 @@
|
||||||
#include "history.h"
|
#include "history.h"
|
||||||
#include "iothread.h"
|
#include "iothread.h"
|
||||||
#include "parse_constants.h"
|
#include "parse_constants.h"
|
||||||
|
#include "parser_keywords.h"
|
||||||
#include "parse_util.h"
|
#include "parse_util.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
@ -1473,17 +1474,8 @@ void completer_t::perform() {
|
||||||
|
|
||||||
// Hack: fix autosuggestion by removing prefixing "and"s #6249.
|
// Hack: fix autosuggestion by removing prefixing "and"s #6249.
|
||||||
if (flags & completion_request_t::autosuggestion) {
|
if (flags & completion_request_t::autosuggestion) {
|
||||||
constexpr const wchar_t *prefix_cmds[] = {L"and", L"begin", L"command", L"exec",
|
while (!tokens.empty() && parser_keywords_is_subcommand(tokens.front().get_source(cmd)))
|
||||||
L"if", L"not", L"or", L"while"};
|
|
||||||
while (!tokens.empty()) {
|
|
||||||
auto cmd_string = tokens.front().get_source(cmd);
|
|
||||||
bool is_subcommand = std::find_if(std::begin(prefix_cmds), std::end(prefix_cmds),
|
|
||||||
[&cmd_string](const wchar_t *prefix) {
|
|
||||||
return cmd_string == prefix;
|
|
||||||
}) != std::end(prefix_cmds);
|
|
||||||
if (!is_subcommand) break;
|
|
||||||
tokens.erase(tokens.begin());
|
tokens.erase(tokens.begin());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Empty process (cursor is after one of ;, &, |, \n, &&, || modulo whitespace).
|
// Empty process (cursor is after one of ;, &, |, \n, &&, || modulo whitespace).
|
||||||
if (tokens.empty()) {
|
if (tokens.empty()) {
|
||||||
|
|
|
@ -17,7 +17,8 @@ static const wcstring skip_keywords[]{
|
||||||
};
|
};
|
||||||
|
|
||||||
static const wcstring subcommand_keywords[]{L"command", L"builtin", L"while", L"exec",
|
static const wcstring subcommand_keywords[]{L"command", L"builtin", L"while", L"exec",
|
||||||
L"if", L"and", L"or", L"not"};
|
L"if", L"and", L"or", L"not",
|
||||||
|
L"time", L"begin"};
|
||||||
|
|
||||||
static const string_set_t block_keywords = {L"for", L"while", L"if",
|
static const string_set_t block_keywords = {L"for", L"while", L"if",
|
||||||
L"function", L"switch", L"begin"};
|
L"function", L"switch", L"begin"};
|
||||||
|
|
Loading…
Reference in a new issue