summaryrefslogtreecommitdiff
path: root/src/insert_completer.cc
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2022-02-11 16:30:47 +0100
committerJohannes Altmanninger <aclopte@gmail.com>2022-02-11 16:51:29 +0100
commite6d0ff1bc86a65f80ad3f8f05b46e66a8a02e65f (patch)
tree681b6d6fb53a6133bbec99adcb328791fc03eb67 /src/insert_completer.cc
parent0b29fcf32ac756dc54ec5c52db63340c9b3692e9 (diff)
Filter duplicate completions only if they have the same select cmd
Given a completer option with two applicable completions text|select-cmd1|menu-text1 text|select-cmd2|menu-text2 Kakoune will only show one of them, because they will insert the same text. Some language servers send completions like this, for example if two different importable modules provide the same name. This can be reproduced using intelephense in this PHP file (cursor is %()) <?php namespace namespace1; class sometype {} ?> <?php namespace namespace2; class sometype {} ?> <?php namespace test; some%() ?> Both completions insert "sometype". The import statement will be added in an InsertCompletionHide hook by kak-lsp (it uses select-cmd to determine which completion was selected). To support this use case, refine the duplicate detection to not filter out completions with different select-cmd values.
Diffstat (limited to 'src/insert_completer.cc')
-rw-r--r--src/insert_completer.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/insert_completer.cc b/src/insert_completer.cc
index f32b35ca..86076b45 100644
--- a/src/insert_completer.cc
+++ b/src/insert_completer.cc
@@ -322,7 +322,8 @@ InsertCompletion complete_option(const SelectionList& sels,
candidates.reserve(matches.size());
while (candidates.size() < max_count and first != last)
{
- if (candidates.empty() or candidates.back().completion != first->candidate())
+ if (candidates.empty() or candidates.back().completion != first->candidate()
+ or candidates.back().on_select != first->on_select)
candidates.push_back({ first->candidate().str(), first->on_select.str(),
std::move(first->menu_entry) });
std::pop_heap(first, last--, greater);