objectionary/eo-lsp-server

Parser-error diagnostic emits zero-length `Range`; clients drop the squiggle

開放

#323 建立於 2026年5月11日

 (2 則留言) (0 個反應) (0 位負責人)TypeScript (9 個分叉)github user discovery
bughelp wanted

倉庫指標

星標
 (6 顆星)
PR 合併指標
 (平均合併 4天 17小時) (30 天內合併 5 個 PR)

描述

What happens

In src/server.ts, parser-error diagnostics are emitted with start and end at the same position:

range: {
    start: { line: error.line - 1, character: error.column },
    end:   { line: error.line - 1, character: error.column }
},

The resulting range has zero length. LSP 3.17 does not forbid empty ranges, so this is not a spec violation, but it is consistently bad UX:

  • VSCode renders a zero-length range as a single-character caret under the next character, hiding which token actually triggered the error.
  • Several other clients (older vim-lsp, some eglot versions) drop zero-length diagnostics entirely from the highlighted-errors list, so the user sees no squiggle at all and has to consult the "Problems" panel to discover there is an error.

A parser error generally points at a specific token; the token's start column is already in hand, and its length is recoverable from the parser state.

What should happen

Either extend the range by one character so every client paints at least a single squiggle:

end: { line: error.line - 1, character: error.column + 1 }

…or, better, set the end to the end of the offending token (if the parser exposes the token length). Result: every LSP client surfaces parser errors as a visible squiggle, instead of silently dropping or rendering them as an invisible caret.

貢獻者指南