aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-09-09 11:03:11 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-09-09 11:03:11 -0400
commit674d5703cc7ba004b4270119a168771543498138 (patch)
treeb85a0b91df9a0782acb881b6622aba0966e2eb48 /src/server
parent87f61c6e6f7d1bad0723a38f1196d8ff89b7a21f (diff)
Add optional limit for fuzzy searching and set 100 for workspace symbols
Diffstat (limited to 'src/server')
-rw-r--r--src/server/indexer.odin3
-rw-r--r--src/server/memory_index.odin5
-rw-r--r--src/server/workspace_symbols.odin2
3 files changed, 7 insertions, 3 deletions
diff --git a/src/server/indexer.odin b/src/server/indexer.odin
index e97c4f5..3ffc3c3 100644
--- a/src/server/indexer.odin
+++ b/src/server/indexer.odin
@@ -68,11 +68,12 @@ fuzzy_search :: proc(
pkgs: []string,
current_file: string,
resolve_fields := false,
+ limit := 0,
) -> (
[]FuzzyResult,
bool,
) {
- results, ok := memory_index_fuzzy_search(&indexer.index, name, pkgs, current_file, resolve_fields)
+ results, ok := memory_index_fuzzy_search(&indexer.index, name, pkgs, current_file, resolve_fields, limit = limit)
if !ok {
return {}, false
}
diff --git a/src/server/memory_index.odin b/src/server/memory_index.odin
index fb00dc1..80c137f 100644
--- a/src/server/memory_index.odin
+++ b/src/server/memory_index.odin
@@ -59,6 +59,7 @@ memory_index_fuzzy_search :: proc(
pkgs: []string,
current_file: string,
resolve_fields := false,
+ limit := 0,
) -> (
[]FuzzyResult,
bool,
@@ -147,7 +148,9 @@ memory_index_fuzzy_search :: proc(
return j.score < i.score
})
- if name == "" {
+ if limit > 0 {
+ return symbols[:min(limit, len(symbols))], true
+ } else if name == "" {
return symbols[:], true
} else {
return symbols[:min(top, len(symbols))], true
diff --git a/src/server/workspace_symbols.odin b/src/server/workspace_symbols.odin
index 56f86a6..c4ce9c6 100644
--- a/src/server/workspace_symbols.odin
+++ b/src/server/workspace_symbols.odin
@@ -82,7 +82,7 @@ get_workspace_symbols :: proc(query: string) -> (workspace_symbols: []WorkspaceS
}
symbols := make([dynamic]WorkspaceSymbol, 0, 100, context.temp_allocator)
- if results, ok := fuzzy_search(query, cache.pkgs[:], "", resolve_fields = false); ok {
+ if results, ok := fuzzy_search(query, cache.pkgs[:], "", resolve_fields = false, limit = 100); ok {
for result in results {
symbol := WorkspaceSymbol {
name = result.symbol.name,