mirror of
https://github.com/neovim/neovim.git
synced 2025-09-15 07:48:18 +00:00
terminal.c: Reset cursor postion when using termopen() (#6212)
After using 'termopen("echo") the current buffer content is changed, but the cursor position of the current window is not updated. Because of this, a call to 'mb_adjust_cursor()' can lead to a heap-buffer-overflow. Fix this by resetting the cursor for the current window. Fixes #3161
This commit is contained in:

committed by
Justin M. Keyes

parent
af63f32129
commit
3030ef825d
@@ -240,6 +240,8 @@ Terminal *terminal_open(TerminalOptions opts)
|
||||
set_option_value((uint8_t *)"relativenumber", false, NULL, OPT_LOCAL);
|
||||
buf_set_term_title(curbuf, (char *)curbuf->b_ffname);
|
||||
RESET_BINDING(curwin);
|
||||
// Reset cursor in current window.
|
||||
curwin->w_cursor = (pos_T){ .lnum = 1, .col = 0, .coladd = 0 };
|
||||
|
||||
// Apply TermOpen autocmds _before_ configuring the scrollback buffer.
|
||||
apply_autocmds(EVENT_TERMOPEN, NULL, NULL, false, curbuf);
|
||||
|
Reference in New Issue
Block a user