]> granicus.if.org Git - vim/commitdiff
patch 8.1.2315: not always using the right window when jumping to an error v8.1.2315
authorBram Moolenaar <Bram@vim.org>
Sun, 17 Nov 2019 17:09:38 +0000 (18:09 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 17 Nov 2019 17:09:38 +0000 (18:09 +0100)
Problem:    Not always using the right window when jumping to an error.
Solution:   Add the "uselast" flag in 'switchbuf'. (closes #1652)

runtime/doc/options.txt
src/option.h
src/optionstr.c
src/quickfix.c
src/testdir/test_quickfix.vim
src/version.c

index ba96e8380e4b0dbc01f5da1bb70bc57c21b4e0dc..b3d7579924f5fcf57f9124818c25e64c55120bb5 100644 (file)
@@ -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)
index 2a4ffbaf617963e9ad69aec71d8b41727559665c..6ab19899d5ec36e6a1f6bf8b6aec3765f669bfd2 100644 (file)
@@ -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'
index 143c8dd542a13cb86197fcd0d55a9ec737c5dcfb..b63a351c63719a31f1e63fe6f9311e2b54127f19 100644 (file)
@@ -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};
index a5d307ea797cf09bc94dc5f246166f3eef42abcd..aa4e765908b64f1fb64c2ec209a6396f5b4c1144 100644 (file)
@@ -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;
index a3061336f8543fa2c5dd9a175f7ea14ed8f9542a..0744364fd63036b47801aa972e58b53634bef6d9 100644 (file)
@@ -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()
index 8422b71e394d3678359017649cad9a959b557d9e..b6a209d7e0adad234cb9b07d8baa52835ef187bd 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2315,
 /**/
     2314,
 /**/