+72
-0
lines changedFilter options
+72
-0
lines changed Original file line number Diff line number Diff line change
@@ -1147,6 +1147,7 @@ void aucmd_prepbuf(aco_save_T *aco, buf_T *buf)
1147
1147
globaldir = NULL;
1148
1148
1149
1149
block_autocmds(); // We don't want BufEnter/WinEnter autocommands.
1150
+
make_snapshot(SNAP_AUCMD_IDX);
1150
1151
if (need_append) {
1151
1152
win_append(lastwin, aucmd_win);
1152
1153
pmap_put(handle_T)(&window_handles, aucmd_win->handle, aucmd_win);
@@ -1212,6 +1213,8 @@ void aucmd_restbuf(aco_save_T *aco)
1212
1213
close_tabpage(curtab);
1213
1214
}
1214
1215
1216
+
restore_snapshot(SNAP_AUCMD_IDX, false);
1217
+
win_comp_pos(); // recompute window positions
1215
1218
unblock_autocmds();
1216
1219
1217
1220
win_T *const save_curwin = win_find_by_handle(aco->save_curwin_handle);
Original file line number Diff line number Diff line change
@@ -958,6 +958,11 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
958
958
int wmh1;
959
959
bool did_set_fraction = false;
960
960
961
+
// aucmd_win should always remain floating
962
+
if (new_wp != NULL && new_wp == aucmd_win) {
963
+
return FAIL;
964
+
}
965
+
961
966
if (flags & WSP_TOP) {
962
967
oldwin = firstwin;
963
968
} else if (flags & WSP_BOT || curwin->w_floating) {
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
2
2
local Screen = require('test.functional.ui.screen')
3
3
4
4
local assert_visible = helpers.assert_visible
5
+
local assert_alive = helpers.assert_alive
5
6
local dedent = helpers.dedent
6
7
local eq = helpers.eq
7
8
local eval = helpers.eval
@@ -13,6 +14,7 @@ local funcs = helpers.funcs
13
14
local expect = helpers.expect
14
15
local command = helpers.command
15
16
local exc_exec = helpers.exc_exec
17
+
local exec_lua = helpers.exec_lua
16
18
local curbufmeths = helpers.curbufmeths
17
19
local source = helpers.source
18
20
@@ -333,6 +335,68 @@ describe('autocmd', function()
333
335
pcall_err(command, "call nvim_set_current_win(g:winid)"))
334
336
end)
335
337
338
+
it("`aucmd_win` cannot be changed into a normal window #13699", function()
339
+
local screen = Screen.new(50, 10)
340
+
screen:attach()
341
+
screen:set_default_attr_ids {
342
+
[1] = {bold = true, foreground = Screen.colors.Blue1},
343
+
[2] = {reverse = true},
344
+
[3] = {bold = true, reverse = true},
345
+
}
346
+
347
+
-- Create specific layout and ensure it's left unchanged.
348
+
-- Use nvim_buf_call on a hidden buffer so aucmd_win is used.
349
+
exec_lua [[
350
+
vim.cmd "wincmd s | wincmd _"
351
+
_G.buf = vim.api.nvim_create_buf(true, true)
352
+
vim.api.nvim_buf_call(_G.buf, function() vim.cmd "wincmd J" end)
353
+
]]
354
+
screen:expect [[
355
+
^ |
356
+
{1:~ }|
357
+
{1:~ }|
358
+
{1:~ }|
359
+
{1:~ }|
360
+
{1:~ }|
361
+
{3:[No Name] }|
362
+
|
363
+
{2:[No Name] }|
364
+
|
365
+
]]
366
+
-- This used to crash after making aucmd_win a normal window via the above.
367
+
exec_lua [[
368
+
vim.cmd "tabnew | tabclose # | wincmd s | wincmd _"
369
+
vim.api.nvim_buf_call(_G.buf, function() vim.cmd "wincmd K" end)
370
+
]]
371
+
assert_alive()
372
+
screen:expect_unchanged()
373
+
374
+
-- Ensure splitting still works from inside the aucmd_win.
375
+
exec_lua [[vim.api.nvim_buf_call(_G.buf, function() vim.cmd "split" end)]]
376
+
screen:expect [[
377
+
^ |
378
+
{1:~ }|
379
+
{3:[No Name] }|
380
+
|
381
+
{1:~ }|
382
+
{2:[Scratch] }|
383
+
|
384
+
{1:~ }|
385
+
{2:[No Name] }|
386
+
|
387
+
]]
388
+
389
+
-- After all of our messing around, aucmd_win should still be floating.
390
+
-- Use :only to ensure _G.buf is hidden again (so the aucmd_win is used).
391
+
eq("editor", exec_lua [[
392
+
vim.cmd "only"
393
+
vim.api.nvim_buf_call(_G.buf, function()
394
+
_G.config = vim.api.nvim_win_get_config(0)
395
+
end)
396
+
return _G.config.relative
397
+
]])
398
+
end)
399
+
336
400
it(':doautocmd does not warn "No matching autocommands" #10689', function()
337
401
local screen = Screen.new(32, 3)
338
402
screen:attach()
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4