diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-02-01 02:16:29 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-02-01 02:16:29 -0500 |
commit | 99067b7e56e0a873bcf333048ed0ba17280957be (patch) | |
tree | f0f7439aa98d0b71b262931c0fc4bc71a18667e7 /src/nvim/window.c | |
parent | fe1ba0487aab98a131e6789b6916b1aec369e8fc (diff) | |
parent | a31f9161b09f3500385e99b076b3d8328de47dd7 (diff) | |
download | rneovim-99067b7e56e0a873bcf333048ed0ba17280957be.tar.gz rneovim-99067b7e56e0a873bcf333048ed0ba17280957be.tar.bz2 rneovim-99067b7e56e0a873bcf333048ed0ba17280957be.zip |
Merge pull request #4113 from jbradaric/vim-7.4.709
vim-patch:7.4.709
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r-- | src/nvim/window.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c index 191cb04d75..e84d8df36b 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -3281,17 +3281,27 @@ void goto_tabpage_win(tabpage_T *tp, win_T *wp) } } -/* - * Move the current tab page to before tab page "nr". - */ +// Move the current tab page to after tab page "nr". void tabpage_move(int nr) { - int n = nr; - tabpage_T *tp; + int n = 1; + tabpage_T *tp; + tabpage_T *tp_dst; if (first_tabpage->tp_next == NULL) return; + for (tp = first_tabpage; tp->tp_next != NULL && n < nr; tp = tp->tp_next) { + ++n; + } + + if (tp == curtab || (nr > 0 && tp->tp_next != NULL + && tp->tp_next == curtab)) { + return; + } + + tp_dst = tp; + /* Remove the current tab page from the list of tab pages. */ if (curtab == first_tabpage) first_tabpage = curtab->tp_next; @@ -3304,15 +3314,13 @@ void tabpage_move(int nr) tp->tp_next = curtab->tp_next; } - /* Re-insert it at the specified position. */ - if (n <= 0) { + // Re-insert it at the specified position. + if (nr <= 0) { curtab->tp_next = first_tabpage; first_tabpage = curtab; } else { - for (tp = first_tabpage; tp->tp_next != NULL && n > 1; tp = tp->tp_next) - --n; - curtab->tp_next = tp->tp_next; - tp->tp_next = curtab; + curtab->tp_next = tp_dst->tp_next; + tp_dst->tp_next = curtab; } /* Need to redraw the tabline. Tab page contents doesn't change. */ |