Merge pull request #13454 from tk-shirasaka/fix/send-win_hide

ui: Fix win_hide distination grid
This commit is contained in:
Björn Linse 2020-12-05 21:22:19 +01:00 committed by GitHub
commit 463cf74182
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 88 additions and 14 deletions

View File

@ -3787,32 +3787,35 @@ void free_tabpage(tabpage_T *tp)
/// @return Was the new tabpage created successfully? FAIL or OK. /// @return Was the new tabpage created successfully? FAIL or OK.
int win_new_tabpage(int after, char_u *filename) int win_new_tabpage(int after, char_u *filename)
{ {
tabpage_T *tp = curtab; tabpage_T *old_curtab = curtab;
tabpage_T *newtp; tabpage_T *newtp;
int n; int n;
newtp = alloc_tabpage(); newtp = alloc_tabpage();
/* Remember the current windows in this Tab page. */ // Remember the current windows in this Tab page.
if (leave_tabpage(curbuf, TRUE) == FAIL) { if (leave_tabpage(curbuf, true) == FAIL) {
xfree(newtp); xfree(newtp);
return FAIL; return FAIL;
} }
newtp->tp_localdir = tp->tp_localdir ? vim_strsave(tp->tp_localdir) : NULL; newtp->tp_localdir = old_curtab->tp_localdir
? vim_strsave(old_curtab->tp_localdir) : NULL;
curtab = newtp; curtab = newtp;
/* Create a new empty window. */ // Create a new empty window.
if (win_alloc_firstwin(tp->tp_curwin) == OK) { if (win_alloc_firstwin(old_curtab->tp_curwin) == OK) {
/* Make the new Tab page the new topframe. */ // Make the new Tab page the new topframe.
if (after == 1) { if (after == 1) {
/* New tab page becomes the first one. */ // New tab page becomes the first one.
newtp->tp_next = first_tabpage; newtp->tp_next = first_tabpage;
first_tabpage = newtp; first_tabpage = newtp;
} else { } else {
tabpage_T *tp = old_curtab;
if (after > 0) { if (after > 0) {
/* Put new tab page before tab page "after". */ // Put new tab page before tab page "after".
n = 2; n = 2;
for (tp = first_tabpage; tp->tp_next != NULL for (tp = first_tabpage; tp->tp_next != NULL
&& n < after; tp = tp->tp_next) && n < after; tp = tp->tp_next)
@ -3826,13 +3829,13 @@ int win_new_tabpage(int after, char_u *filename)
win_comp_scroll(curwin); win_comp_scroll(curwin);
newtp->tp_topframe = topframe; newtp->tp_topframe = topframe;
last_status(FALSE); last_status(false);
redraw_all_later(NOT_VALID); redraw_all_later(NOT_VALID);
tabpage_check_windows(tp); tabpage_check_windows(old_curtab);
lastused_tabpage = tp; lastused_tabpage = old_curtab;
apply_autocmds(EVENT_WINNEW, NULL, NULL, false, curbuf); apply_autocmds(EVENT_WINNEW, NULL, NULL, false, curbuf);
apply_autocmds(EVENT_WINENTER, NULL, NULL, false, curbuf); apply_autocmds(EVENT_WINENTER, NULL, NULL, false, curbuf);
@ -3842,8 +3845,8 @@ int win_new_tabpage(int after, char_u *filename)
return OK; return OK;
} }
/* Failed, get back the previous Tab page */ // Failed, get back the previous Tab page
enter_tabpage(curtab, curbuf, TRUE, TRUE); enter_tabpage(curtab, curbuf, true, true);
return FAIL; return FAIL;
} }

View File

@ -1562,6 +1562,77 @@ describe('ext_multigrid', function()
{1:~ }| {1:~ }|
]]} ]]}
command('tabnext')
command('$tabnew')
screen:expect{grid=[[
## grid 1
{16: }{17:2}{16: [No Name] }{17:2}{16: [No Name] }{7: [No Name] }{12: }{16:X}|
[7:-----------------------------------------------------]|
[7:-----------------------------------------------------]|
[7:-----------------------------------------------------]|
[7:-----------------------------------------------------]|
[7:-----------------------------------------------------]|
[7:-----------------------------------------------------]|
[7:-----------------------------------------------------]|
[7:-----------------------------------------------------]|
[7:-----------------------------------------------------]|
[7:-----------------------------------------------------]|
[7:-----------------------------------------------------]|
{11:[No Name] }|
[3:-----------------------------------------------------]|
## grid 2 (hidden)
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 3
|
## grid 4 (hidden)
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 5 (hidden)
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 6 (hidden)
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
## grid 7
^ |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
]]}
command('tabclose')
command('tabclose') command('tabclose')
screen:expect{grid=[[ screen:expect{grid=[[
## grid 1 ## grid 1