Skip to content

Commit 621a1c8

Browse files
committed
fix(utils): optimize return to normal mode function
The function now only calls 'stopinsert' when not already in normal mode, avoiding unnecessary command execution when already in normal mode. Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
1 parent 648d936 commit 621a1c8

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lua/CopilotChat/utils.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ function M.return_to_normal_mode()
134134
local mode = vim.fn.mode():lower()
135135
if mode:find('v') then
136136
vim.cmd([[execute "normal! \<Esc>"]])
137+
elseif mode ~= 'n' then
138+
vim.cmd('stopinsert')
137139
end
138-
vim.cmd('stopinsert')
139140
end
140141

141142
--- Mark a function as deprecated

0 commit comments

Comments
 (0)