mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 06:28:35 +00:00
vim-patch:8.2.4028: ml_get error with :doautoall and Visual area
Problem: ml_get error with :doautoall and Visual area. (Sean Dewar)
Solution: Disable Visual mode while executing autocommands.
cb1956d6f2
This should also fix #16937 for nvim_buf_call, so test for it.
This commit is contained in:
@@ -1069,8 +1069,6 @@ void ex_doautoall(exarg_T *eap)
|
|||||||
do_modelines(0);
|
do_modelines(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
check_cursor(); // just in case lines got deleted
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check *argp for <nomodeline>. When it is present return false, otherwise
|
/// Check *argp for <nomodeline>. When it is present return false, otherwise
|
||||||
@@ -1171,6 +1169,10 @@ void aucmd_prepbuf(aco_save_T *aco, buf_T *buf)
|
|||||||
curbuf = buf;
|
curbuf = buf;
|
||||||
aco->new_curwin_handle = curwin->handle;
|
aco->new_curwin_handle = curwin->handle;
|
||||||
set_bufref(&aco->new_curbuf, curbuf);
|
set_bufref(&aco->new_curbuf, curbuf);
|
||||||
|
|
||||||
|
// disable the Visual area, the position may be invalid in another buffer
|
||||||
|
aco->save_VIsual_active = VIsual_active;
|
||||||
|
VIsual_active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cleanup after executing autocommands for a (hidden) buffer.
|
/// Cleanup after executing autocommands for a (hidden) buffer.
|
||||||
@@ -1267,6 +1269,12 @@ win_found:
|
|||||||
check_cursor();
|
check_cursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_cursor(); // just in case lines got deleted
|
||||||
|
VIsual_active = aco->save_VIsual_active;
|
||||||
|
if (VIsual_active) {
|
||||||
|
check_pos(curbuf, &VIsual);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Execute autocommands for "event" and file name "fname".
|
/// Execute autocommands for "event" and file name "fname".
|
||||||
|
@@ -14,6 +14,7 @@ typedef struct {
|
|||||||
handle_T save_prevwin_handle; ///< ID of saved prevwin
|
handle_T save_prevwin_handle; ///< ID of saved prevwin
|
||||||
bufref_T new_curbuf; ///< new curbuf
|
bufref_T new_curbuf; ///< new curbuf
|
||||||
char_u *globaldir; ///< saved value of globaldir
|
char_u *globaldir; ///< saved value of globaldir
|
||||||
|
bool save_VIsual_active; ///< saved VIsual_active
|
||||||
} aco_save_T;
|
} aco_save_T;
|
||||||
|
|
||||||
typedef struct AutoCmd {
|
typedef struct AutoCmd {
|
||||||
|
@@ -2543,6 +2543,16 @@ func Test_close_autocmd_tab()
|
|||||||
%bwipe!
|
%bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_Visual_doautoall_redraw()
|
||||||
|
call setline(1, ['a', 'b'])
|
||||||
|
new
|
||||||
|
wincmd p
|
||||||
|
call feedkeys("G\<C-V>", 'txn')
|
||||||
|
autocmd User Explode ++once redraw
|
||||||
|
doautoall User Explode
|
||||||
|
%bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_autocmd_closes_window()
|
func Test_autocmd_closes_window()
|
||||||
au BufNew,BufWinLeave * e %e
|
au BufNew,BufWinLeave * e %e
|
||||||
file yyy
|
file yyy
|
||||||
|
@@ -2406,6 +2406,17 @@ describe('lua stdlib', function()
|
|||||||
eq(buf1, meths.get_current_buf())
|
eq(buf1, meths.get_current_buf())
|
||||||
eq(buf2, val)
|
eq(buf2, val)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('does not cause ml_get errors with invalid visual selection', function()
|
||||||
|
-- Should be fixed by vim-patch:8.2.4028.
|
||||||
|
exec_lua [[
|
||||||
|
local a = vim.api
|
||||||
|
local t = function(s) return a.nvim_replace_termcodes(s, true, true, true) end
|
||||||
|
a.nvim_buf_set_lines(0, 0, -1, true, {"a", "b", "c"})
|
||||||
|
a.nvim_feedkeys(t "G<C-V>", "txn", false)
|
||||||
|
a.nvim_buf_call(a.nvim_create_buf(false, true), function() vim.cmd "redraw" end)
|
||||||
|
]]
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('vim.api.nvim_win_call', function()
|
describe('vim.api.nvim_win_call', function()
|
||||||
|
Reference in New Issue
Block a user