aboutsummaryrefslogtreecommitdiff
path: root/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'util.lua')
-rw-r--r--util.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/util.lua b/util.lua
index 2b090b2..e36c23f 100644
--- a/util.lua
+++ b/util.lua
@@ -242,6 +242,14 @@ 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.
+ -- 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
+ table.insert(positions, pos)
+ end
return positions
end