mirror of
https://github.com/neovim/neovim.git
synced 2026-04-25 08:44:06 +00:00
fix(api): nvim_set_current_win doesn't reset Visual mode (#37340)
Problem: Using nvim_set_current_win() to switch windows while in Visual mode causes E315 ml_get error when target buffer has fewer lines. This doesn't happen with `:wincmd w` since it properly resets Visual mode when switching buffers. Solution: Reset Visual mode when switching to another buffer, like `:wincmd w`.
This commit is contained in:
@@ -65,6 +65,7 @@
|
||||
#include "nvim/msgpack_rpc/channel.h"
|
||||
#include "nvim/msgpack_rpc/channel_defs.h"
|
||||
#include "nvim/msgpack_rpc/unpacker.h"
|
||||
#include "nvim/normal.h"
|
||||
#include "nvim/option.h"
|
||||
#include "nvim/option_defs.h"
|
||||
#include "nvim/option_vars.h"
|
||||
@@ -975,6 +976,9 @@ void nvim_set_current_win(Window window, Error *err)
|
||||
}
|
||||
|
||||
TRY_WRAP(err, {
|
||||
if (win->w_buffer != curbuf) {
|
||||
reset_VIsual_and_resel();
|
||||
}
|
||||
goto_tabpage_win(win_find_tabpage(win), win);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user