From 9601e7c5d5cc455bd6649ece2049a528993f4c79 Mon Sep 17 00:00:00 2001 From: shirasaka Date: Fri, 4 Dec 2020 12:03:04 +0900 Subject: ui: Fix win_hide distination grid When create tab, win_hide sent to new tab and new tab's previous tab. So, if created tab that not next tab (eg. $tabnew cmd), send win_hide to not current tab, and fixed this. --- src/nvim/window.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/window.c b/src/nvim/window.c index 72ee400e40..5a5d3690f6 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -3787,6 +3787,7 @@ void free_tabpage(tabpage_T *tp) /// @return Was the new tabpage created successfully? FAIL or OK. int win_new_tabpage(int after, char_u *filename) { + tabpage_T *old_curtab = curtab; tabpage_T *tp = curtab; tabpage_T *newtp; int n; @@ -3830,9 +3831,9 @@ int win_new_tabpage(int after, char_u *filename) 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_WINENTER, NULL, NULL, false, curbuf); -- cgit From bb6229449d87defca4523c11d82bff8cbcad27ca Mon Sep 17 00:00:00 2001 From: Shirasaka Date: Sat, 5 Dec 2020 23:48:59 +0900 Subject: Moved temporary variable to where it's used --- src/nvim/window.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/window.c b/src/nvim/window.c index 5a5d3690f6..c415050391 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -3788,7 +3788,6 @@ void free_tabpage(tabpage_T *tp) int win_new_tabpage(int after, char_u *filename) { tabpage_T *old_curtab = curtab; - tabpage_T *tp = curtab; tabpage_T *newtp; int n; @@ -3800,18 +3799,20 @@ int win_new_tabpage(int after, char_u *filename) 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; /* 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. */ if (after == 1) { /* New tab page becomes the first one. */ newtp->tp_next = first_tabpage; first_tabpage = newtp; } else { + tabpage_T *tp = old_curtab; + if (after > 0) { /* Put new tab page before tab page "after". */ n = 2; -- cgit From de0ecf3e031573d543857e92b42fc37bfaaa17a0 Mon Sep 17 00:00:00 2001 From: Shirasaka Date: Sun, 6 Dec 2020 02:25:38 +0900 Subject: Fixed lint error --- src/nvim/window.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/nvim/window.c b/src/nvim/window.c index c415050391..9eb16e67ec 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -3793,28 +3793,29 @@ int win_new_tabpage(int after, char_u *filename) newtp = alloc_tabpage(); - /* Remember the current windows in this Tab page. */ - if (leave_tabpage(curbuf, TRUE) == FAIL) { + // Remember the current windows in this Tab page. + if (leave_tabpage(curbuf, true) == FAIL) { xfree(newtp); return FAIL; } - newtp->tp_localdir = old_curtab->tp_localdir ? vim_strsave(old_curtab->tp_localdir) : NULL; + newtp->tp_localdir = old_curtab->tp_localdir + ? vim_strsave(old_curtab->tp_localdir) : NULL; curtab = newtp; - /* Create a new empty window. */ + // Create a new empty window. 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) { - /* New tab page becomes the first one. */ + // New tab page becomes the first one. newtp->tp_next = first_tabpage; first_tabpage = newtp; } else { tabpage_T *tp = old_curtab; if (after > 0) { - /* Put new tab page before tab page "after". */ + // Put new tab page before tab page "after". n = 2; for (tp = first_tabpage; tp->tp_next != NULL && n < after; tp = tp->tp_next) @@ -3828,7 +3829,7 @@ int win_new_tabpage(int after, char_u *filename) win_comp_scroll(curwin); newtp->tp_topframe = topframe; - last_status(FALSE); + last_status(false); redraw_all_later(NOT_VALID); @@ -3844,8 +3845,8 @@ int win_new_tabpage(int after, char_u *filename) return OK; } - /* Failed, get back the previous Tab page */ - enter_tabpage(curtab, curbuf, TRUE, TRUE); + // Failed, get back the previous Tab page + enter_tabpage(curtab, curbuf, true, true); return FAIL; } -- cgit