mirror of
https://github.com/MaskRay/ccls.git
synced 2025-02-21 07:59:27 +00:00
Uniqueify include string proposals
This commit is contained in:
parent
511f6c5248
commit
584f7b45b9
@ -2905,7 +2905,7 @@ bool QueryDbMainLoop(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build include strings.
|
// Build include strings.
|
||||||
std::vector<std::string> include_insert_strings;
|
std::unordered_set<std::string> include_insert_strings;
|
||||||
include_insert_strings.reserve(include_absolute_paths.size());
|
include_insert_strings.reserve(include_absolute_paths.size());
|
||||||
|
|
||||||
for (const std::string& path : include_absolute_paths) {
|
for (const std::string& path : include_absolute_paths) {
|
||||||
@ -2913,9 +2913,9 @@ bool QueryDbMainLoop(
|
|||||||
if (!item)
|
if (!item)
|
||||||
continue;
|
continue;
|
||||||
if (item->textEdit)
|
if (item->textEdit)
|
||||||
include_insert_strings.push_back(item->textEdit->newText);
|
include_insert_strings.insert(item->textEdit->newText);
|
||||||
else if (!item->insertText.empty())
|
else if (!item->insertText.empty())
|
||||||
include_insert_strings.push_back(item->insertText);
|
include_insert_strings.insert(item->insertText);
|
||||||
else
|
else
|
||||||
assert(false && "unable to determine insert string for include completion item");
|
assert(false && "unable to determine insert string for include completion item");
|
||||||
}
|
}
|
||||||
@ -2939,7 +2939,7 @@ bool QueryDbMainLoop(
|
|||||||
|
|
||||||
// Setup metadata and send to client.
|
// Setup metadata and send to client.
|
||||||
if (include_insert_strings.size() == 1)
|
if (include_insert_strings.size() == 1)
|
||||||
command.title = "Insert " + include_insert_strings[0];
|
command.title = "Insert " + *include_insert_strings.begin();
|
||||||
else
|
else
|
||||||
command.title = "Pick one of " + std::to_string(include_insert_strings.size()) + " includes to insert";
|
command.title = "Pick one of " + std::to_string(include_insert_strings.size()) + " includes to insert";
|
||||||
command.command = "cquery._insertInclude";
|
command.command = "cquery._insertInclude";
|
||||||
|
Loading…
Reference in New Issue
Block a user