From cd4358a4b726adaa8515f0a33eafde446cd72937 Mon Sep 17 00:00:00 2001 From: XeroOl Date: Sun, 18 Sep 2022 13:05:35 -0500 Subject: [PATCH] Parse errors are on the correct line number now --- src/fennel-ls/compiler.fnl | 3 ++- src/fennel-ls/handlers.fnl | 3 +++ test/diagnostic-test.fnl | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/fennel-ls/compiler.fnl b/src/fennel-ls/compiler.fnl index 205a7a0..c33f2cf 100644 --- a/src/fennel-ls/compiler.fnl +++ b/src/fennel-ls/compiler.fnl @@ -155,7 +155,8 @@ later by fennel-ls.language to answer requests from the client." (λ on-parse-error [msg file line byte] ;; assume byte and char count is the same, ie no UTF-8 - (let [range (message.pos->range line byte line byte)] + (let [line (- line 1) + range (message.pos->range line byte line byte)] (table.insert diagnostics {:range range :message msg diff --git a/src/fennel-ls/handlers.fnl b/src/fennel-ls/handlers.fnl index 7bebc5f..6c579e2 100644 --- a/src/fennel-ls/handlers.fnl +++ b/src/fennel-ls/handlers.fnl @@ -92,6 +92,9 @@ Every time the client sends a message, it gets handled by a function in the corr :value (formatter.hover-format result)}} (catch _ nil)))) + +;; All of the helper functions for textDocument/completion are here until I +;; finish refactoring them, and then they can find a home in language.fnl (λ collect-scope [scope typ callback ?target] (let [result (or ?target [])] (var scope scope) diff --git a/test/diagnostic-test.fnl b/test/diagnostic-test.fnl index 901f138..1586a2b 100644 --- a/test/diagnostic-test.fnl +++ b/test/diagnostic-test.fnl @@ -46,8 +46,8 @@ (find [i v (ipairs diagnostics)] (match v {:message "expected whitespace before opening delimiter (" - :range {:start {:character 17 :line 1} - :end {:character 17 :line 1}}} + :range {:start {:character 17 :line 0} + :end {:character 17 :line 0}}} v)))] (is diagnostic "expected a diagnostic")))