diff options
| author | Maxime Coste <mawww@kakoune.org> | 2022-07-28 21:29:21 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2022-07-28 21:29:21 +1000 |
| commit | 99874a1e2562148d6308bf95643f16dcc00453ab (patch) | |
| tree | ec878391df37548326642894da1a6165aed70bb0 /src | |
| parent | ab20fa93603fa198e822c44711eb867c69f288c1 (diff) | |
| parent | 19fccc15871cbfcbb79e872b3c4d1540a16f7013 (diff) | |
Merge remote-tracking branch 'krobelus/prompt-completion-cut-at-cursor'
Diffstat (limited to 'src')
| -rw-r--r-- | src/command_manager.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/command_manager.cc b/src/command_manager.cc index 8d2fa57b..4fea1e79 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -717,8 +717,9 @@ Completions CommandManager::complete(const Context& context, StringView command_line, ByteCount cursor_pos) { - CommandParser parser{command_line}; - const char* cursor = command_line.begin() + (int)cursor_pos; + auto prefix = command_line.substr(0_byte, cursor_pos); + CommandParser parser{prefix}; + const char* cursor = prefix.begin() + (int)cursor_pos; Vector<Token> tokens; bool is_last_token = true; @@ -739,7 +740,7 @@ Completions CommandManager::complete(const Context& context, } if (is_last_token) - tokens.push_back({Token::Type::Raw, command_line.length(), {}}); + tokens.push_back({Token::Type::Raw, prefix.length(), {}}); kak_assert(not tokens.empty()); const auto& token = tokens.back(); @@ -776,8 +777,7 @@ Completions CommandManager::complete(const Context& context, if (tokens.size() == 1 and (token.type == Token::Type::Raw or token.type == Token::Type::RawQuoted)) { - StringView query = command_line.substr(start, pos_in_token); - return offset_pos(requote(complete_command_name(context, query), token.type), start); + return offset_pos(requote(complete_command_name(context, prefix), token.type), start); } switch (token.type) |
