mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
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().
This commit is contained in:
33
src/tag.c
33
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)
|
||||
|
Reference in New Issue
Block a user