diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-06-21 09:59:14 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-06-21 12:50:30 -0400 |
commit | bf61885cb45fcced4f5886f336460be4af8a8ba8 (patch) | |
tree | 2852806953323960e6bc74ce50203af6b9a8dff0 /src/nvim/tag.c | |
parent | 7ae7da8fb9ab2e23ffc19000798ae27a2dee4e87 (diff) | |
download | rneovim-bf61885cb45fcced4f5886f336460be4af8a8ba8.tar.gz rneovim-bf61885cb45fcced4f5886f336460be4af8a8ba8.tar.bz2 rneovim-bf61885cb45fcced4f5886f336460be4af8a8ba8.zip |
vim-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 vim/vim#1681) Define macros for the return values
of getfile().
https://github.com/vim/vim/commit/8ad80dea089ffeb1a845199c013e9bb4be1cd22e
Diffstat (limited to 'src/nvim/tag.c')
-rw-r--r-- | src/nvim/tag.c | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 473381a13c..beff89d191 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -2320,7 +2320,7 @@ jumpto_tag ( char_u *fname; tagptrs_T tagp; int retval = FAIL; - int getfile_result; + int getfile_result = GETFILE_UNUSED; int search_options; int save_no_hlsearch; win_T *curwin_save = NULL; @@ -2406,7 +2406,31 @@ 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 *const existing_buf = buflist_findname_exp(fname); + + if (existing_buf != NULL) { + const 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) { RedrawingDisabled--; @@ -2423,11 +2447,13 @@ jumpto_tag ( else keep_help_flag = curbuf->b_help; } - getfile_result = getfile(0, fname, NULL, TRUE, (linenr_T)0, forceit); - keep_help_flag = FALSE; + 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 */ - curwin->w_set_curswant = TRUE; + if (GETFILE_SUCCESS(getfile_result)) { // got to the right file + curwin->w_set_curswant = true; postponed_split = 0; save_secure = secure; @@ -2545,9 +2571,10 @@ jumpto_tag ( SET_NO_HLSEARCH(save_no_hlsearch); } - /* Return OK if jumped to another file (at least we found the file!). */ - if (getfile_result == -1) + // Return OK if jumped to another file (at least we found the file!). + if (getfile_result == GETFILE_OPEN_OTHER) { retval = OK; + } if (retval == OK) { /* |