Merge remote-tracking branch 'krobelus/prompt-completion-cut-at-cursor'
This commit is contained in:
commit
99874a1e25
|
@ -717,8 +717,9 @@ Completions CommandManager::complete(const Context& context,
|
||||||
StringView command_line,
|
StringView command_line,
|
||||||
ByteCount cursor_pos)
|
ByteCount cursor_pos)
|
||||||
{
|
{
|
||||||
CommandParser parser{command_line};
|
auto prefix = command_line.substr(0_byte, cursor_pos);
|
||||||
const char* cursor = command_line.begin() + (int)cursor_pos;
|
CommandParser parser{prefix};
|
||||||
|
const char* cursor = prefix.begin() + (int)cursor_pos;
|
||||||
Vector<Token> tokens;
|
Vector<Token> tokens;
|
||||||
|
|
||||||
bool is_last_token = true;
|
bool is_last_token = true;
|
||||||
|
@ -739,7 +740,7 @@ Completions CommandManager::complete(const Context& context,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_last_token)
|
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());
|
kak_assert(not tokens.empty());
|
||||||
const auto& token = tokens.back();
|
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
|
if (tokens.size() == 1 and (token.type == Token::Type::Raw or
|
||||||
token.type == Token::Type::RawQuoted))
|
token.type == Token::Type::RawQuoted))
|
||||||
{
|
{
|
||||||
StringView query = command_line.substr(start, pos_in_token);
|
return offset_pos(requote(complete_command_name(context, prefix), token.type), start);
|
||||||
return offset_pos(requote(complete_command_name(context, query), token.type), start);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (token.type)
|
switch (token.type)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user