summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-08-12 18:29:59 +0200
committerBram Moolenaar <Bram@vim.org>2016-08-12 18:29:59 +0200
commit95ec9d6a6ab3117d60ff638670a803d43974ba51 (patch)
treec4bb7a90165db973560e11a681665cce6c60e8d3
parentd823fa910cca43fec3c31c030ee908a14c272640 (diff)
downloadvim-git-95ec9d6a6ab3117d60ff638670a803d43974ba51.tar.gz
patch 7.4.2201v7.4.2201
Problem: The sign column disappears when the last sign is deleted. Solution: Add the 'signcolumn' option. (Christian Brabandt)
-rw-r--r--runtime/doc/options.txt21
-rw-r--r--runtime/optwin.vim5
-rw-r--r--src/edit.c6
-rw-r--r--src/move.c7
-rw-r--r--src/option.c54
-rw-r--r--src/option.h6
-rw-r--r--src/proto/option.pro1
-rw-r--r--src/screen.c25
-rw-r--r--src/structs.h4
-rw-r--r--src/testdir/test_options.vim12
-rw-r--r--src/version.c2
11 files changed, 103 insertions, 40 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 16002ddd0..58f71ac6b 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -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'*
diff --git a/runtime/optwin.vim b/runtime/optwin.vim
index e534a912c..11d6b8804 100644
--- a/runtime/optwin.vim
+++ b/runtime/optwin.vim
@@ -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)
diff --git a/src/edit.c b/src/edit.c
index 228123227..08aed470c 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -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)
diff --git a/src/move.c b/src/move.c
index 136263f22..a083c1c45 100644
--- a/src/move.c
+++ b/src/move.c
@@ -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
);
}
diff --git a/src/option.c b/src/option.c
index ff7973fd4..7146503eb 100644
--- a/src/option.c
+++ b/src/option.c
@@ -253,6 +253,9 @@
# 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)
@@ -10433,6 +10456,9 @@ get_varp(struct vimoption *p)
#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"));
}
/* always return a valid pointer to avoid a crash! */
@@ -10549,6 +10575,9 @@ copy_winopt(winopt_T *from, winopt_T *to)
# 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
diff --git a/src/option.h b/src/option.h
index bc8d4e0cf..bee6442c0 100644
--- a/src/option.h
+++ b/src/option.h
@@ -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 */
};
diff --git a/src/proto/option.pro b/src/proto/option.pro
index d0ba4ec27..3da0e945e 100644
--- a/src/proto/option.pro
+++ b/src/proto/option.pro
@@ -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 : */
diff --git a/src/screen.c b/src/screen.c
index 0458ed780..cf23a6813 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -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
diff --git a/src/structs.h b/src/structs.h
index b56282fc2..2a64471b1 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -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 */
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index cceb18018..3ddf5e6c2 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -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
+
diff --git a/src/version.c b/src/version.c
index 66648d270..58893c5db 100644
--- a/src/version.c
+++ b/src/version.c
@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2201,
+/**/
2200,
/**/
2199,