mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-19 09:21:30 +03:00
InsertCompleter: refactor line completer implementation
This commit is contained in:
parent
4e6b24eea2
commit
2193947b71
@ -361,17 +361,17 @@ InsertCompletion complete_line(const SelectionList& sels, const OptionManager& o
|
|||||||
auto add_candidates = [&](const Buffer& buf) {
|
auto add_candidates = [&](const Buffer& buf) {
|
||||||
for (LineCount l = 0_line; l < buf.line_count(); ++l)
|
for (LineCount l = 0_line; l < buf.line_count(); ++l)
|
||||||
{
|
{
|
||||||
// perf: it's unlikely the user intends to search among >10 candidates anyway
|
|
||||||
if (candidates.size() == 100)
|
|
||||||
break;
|
|
||||||
if (buf.name() == buffer.name() && l == cursor_pos.line)
|
if (buf.name() == buffer.name() && l == cursor_pos.line)
|
||||||
continue;
|
continue;
|
||||||
ByteCount len = buf[l].length();
|
const StringView line = buf[l];
|
||||||
if (len > cursor_pos.column and std::equal(prefix.begin(), prefix.end(), buf[l].begin()))
|
if (prefix == line.substr(0_byte, prefix.length()))
|
||||||
{
|
{
|
||||||
StringView candidate = buf[l].substr(0_byte, len-1);
|
StringView candidate = line.substr(0_byte, line.length()-1);
|
||||||
candidates.push_back({candidate.str(), "",
|
candidates.push_back({candidate.str(), "",
|
||||||
expand_tabs(candidate, tabstop, column)});
|
expand_tabs(candidate, tabstop, column)});
|
||||||
|
// perf: it's unlikely the user intends to search among >10 candidates anyway
|
||||||
|
if (candidates.size() == 100)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -382,9 +382,8 @@ InsertCompletion complete_line(const SelectionList& sels, const OptionManager& o
|
|||||||
{
|
{
|
||||||
for (const auto& buf : BufferManager::instance())
|
for (const auto& buf : BufferManager::instance())
|
||||||
{
|
{
|
||||||
if (buf.get() == &buffer or buf->flags() & Buffer::Flags::Debug)
|
if (buf.get() != &buffer and not (buf->flags() & Buffer::Flags::Debug))
|
||||||
continue;
|
add_candidates(*buf);
|
||||||
add_candidates(*buf);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user