Mercurial > vim
diff src/tag.c @ 11476:c45fb081391c v8.0.0621
patch 8.0.0621: :stag does not respect 'switchbuf'
commit https://github.com/vim/vim/commit/8ad80dea089ffeb1a845199c013e9bb4be1cd22e
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 5 16:01:59 2017 +0200
patch 8.0.0621: :stag does not respect 'switchbuf'
Problem: The ":stag" command does not respect 'switchbuf'.
Solution: Check 'switchbuf' for tag commands that may open a new window.
(Ingo Karkat, closes #1681) Define macros for the return values
of getfile().
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 05 Jun 2017 16:15:03 +0200 |
parents | c7ba89661c39 |
children | 578df034735d |
line wrap: on
line diff
--- a/src/tag.c +++ b/src/tag.c @@ -3088,7 +3088,7 @@ jumpto_tag( char_u *fname; tagptrs_T tagp; int retval = FAIL; - int getfile_result; + int getfile_result = GETFILE_UNUSED; int search_options; #ifdef FEAT_SEARCH_EXTRA int save_no_hlsearch; @@ -3202,7 +3202,29 @@ jumpto_tag( /* If it was a CTRL-W CTRL-] command split window now. For ":tab tag" * open a new tab page. */ - if (postponed_split || cmdmod.tab != 0) + if (postponed_split && (swb_flags & (SWB_USEOPEN | SWB_USETAB))) + { + buf_T *existing_buf = buflist_findname_exp(fname); + + if (existing_buf != NULL) + { + win_T *wp = NULL; + + if (swb_flags & SWB_USEOPEN) + wp = buf_jump_open_win(existing_buf); + + /* If 'switchbuf' contains "usetab": jump to first window in any tab + * page containing "existing_buf" if one exists */ + if (wp == NULL && (swb_flags & SWB_USETAB)) + wp = buf_jump_open_tab(existing_buf); + /* We've switched to the buffer, the usual loading of the file must + * be skipped. */ + if (wp != NULL) + getfile_result = GETFILE_SAME_FILE; + } + } + if (getfile_result == GETFILE_UNUSED + && (postponed_split || cmdmod.tab != 0)) { if (win_split(postponed_split > 0 ? postponed_split : 0, postponed_split_flags) == FAIL) @@ -3225,10 +3247,11 @@ jumpto_tag( #endif keep_help_flag = curbuf->b_help; } - getfile_result = getfile(0, fname, NULL, TRUE, (linenr_T)0, forceit); + if (getfile_result == GETFILE_UNUSED) + getfile_result = getfile(0, fname, NULL, TRUE, (linenr_T)0, forceit); keep_help_flag = FALSE; - if (getfile_result <= 0) /* got to the right file */ + if (GETFILE_SUCCESS(getfile_result)) /* got to the right file */ { curwin->w_set_curswant = TRUE; #ifdef FEAT_WINDOWS @@ -3377,7 +3400,7 @@ jumpto_tag( #endif /* Return OK if jumped to another file (at least we found the file!). */ - if (getfile_result == -1) + if (getfile_result == GETFILE_OPEN_OTHER) retval = OK; if (retval == OK)