nvarner / typst-lsp

A brand-new language server for Typst, plus a VS Code extension
MIT License
1.19k stars 77 forks source link

Hover popup not showing up when hovering the keyword's first character. #436

Open Momijiichigo opened 7 months ago

Momijiichigo commented 7 months ago

Issue

The LSP does not seem to react to the cursor hovering when hovering the first character of the keyword. I have noticed this on my NeoVim and checked this also happens in VS Code.

Temporal Fix

Add +1 to the line in src/server/hover.rs: https://github.com/nvarner/typst-lsp/blob/0d5b9330a1d515fa47456e755f751ea4056282b8/src/server/hover.rs#L27C17-L28C92

let typst_offset =
    lsp_to_typst::position_to_offset(position, position_encoding, &source) + 1;

Possible cause

possibly, wrong byte index (shifted by one) is returned from typst_syntax::source::Source::utf16_to_byte and/or typst_syntax::source::Source::line_column_to_byte

Enter-tainer commented 7 months ago

145 might be related