aboutsummaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-02-05 06:59:25 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-02-14 16:23:13 +0100
commitf5c20434eaeb3e22cc50864d08878adef39fd233 (patch)
treea516b2d5f377d585ad9d66bd1f0bc6c781461c6c /init.lua
parent71e6e1787a8caaceace53f0fe658da7a8f6debec (diff)
downloadvis-lspc-f5c20434eaeb3e22cc50864d08878adef39fd233.tar.gz
vis-lspc-f5c20434eaeb3e22cc50864d08878adef39fd233.zip
calculate the positions for multiple selections at once
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua12
1 files changed, 8 insertions, 4 deletions
diff --git a/init.lua b/init.lua
index 99cb3cb..49e0253 100644
--- a/init.lua
+++ b/init.lua
@@ -177,13 +177,17 @@ local function vis_get_doc_pos(win)
}
end
--- convert a lsp_range to a vis_range
+--- Convert a lsp_range to a vis_range
+-- @param file the file in which the range lies
+-- @param lsp_range the LSP range that should be converted
+-- @return the according vis range
local function lsp_range_to_vis_range(file, lsp_range)
local start = lsp_pos_to_vis_sel(lsp_range.start)
- local start_pos = util.vis_sel_to_pos(file, start)
-
local finish = lsp_pos_to_vis_sel(lsp_range['end'])
- local finish_pos = util.vis_sel_to_pos(file, finish)
+
+ local positions = util.vis_sorted_selections_to_pos(file, {start, finish})
+ local start_pos = positions[1]
+ local finish_pos = positions[2]
return {start = start_pos, finish = finish_pos}
end