]> granicus.if.org Git - vim/commitdiff
patch 7.4.2201 v7.4.2201
authorBram Moolenaar <Bram@vim.org>
Fri, 12 Aug 2016 16:29:59 +0000 (18:29 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 12 Aug 2016 16:29:59 +0000 (18:29 +0200)
Problem:    The sign column disappears when the last sign is deleted.
Solution:   Add the 'signcolumn' option. (Christian Brabandt)

runtime/doc/options.txt
runtime/optwin.vim
src/edit.c
src/move.c
src/option.c
src/option.h
src/proto/option.pro
src/screen.c
src/structs.h
src/testdir/test_options.vim
src/version.c

index 16002ddd056e82d89a7fc6773e6fc5a159fc254a..58f71ac6b980618dc720cc10618ba578b9233ab1 100644 (file)
@@ -1,4 +1,4 @@
-*options.txt*  For Vim version 7.4.  Last change: 2016 Jul 29
+*options.txt*  For Vim version 7.4.  Last change: 2016 Aug 12
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -261,10 +261,10 @@ global value, which is used for new buffers.  With ":set" both the local and
 global value is changed.  With "setlocal" only the local value is changed,
 thus this value is not used when editing a new buffer.
 
-When editing a buffer that has been edited before, the last used window
-options are used again.  If this buffer has been edited in this window, the
-values from back then are used.  Otherwise the values from the window where
-the buffer was edited last are used.
+When editing a buffer that has been edited before, the options from the window
+that was last closed are used again.  If this buffer has been edited in this
+window, the values from back then are used.  Otherwise the values from the
+last closed window where the buffer was edited last are used.
 
 It's possible to set a local window option specifically for a type of buffer.
 When you edit another buffer in the same window, you don't want to keep
@@ -6733,10 +6733,19 @@ A jump table for the options with a short description can be found at |Q_op|.
 
        Example: Try this together with 'sidescroll' and 'listchars' as
                 in the following example to never allow the cursor to move
-                onto the "extends" character:
+                onto the "extends" character: >
 
                 :set nowrap sidescroll=1 listchars=extends:>,precedes:<
                 :set sidescrolloff=1
+<
+                                               *'signcolumn'* *'scl'*
+'signcolumn' 'scl'     string  (default "auto")
+                       local to window
+                       {not in Vi}
+                       {not available when compiled without the |+signs|
+                       feature}
+       Whether or not to draw the signcolumn. "auto" means it will only be
+       drawn when there is a sign to display.
 
 
                        *'smartcase'* *'scs'* *'nosmartcase'* *'noscs'*
index e534a912c3e7cbe0fde9f784fecf5174cea11b8f..11d6b8804eb9d266ed81745ff2c2ca0b380357aa 100644 (file)
@@ -1307,6 +1307,11 @@ call append("$", "\t(local to buffer)")
 call <SID>BinOptionL("bl")
 call append("$", "debug\tset to \"msg\" to see all error messages")
 call append("$", " \tset debug=" . &debug)
+if has("signs")
+  call append("$", "signcolumn\twhether to show the signcolumn")
+  call append("$", "\t(local to window)")
+  call <SID>OptionL("scl")
+endif
 if has("mzscheme")
   call append("$", "mzquantum\tinterval in milliseconds between polls for MzScheme threads")
   call append("$", " \tset mzq=" . &mzq)
index 2281232278bb2c8f5bbacb84bc693a9af02faf62..08aed470cf0350a61e3977b5a9a03499f31f2bd5 100644 (file)
@@ -6761,11 +6761,7 @@ comp_textwidth(
        textwidth -= curwin->w_p_fdc;
 #endif
 #ifdef FEAT_SIGNS
-       if (curwin->w_buffer->b_signlist != NULL
-# ifdef FEAT_NETBEANS_INTG
-                         || curwin->w_buffer->b_has_sign_column
-# endif
-                   )
+       if (signcolumn_on(curwin))
            textwidth -= 1;
 #endif
        if (curwin->w_p_nu || curwin->w_p_rnu)
index 136263f22aeab58d75b1b4b932d4eb87c0c70fa3..a083c1c455b3b4103f210a952b978b52bc9f3fd6 100644 (file)
@@ -890,12 +890,7 @@ win_col_off(win_T *wp)
            + wp->w_p_fdc
 #endif
 #ifdef FEAT_SIGNS
-           + (
-# ifdef FEAT_NETBEANS_INTG
-               /* show glyph gutter in netbeans */
-               wp->w_buffer->b_has_sign_column ||
-# endif
-               wp->w_buffer->b_signlist != NULL ? 2 : 0)
+           + (signcolumn_on(wp) ? 2 : 0)
 #endif
           );
 }
index ff7973fd40e09161a799c0b5137a4105e33d6975..7146503eb392130edcf9af631e915a6af53b9474 100644 (file)
 # define PV_COCU       OPT_WIN(WV_COCU)
 # define PV_COLE       OPT_WIN(WV_COLE)
 #endif
+#ifdef FEAT_SIGNS
+# define PV_SCL                OPT_WIN(WV_SCL)
+#endif
 
 /* WV_ and BV_ values get typecasted to this for the "indir" field */
 typedef enum
@@ -2410,6 +2413,14 @@ static struct vimoption options[] =
     {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
                            (char_u *)&p_siso, PV_NONE,
                            {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
+    {"signcolumn",   "scl",  P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
+#ifdef FEAT_SIGNS
+                           (char_u *)VAR_WIN, PV_SCL,
+                           {(char_u *)"auto", (char_u *)0L} SCRIPTID_INIT},
+#else
+                           (char_u *)NULL, PV_NONE,
+                           {(char_u *)NULL, (char_u *)0L}
+#endif
     {"slowopen",    "slow", P_BOOL|P_VI_DEF,
                            (char_u *)NULL, PV_NONE,
                            {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
@@ -3076,6 +3087,9 @@ static char *(p_fcl_values[]) = {"all", NULL};
 #ifdef FEAT_INS_EXPAND
 static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
 #endif
+#ifdef FEAT_SIGNS
+static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
+#endif
 
 static void set_option_default(int, int opt_flags, int compatible);
 static void set_options_default(int opt_flags);
@@ -6978,6 +6992,15 @@ did_set_string_option(
     }
 #endif /* FEAT_INS_EXPAND */
 
+#ifdef FEAT_SIGNS
+    /* 'signcolumn' */
+    else if (varp == &curwin->w_p_scl)
+    {
+       if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
+           errmsg = e_invarg;
+    }
+#endif
+
 
 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
     else if (varp == &p_toolbar)
@@ -10432,6 +10455,9 @@ get_varp(struct vimoption *p)
        case PV_WM:     return (char_u *)&(curbuf->b_p_wm);
 #ifdef FEAT_KEYMAP
        case PV_KMAP:   return (char_u *)&(curbuf->b_p_keymap);
+#endif
+#ifdef FEAT_SIGNS
+       case PV_SCL:    return (char_u *)&(curwin->w_p_scl);
 #endif
        default:        EMSG(_("E356: get_varp ERROR"));
     }
@@ -10548,6 +10574,9 @@ copy_winopt(winopt_T *from, winopt_T *to)
     to->wo_fdt = vim_strsave(from->wo_fdt);
 # endif
     to->wo_fmr = vim_strsave(from->wo_fmr);
+#endif
+#ifdef FEAT_SIGNS
+    to->wo_scl = vim_strsave(from->wo_scl);
 #endif
     check_winopt(to);          /* don't want NULL pointers */
 }
@@ -10578,6 +10607,9 @@ check_winopt(winopt_T *wop UNUSED)
 # endif
     check_string_option(&wop->wo_fmr);
 #endif
+#ifdef FEAT_SIGNS
+    check_string_option(&wop->wo_scl);
+#endif
 #ifdef FEAT_RIGHTLEFT
     check_string_option(&wop->wo_rlc);
 #endif
@@ -10611,6 +10643,9 @@ clear_winopt(winopt_T *wop UNUSED)
 # endif
     clear_string_option(&wop->wo_fmr);
 #endif
+#ifdef FEAT_SIGNS
+    clear_string_option(&wop->wo_scl);
+#endif
 #ifdef FEAT_LINEBREAK
     clear_string_option(&wop->wo_briopt);
 #endif
@@ -12274,3 +12309,22 @@ get_bkc_value(buf_T *buf)
 {
     return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
 }
+
+#if defined(FEAT_SIGNS) || defined(PROTO)
+/*
+ * Return TRUE when window "wp" has a column to draw signs in.
+ */
+     int
+signcolumn_on(win_T *wp)
+{
+    if (*wp->w_p_scl == 'n')
+       return FALSE;
+    if (*wp->w_p_scl == 'y')
+       return TRUE;
+    return (wp->w_buffer->b_signlist != NULL
+# ifdef FEAT_NETBEANS_INTG
+                       || wp->w_buffer->b_has_sign_column
+# endif
+                   );
+}
+#endif
index bc8d4e0cf600bee9d25fa5a414ea522db524f516..bee6442c05f9288fcd7df5580004ea441f741118 100644 (file)
@@ -633,6 +633,9 @@ EXTERN int  p_magic;        /* 'magic' */
 EXTERN char_u  *p_mef;         /* 'makeef' */
 EXTERN char_u  *p_mp;          /* 'makeprg' */
 #endif
+#ifdef FEAT_SIGNS
+EXTERN char_u  *p_scl;         /* signcolumn */
+#endif
 #ifdef FEAT_SYN_HL
 EXTERN char_u   *p_cc;         /* 'colorcolumn' */
 EXTERN int      p_cc_cols[256]; /* array for 'colorcolumn' columns */
@@ -1173,6 +1176,9 @@ enum
     , WV_WFW
 #endif
     , WV_WRAP
+#ifdef FEAT_SIGNS
+    , WV_SCL
+#endif
     , WV_COUNT     /* must be the last one */
 };
 
index d0ba4ec27f87d5823b390f998ea7569a9c10c28f..3da0e945e0573d32f829db1653c5a7e43eeb3767 100644 (file)
@@ -63,4 +63,5 @@ long get_sw_value(buf_T *buf);
 long get_sts_value(void);
 void find_mps_values(int *initc, int *findc, int *backwards, int switchit);
 unsigned int get_bkc_value(buf_T *buf);
+int signcolumn_on(win_T *wp);
 /* vim: set ft=c : */
index 0458ed78015693589f4348fe008f7398312526ea..cf23a6813de24b9939995028a5a0ae8a42ceedf6 100644 (file)
@@ -2255,23 +2255,6 @@ win_update(win_T *wp)
 #endif
 }
 
-#ifdef FEAT_SIGNS
-static int draw_signcolumn(win_T *wp);
-
-/*
- * Return TRUE when window "wp" has a column to draw signs in.
- */
-    static int
-draw_signcolumn(win_T *wp)
-{
-    return (wp->w_buffer->b_signlist != NULL
-# ifdef FEAT_NETBEANS_INTG
-                               || wp->w_buffer->b_has_sign_column
-# endif
-                   );
-}
-#endif
-
 /*
  * Clear the rest of the window and mark the unused lines with "c1".  use "c2"
  * as the filler character.
@@ -2313,7 +2296,7 @@ win_draw_end(
        }
 # endif
 # ifdef FEAT_SIGNS
-       if (draw_signcolumn(wp))
+       if (signcolumn_on(wp))
        {
            int nn = n + 2;
 
@@ -2363,7 +2346,7 @@ win_draw_end(
        }
 #endif
 #ifdef FEAT_SIGNS
-       if (draw_signcolumn(wp))
+       if (signcolumn_on(wp))
        {
            int     nn = n + 2;
 
@@ -2507,7 +2490,7 @@ fold_line(
 
 #ifdef FEAT_SIGNS
     /* If signs are being displayed, add two spaces. */
-    if (draw_signcolumn(wp))
+    if (signcolumn_on(wp))
     {
        len = W_WIDTH(wp) - col;
        if (len > 0)
@@ -3677,7 +3660,7 @@ win_line(
                draw_state = WL_SIGN;
                /* Show the sign column when there are any signs in this
                 * buffer or when using Netbeans. */
-               if (draw_signcolumn(wp))
+               if (signcolumn_on(wp))
                {
                    int text_sign;
 # ifdef FEAT_SIGN_ICONS
index b56282fc2999736a82a66fc313018935b55ccb8f..2a64471b1f57c8fd5e851e7d4b1fbbb2acc9fe18 100644 (file)
@@ -263,6 +263,10 @@ typedef struct
     int                wo_crb_save;    /* 'cursorbind' state saved for diff mode*/
 # define w_p_crb_save w_onebuf_opt.wo_crb_save
 #endif
+#ifdef FEAT_SIGNS
+    char_u     *wo_scl;
+# define w_p_scl w_onebuf_opt.wo_scl   /* 'signcolumn' */
+#endif
 
 #ifdef FEAT_EVAL
     int                wo_scriptID[WV_COUNT];  /* SIDs for window-local options */
index cceb180189d7b0b09bcfce88400afe3ebc009b99..3ddf5e6c255eb7703578109c68e70633e85763e5 100644 (file)
@@ -16,7 +16,7 @@ function! Test_whichwrap()
   set whichwrap&
 endfunction
 
-function! Test_options()
+function Test_options()
   let caught = 'ok'
   try
     options
@@ -29,7 +29,7 @@ function! Test_options()
   close
 endfunction
 
-function! Test_path_keep_commas()
+function Test_path_keep_commas()
   " Test that changing 'path' keeps two commas.
   set path=foo,,bar
   set path-=bar
@@ -38,3 +38,11 @@ function! Test_path_keep_commas()
 
   set path&
 endfunction
+
+func Test_signcolumn()
+  call assert_equal("auto", &signcolumn)
+  set signcolumn=yes
+  set signcolumn=no
+  call assert_fails('set signcolumn=nope')
+endfunc
+
index 66648d2708441180dbbf9fe0b3a2dc23cb09e2b4..58893c5dbbebfb0fe11f2f27b71c36dea831ab1d 100644 (file)
@@ -763,6 +763,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2201,
 /**/
     2200,
 /**/