From d9639943621d63bd98fad0b0632918018fd0070e Mon Sep 17 00:00:00 2001 From: Joosep Alviste Date: Sun, 7 Aug 2022 09:46:27 +0300 Subject: [PATCH] Add visual end location utility function Closes #44 --- lua/ts_context_commentstring/utils.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lua/ts_context_commentstring/utils.lua b/lua/ts_context_commentstring/utils.lua index b3b5f74..ab2229e 100644 --- a/lua/ts_context_commentstring/utils.lua +++ b/lua/ts_context_commentstring/utils.lua @@ -75,7 +75,7 @@ function M.get_cursor_line_non_whitespace_col_location() } end ----Get the location of the visual section start. +---Get the location of the visual selection start. --- ---@return ts_context_commentstring.Location function M.get_visual_start_location() @@ -87,6 +87,16 @@ function M.get_visual_start_location() } end +---Get the location of the visual selection end. +--- +---@return ts_context_commentstring.Location +function M.get_visual_end_location() + return { + vim.fn.getpos("'>")[2] - 1, + vim.fn.getpos("'>")[3] - 1, + } +end + ---Get the node that is on the given location (default first non-whitespace ---character of the cursor line). This also handles injected languages via ---language tree.