mirror of
https://github.com/neovim/neovim.git
synced 2026-07-15 22:00:40 +00:00
fix(terminal): don't allow b:term_title watcher to delete buffer
This commit is contained in:
@@ -1416,6 +1416,7 @@ static void buf_set_term_title(buf_T *buf, const char *title, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Error err = ERROR_INIT;
|
Error err = ERROR_INIT;
|
||||||
|
buf->b_locked++;
|
||||||
dict_set_var(buf->b_vars,
|
dict_set_var(buf->b_vars,
|
||||||
STATIC_CSTR_AS_STRING("term_title"),
|
STATIC_CSTR_AS_STRING("term_title"),
|
||||||
STRING_OBJ(((String){ .data = (char *)title, .size = len })),
|
STRING_OBJ(((String){ .data = (char *)title, .size = len })),
|
||||||
@@ -1423,6 +1424,7 @@ static void buf_set_term_title(buf_T *buf, const char *title, size_t len)
|
|||||||
false,
|
false,
|
||||||
NULL,
|
NULL,
|
||||||
&err);
|
&err);
|
||||||
|
buf->b_locked--;
|
||||||
api_clear_error(&err);
|
api_clear_error(&err);
|
||||||
status_redraw_buf(buf);
|
status_redraw_buf(buf);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1134,6 +1134,16 @@ describe(':terminal buffer', function()
|
|||||||
feed([[<C-\><C-N>]])
|
feed([[<C-\><C-N>]])
|
||||||
eq({ mode = 'nt', blocking = false }, api.nvim_get_mode())
|
eq({ mode = 'nt', blocking = false }, api.nvim_get_mode())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('does not allow b:term_title watcher to delete buffer', function()
|
||||||
|
local chan = api.nvim_open_term(0, {})
|
||||||
|
api.nvim_chan_send(chan, '\027]2;SOME_TITLE\007')
|
||||||
|
eq('SOME_TITLE', api.nvim_buf_get_var(0, 'term_title'))
|
||||||
|
command([[call dictwatcheradd(b:, 'term_title', {-> execute('bwipe!')})]])
|
||||||
|
api.nvim_chan_send(chan, '\027]2;OTHER_TITLE\007')
|
||||||
|
eq('OTHER_TITLE', api.nvim_buf_get_var(0, 'term_title'))
|
||||||
|
matches('^E937: ', api.nvim_get_vvar('errmsg'))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('on_lines does not emit out-of-bounds line indexes when', function()
|
describe('on_lines does not emit out-of-bounds line indexes when', function()
|
||||||
|
|||||||
Reference in New Issue
Block a user