Rank same-document completion candidates first
Candidates carry a local flag set from the index record path, and the deterministic sort key orders local candidates before remote ones within the same kind. Registered feature tests cover the ranking.
This commit is contained in:
1 parent
0b33a0cd99
commit
236c3c5718
5 files changed
+29
-16
No files matched your search
@@ -61,6 +61,15 @@ start coordinate only, so ranges are zero-width until an end is available.
|
||||
LSP adapters and index/rename/debugging integration remain open. `vbs test`
|
||||
passed all 17 native suites; CMake passed the reflection and trace suites.
|
||||
|
||||
## December 6 locality ranking in completion
|
||||
|
||||
Completion candidates now carry whether they are declared in the requesting
|
||||
document, and the sort key ranks local candidates first within each kind
|
||||
(`<kind priority><0 local|1 remote><label>`). `EditorDiagnostics` marks a
|
||||
candidate local when its index record path equals the open document's canonical
|
||||
path. Registered `vls_feature_tests` grew to 111 cases. All 18 native suites and
|
||||
all 18 CMake tests passed.
|
||||
|
||||
## December 6 generic outline ingested into the symbol index
|
||||
|
||||
Each open document's text outline is published as its own index context
|
||||
|
||||
@@ -35,6 +35,8 @@ struct Candidate {
|
||||
std::string detail;
|
||||
std::string provenance;
|
||||
Identity identity;
|
||||
// The candidate is declared in the requesting document.
|
||||
bool local{};
|
||||
auto operator<=>(const Candidate &) const = default;
|
||||
};
|
||||
|
||||
|
||||
@@ -68,15 +68,15 @@ Result complete(std::span<const Candidate> candidates, std::string_view text, st
|
||||
continue;
|
||||
if (!seen.emplace(candidate.label, candidate.kind).second)
|
||||
continue;
|
||||
items.push_back(
|
||||
Item{.label = candidate.label,
|
||||
.kind = candidate.kind,
|
||||
.detail = bounded(candidate.detail, limits.detailBytes),
|
||||
.provenance = bounded(candidate.provenance, limits.provenanceBytes),
|
||||
.sort_text = std::to_string(priority(candidate.kind)) + candidate.label,
|
||||
.identity = candidate.identity,
|
||||
.replacement_start = start,
|
||||
.replacement_end = offset});
|
||||
items.push_back(Item{.label = candidate.label,
|
||||
.kind = candidate.kind,
|
||||
.detail = bounded(candidate.detail, limits.detailBytes),
|
||||
.provenance = bounded(candidate.provenance, limits.provenanceBytes),
|
||||
.sort_text = std::to_string(priority(candidate.kind)) +
|
||||
(candidate.local ? "0" : "1") + candidate.label,
|
||||
.identity = candidate.identity,
|
||||
.replacement_start = start,
|
||||
.replacement_end = offset});
|
||||
}
|
||||
std::ranges::sort(items, [](const Item &left, const Item &right) {
|
||||
return std::tie(left.sort_text, left.label) < std::tie(right.sort_text, right.label);
|
||||
|
||||
@@ -996,12 +996,14 @@ Json EditorDiagnostics::completion(std::string_view uri, Documents::Position pos
|
||||
? features::completion::Kind::namespace_
|
||||
: record.kind == index::SymbolKind::module ? features::completion::Kind::module
|
||||
: features::completion::Kind::unknown;
|
||||
candidates.push_back({record.name,
|
||||
kind,
|
||||
record.location.path,
|
||||
record.provenance,
|
||||
{record.name, record.location.path, record.location.line,
|
||||
record.location.character}});
|
||||
candidates.push_back(
|
||||
{record.name,
|
||||
kind,
|
||||
record.location.path,
|
||||
record.provenance,
|
||||
{record.name, record.location.path, record.location.line,
|
||||
record.location.character},
|
||||
record.location.path == snapshot->identity.canonical_path.native()});
|
||||
}
|
||||
}
|
||||
const std::uint64_t generation = s.symbols.generation();
|
||||
|
||||
@@ -66,7 +66,7 @@ VOID_TEST(Completion, ranks_types_before_functions_before_variables) {
|
||||
expect(result.items[0].kind == Kind::type);
|
||||
expect(result.items[1].kind == Kind::function);
|
||||
expect(result.items[2].kind == Kind::variable);
|
||||
expect(result.items[0].sort_text == "0zz");
|
||||
expect(result.items[0].sort_text == "01zz");
|
||||
}
|
||||
|
||||
VOID_TEST(Completion, empty_prefix_lists_everything_bounded) {
|
||||
|
||||
Reference in new issue
Block a user