From 3dac407a11767a2063beee0e5ccebffda1f90bd4 Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 9 Oct 2024 17:16:01 +0800 Subject: [PATCH] fix: should not get the previous visual selection (#698) --- lua/avante/utils/init.lua | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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]