diff options
| author | Bram Moolenaar <Bram@vim.org> | 2015-04-21 18:08:39 +0200 |
|---|---|---|
| committer | Bram Moolenaar <Bram@vim.org> | 2015-04-21 18:08:39 +0200 |
| commit | 40ce3a4e1f50badb75ca812e26557a9bc5fde8c6 (patch) | |
| tree | 76b61256322ed7d01bbd3913ec3ae45f9d826b5a /src/window.c | |
| parent | 77354e78a887e1b59ac519c5a1cb0e7fe9fc5899 (diff) | |
| download | vim-git-40ce3a4e1f50badb75ca812e26557a9bc5fde8c6.tar.gz | |
patch 7.4.709v7.4.709
Problem: ":tabmove" does not work as documented.
Solution: Make it work consistently. Update documentation and add tests.
(Hirohito Higashi)
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/window.c b/src/window.c index 952143003..609ab3e6a 100644 --- a/src/window.c +++ b/src/window.c @@ -4120,18 +4120,27 @@ goto_tabpage_win(tp, wp) } /* - * Move the current tab page to before tab page "nr". + * Move the current tab page to after tab page "nr". */ void tabpage_move(nr) int nr; { - int n = nr; - tabpage_T *tp; + int n = 1; + tabpage_T *tp, *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; @@ -4146,17 +4155,15 @@ tabpage_move(nr) } /* Re-insert it at the specified position. */ - if (n <= 0) + 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. */ |
