Parse errors are on the correct line number now

This commit is contained in:
XeroOl 2022-09-18 13:05:35 -05:00
parent 5c4d0530f8
commit cd4358a4b7
No known key found for this signature in database
GPG Key ID: 9DD4B4B4DAED0322
3 changed files with 7 additions and 3 deletions

View File

@ -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

View File

@ -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)

View File

@ -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")))