diff --git a/lua/avante/utils/init.lua b/lua/avante/utils/init.lua index b25dc83..d7a7f73 100644 --- a/lua/avante/utils/init.lua +++ b/lua/avante/utils/init.lua @@ -168,6 +168,8 @@ end ---Get the selected content and range in Visual mode ---@return avante.SelectionResult | nil Selected content and range function M.get_visual_selection_and_range() + if not M.in_visual_mode() then return nil end + local Range = require("avante.range") local SelectionResult = require("avante.selection_result") @@ -175,11 +177,6 @@ function M.get_visual_selection_and_range() local start_pos = fn.getpos("v") local end_pos = fn.getpos(".") - if not M.in_visual_mode() then - start_pos = fn.getpos("'<") - end_pos = fn.getpos("'>") - end - -- Get the start and end line and column numbers local start_line = start_pos[2] local start_col = start_pos[3]