diff options
| author | Maxime Coste <mawww@kakoune.org> | 2019-10-17 08:15:33 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2019-10-17 08:15:33 +1100 |
| commit | 6a893b4e563acd47d6f4a4e59e1c11e3ebca867a (patch) | |
| tree | f477c0e847e5c58966140bee80b59effe7553e2e /src/insert_completer.cc | |
| parent | c7f106a09b9b54a6022fd9208ebd1a5899d76c8f (diff) | |
Limit word completion menu filename length
Diffstat (limited to 'src/insert_completer.cc')
| -rw-r--r-- | src/insert_completer.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/insert_completer.cc b/src/insert_completer.cc index e1cc5319..abca58ab 100644 --- a/src/insert_completer.cc +++ b/src/insert_completer.cc @@ -154,6 +154,7 @@ InsertCompletion complete_word(const SelectionList& sels, [](const CharCount& lhs, const RankedMatchAndBuffer& rhs) { return std::max(lhs, rhs.candidate().char_length()); }); + auto limit = [](StringView s, ColumnCount l) { return s.column_length() <= l ? s.str() : "…" + s.substr(s.column_length() - (l + 1)); }; constexpr size_t max_count = 100; // Gather best max_count matches InsertCompletion::CandidateList candidates; @@ -169,7 +170,7 @@ InsertCompletion complete_word(const SelectionList& sels, const auto pad_len = longest + 1 - m.candidate().char_length(); menu_entry.push_back({ m.candidate().str(), {} }); menu_entry.push_back({ String{' ', pad_len}, {} }); - menu_entry.push_back({ m.buffer->display_name(), faces["MenuInfo"] }); + menu_entry.push_back({ limit(m.buffer->display_name(), 20), faces["MenuInfo"] }); } else menu_entry.push_back({ m.candidate().str(), {} }); |
