mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-18 08:51:46 +03:00
Tweak option completion behaviour
This commit is contained in:
parent
0c3acb74c2
commit
6663d50d95
@ -193,22 +193,17 @@ InsertCompletion complete_option(const Buffer& buffer, ByteCoord cursor_pos,
|
|||||||
}) != changes.end())
|
}) != changes.end())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
ByteCount longest_completion = 0;
|
if (cursor_pos.line == coord.line and cursor_pos.column >= coord.column)
|
||||||
for (auto it = opt.begin() + 1; it != opt.end(); ++it)
|
|
||||||
longest_completion = std::max(longest_completion, it->length());
|
|
||||||
|
|
||||||
if (cursor_pos.line == coord.line and cursor_pos.column >= coord.column and
|
|
||||||
buffer.distance(coord, cursor_pos) < longest_completion)
|
|
||||||
{
|
{
|
||||||
|
StringView prefix = buffer[coord.line].substr(
|
||||||
|
coord.column, cursor_pos.column - coord.column);
|
||||||
|
|
||||||
ComplAndDescList res;
|
ComplAndDescList res;
|
||||||
for (auto it = opt.begin() + 1; it != opt.end(); ++it)
|
for (auto it = opt.begin() + 1; it != opt.end(); ++it)
|
||||||
{
|
{
|
||||||
size_t pos = it->find_first_of("@");
|
auto splitted = split(*it, '@');
|
||||||
if (pos != String::npos)
|
if (not splitted.empty() and prefix_match(splitted[0], prefix))
|
||||||
res.emplace_back(it->substr(0_byte, (int)pos),
|
res.emplace_back(splitted[0], splitted.size() > 1 ? splitted[1] : "");
|
||||||
it->substr(ByteCount{(int)pos+1}));
|
|
||||||
else
|
|
||||||
res.emplace_back(*it, "");
|
|
||||||
}
|
}
|
||||||
return { coord, end, std::move(res), timestamp };
|
return { coord, end, std::move(res), timestamp };
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user