diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-08-12 18:29:59 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-08-12 18:29:59 +0200 |
commit | 95ec9d6a6ab3117d60ff638670a803d43974ba51 (patch) | |
tree | c4bb7a90165db973560e11a681665cce6c60e8d3 /src | |
parent | d823fa910cca43fec3c31c030ee908a14c272640 (diff) | |
download | vim-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)
Diffstat (limited to 'src')
-rw-r--r-- | src/edit.c | 6 | ||||
-rw-r--r-- | src/move.c | 7 | ||||
-rw-r--r-- | src/option.c | 54 | ||||
-rw-r--r-- | src/option.h | 6 | ||||
-rw-r--r-- | src/proto/option.pro | 1 | ||||
-rw-r--r-- | src/screen.c | 25 | ||||
-rw-r--r-- | src/structs.h | 4 | ||||
-rw-r--r-- | src/testdir/test_options.vim | 12 | ||||
-rw-r--r-- | src/version.c | 2 |
9 files changed, 83 insertions, 34 deletions
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, |