summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/options.txt2
-rw-r--r--src/option.h2
-rw-r--r--src/optionstr.c3
-rw-r--r--src/quickfix.c7
-rw-r--r--src/testdir/test_quickfix.vim8
-rw-r--r--src/version.c2
6 files changed, 21 insertions, 3 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index ba96e8380..b3d757992 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -7417,6 +7417,8 @@ A jump table for the options with a short description can be found at |Q_op|.
vsplit Just like "split" but split vertically.
newtab Like "split", but open a new tab page. Overrules
"split" when both are present.
+ uselast If included, jump to the previously used window when
+ jumping to errors with |quickfix| commands.
*'synmaxcol'* *'smc'*
'synmaxcol' 'smc' number (default 3000)
diff --git a/src/option.h b/src/option.h
index 2a4ffbaf6..6ab19899d 100644
--- a/src/option.h
+++ b/src/option.h
@@ -911,11 +911,13 @@ EXTERN char_u *p_su; // 'suffixes'
EXTERN char_u *p_sws; // 'swapsync'
EXTERN char_u *p_swb; // 'switchbuf'
EXTERN unsigned swb_flags;
+// Keep in sync with p_swb_values in optionstr.c
#define SWB_USEOPEN 0x001
#define SWB_USETAB 0x002
#define SWB_SPLIT 0x004
#define SWB_NEWTAB 0x008
#define SWB_VSPLIT 0x010
+#define SWB_USELAST 0x020
EXTERN char_u *p_syn; // 'syntax'
EXTERN long p_ts; // 'tabstop'
EXTERN int p_tbs; // 'tagbsearch'
diff --git a/src/optionstr.c b/src/optionstr.c
index 143c8dd54..b63a351c6 100644
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -39,7 +39,8 @@ static char *(p_ssop_values[]) = {"buffers", "winpos", "resize", "winsize",
"localoptions", "options", "help", "blank", "globals", "slash", "unix",
"sesdir", "curdir", "folds", "cursor", "tabpages", "terminal", NULL};
#endif
-static char *(p_swb_values[]) = {"useopen", "usetab", "split", "newtab", "vsplit", NULL};
+// Keep in sync with SWB_ flags in option.h
+static char *(p_swb_values[]) = {"useopen", "usetab", "split", "newtab", "vsplit", "uselast", NULL};
static char *(p_tc_values[]) = {"followic", "ignore", "match", "followscs", "smart", NULL};
#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN)
static char *(p_toolbar_values[]) = {"text", "icons", "tooltips", "horiz", NULL};
diff --git a/src/quickfix.c b/src/quickfix.c
index a5d307ea7..aa4e76590 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -3013,8 +3013,11 @@ qf_goto_win_with_qfl_file(int qf_fnum)
if (IS_QF_WINDOW(win))
{
// Didn't find it, go to the window before the quickfix
- // window.
- if (altwin != NULL)
+ // window, unless 'switchbuf' contains 'uselast': in this case we
+ // try to jump to the previously used window first.
+ if ((swb_flags & SWB_USELAST) && win_valid(prevwin))
+ win = prevwin;
+ else if (altwin != NULL)
win = altwin;
else if (curwin->w_prev != NULL)
win = curwin->w_prev;
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index a3061336f..0744364fd 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -1664,6 +1664,14 @@ func Test_switchbuf()
call assert_equal(3, tabpagenr('$'))
tabfirst | enew | tabonly | only
+ set switchbuf=uselast
+ split
+ let last_winid = win_getid()
+ copen
+ exe "normal 1G\<CR>"
+ call assert_equal(last_winid, win_getid())
+ enew | only
+
set switchbuf=
edit Xqftestfile1
let file1_winid = win_getid()
diff --git a/src/version.c b/src/version.c
index 8422b71e3..b6a209d7e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2315,
+/**/
2314,
/**/
2313,