diff options
| author | Maxime Coste <mawww@kakoune.org> | 2018-02-28 15:40:42 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2018-02-28 15:40:42 +1100 |
| commit | 2193947b710ef015d11ad5587b1cc60831783d5b (patch) | |
| tree | 6a07d0589c2df692206e286574044a9af909ffa0 | |
| parent | 4e6b24eea22300f4e6581da6ce63880f5df7f5d5 (diff) | |
InsertCompleter: refactor line completer implementation
| -rw-r--r-- | src/insert_completer.cc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/insert_completer.cc b/src/insert_completer.cc index d4e81eda..5bd1efe7 100644 --- a/src/insert_completer.cc +++ b/src/insert_completer.cc @@ -361,17 +361,17 @@ InsertCompletion complete_line(const SelectionList& sels, const OptionManager& o auto add_candidates = [&](const Buffer& buf) { 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) continue; - ByteCount len = buf[l].length(); - if (len > cursor_pos.column and std::equal(prefix.begin(), prefix.end(), buf[l].begin())) + const StringView line = buf[l]; + 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(), "", 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()) { - if (buf.get() == &buffer or buf->flags() & Buffer::Flags::Debug) - continue; - add_candidates(*buf); + if (buf.get() != &buffer and not (buf->flags() & Buffer::Flags::Debug)) + add_candidates(*buf); } } |
