From 356c6bcae7c5a3acd15068e709cc19e7cd30ebf2 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Sun, 2 Mar 2025 21:45:57 -0800 Subject: [PATCH] Fix indeterminate analyze search results. --- src/fennel-ls/analyzer.fnl | 5 +++-- src/fennel-ls/handlers.fnl | 5 +++-- src/fennel-ls/lint.fnl | 3 +-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/fennel-ls/analyzer.fnl b/src/fennel-ls/analyzer.fnl index ff016a8..b84c755 100644 --- a/src/fennel-ls/analyzer.fnl +++ b/src/fennel-ls/analyzer.fnl @@ -73,7 +73,7 @@ find the definition `10`, but if `opts.stop-early?` is set, it would find (. document.fields (. stack (length stack)))) (search-document server (. document.fields (table.remove stack)) stack opts) (not document.fields) - (set opts.searched-through-require-indeterminate true))) + {:indeterminate true})) (λ search-val [server file ?ast stack opts] "searches for the definition of the ast, adjusted to 1 value" @@ -158,7 +158,8 @@ find the definition `10`, but if `opts.stop-early?` is set, it would find (sym? head :lambda) (sym? head :λ)))) - (search-multival server file (. definition (length definition)) stack multival opts))))))) + (search-multival server file (. definition (length definition)) stack multival opts) + result result)))))) (set search-multival (λ [server file ?ast stack multival opts] diff --git a/src/fennel-ls/handlers.fnl b/src/fennel-ls/handlers.fnl index 74e0f59..6cea6f3 100644 --- a/src/fennel-ls/handlers.fnl +++ b/src/fennel-ls/handlers.fnl @@ -140,8 +140,9 @@ Every time the client sends a message, it gets handled by a function in the corr byte (utils.position->byte file.text position server.position-encoding)] (case-try (analyzer.find-symbol file.ast byte) symbol (analyzer.search-main server file symbol {} {: byte}) - result {:contents (formatter.hover-format result) - :range (message.ast->range server file symbol)} + {:indeterminate nil &as result} {:contents (formatter.hover-format result) + :range (message.ast->range server file + symbol)} (catch _ nil)))) (λ make-completion-item [server file name scope] diff --git a/src/fennel-ls/lint.fnl b/src/fennel-ls/lint.fnl index 3f71ab8..a4269f3 100644 --- a/src/fennel-ls/lint.fnl +++ b/src/fennel-ls/lint.fnl @@ -57,8 +57,7 @@ the `file.diagnostics` field, filling it with diagnostics." (let [opts {} item (analyzer.search-ast server file ?ast stack opts)] (if (and (not item) - opts.searched-through-require-with-stack-size-1 - (not opts.searched-through-require-indeterminate)) + opts.searched-through-require-with-stack-size-1) (diagnostic {:range (message.ast->range server file symbol) :message (.. "unknown field: " (tostring symbol))