diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-07-02 23:06:50 -0400 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-07-02 23:06:50 -0400 |
| commit | 05f2d8e253c3523e63ea08018f8bb9d23f6659b5 (patch) | |
| tree | 8aab42285a88ad8c2214ae07536a5ed8b86b4871 /util.lua | |
| parent | bee42bc87a249bddcd7d13a7a7c257f0c7f78072 (diff) | |
| download | vis-lspc-05f2d8e253c3523e63ea08018f8bb9d23f6659b5.tar.gz vis-lspc-05f2d8e253c3523e63ea08018f8bb9d23f6659b5.zip | |
add special case for the gopls empty file range
Diffstat (limited to 'util.lua')
| -rw-r--r-- | util.lua | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -243,12 +243,16 @@ function util.vis_sorted_selections_to_pos(file, sorted_selections) pos = pos + #line + 1 end - -- Some language servers (pylsp) sends a range including the first character after the last line. + -- Some language servers (pylsp) send ranges including the first character after the last line. -- e.g. [{"line":1, "col":1}, {"line":#lines+1, "col":1}] -- But this selection can not be handled by iterating all lines. - -- Add a special case for the selection of the first char after the last line. - if sel.line == line_count + 1 and sel.col == 1 then + -- Special case ranges ensing after the last line. + -- Additionaly the start and end can overlap. + -- Gopls sends the range [{"line":1, "col":1}, {"line":1, "col":1}] when editing an empty file. + while sel and sel.line == line_count + 1 and sel.col == 1 do table.insert(positions, pos) + sel_i = sel_i + 1 + sel = sorted_selections[sel_i] end return positions end |
