To: vim_dev@googlegroups.com Subject: Patch 7.4.2201 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.2201 Problem: The sign column disappears when the last sign is deleted. Solution: Add the 'signcolumn' option. (Christian Brabandt) Files: 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 *** ../vim-7.4.2200/runtime/doc/options.txt 2016-07-27 23:26:00.782222261 +0200 --- runtime/doc/options.txt 2016-08-12 17:50:05.575859943 +0200 *************** *** 6704,6713 **** Example: Try this together with 'sidescroll' and 'listchars' as in the following example to never allow the cursor to move ! onto the "extends" character: :set nowrap sidescroll=1 listchars=extends:>,precedes:< :set sidescrolloff=1 *'smartcase'* *'scs'* *'nosmartcase'* *'noscs'* --- 6733,6751 ---- Example: Try this together with 'sidescroll' and 'listchars' as in the following example to never allow the cursor to move ! 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'* *** ../vim-7.4.2200/runtime/optwin.vim 2016-07-16 14:46:51.119240709 +0200 --- runtime/optwin.vim 2016-08-12 17:26:01.604631766 +0200 *************** *** 1307,1312 **** --- 1307,1317 ---- call 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 OptionL("scl") + endif if has("mzscheme") call append("$", "mzquantum\tinterval in milliseconds between polls for MzScheme threads") call append("$", " \tset mzq=" . &mzq) *** ../vim-7.4.2200/src/edit.c 2016-08-09 21:51:36.154407615 +0200 --- src/edit.c 2016-08-12 17:30:29.910264818 +0200 *************** *** 6761,6771 **** 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 ! ) textwidth -= 1; #endif if (curwin->w_p_nu || curwin->w_p_rnu) --- 6761,6767 ---- textwidth -= curwin->w_p_fdc; #endif #ifdef FEAT_SIGNS ! if (signcolumn_on(curwin)) textwidth -= 1; #endif if (curwin->w_p_nu || curwin->w_p_rnu) *** ../vim-7.4.2200/src/move.c 2016-07-24 21:58:39.712057561 +0200 --- src/move.c 2016-08-12 17:30:33.210235702 +0200 *************** *** 890,901 **** + 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) #endif ); } --- 890,896 ---- + wp->w_p_fdc #endif #ifdef FEAT_SIGNS ! + (signcolumn_on(wp) ? 2 : 0) #endif ); } *** ../vim-7.4.2200/src/option.c 2016-08-07 13:48:04.997106444 +0200 --- src/option.c 2016-08-12 17:48:50.480524989 +0200 *************** *** 253,258 **** --- 253,261 ---- # 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,2415 **** --- 2413,2426 ---- {"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,3081 **** --- 3087,3095 ---- #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,6983 **** --- 6992,7006 ---- } #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,10438 **** --- 10456,10464 ---- #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,10554 **** --- 10575,10583 ---- # 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,10583 **** --- 10607,10615 ---- # 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,10616 **** --- 10643,10651 ---- # 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,12276 **** --- 12309,12330 ---- { 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 *** ../vim-7.4.2200/src/option.h 2016-07-27 23:26:00.778222299 +0200 --- src/option.h 2016-08-12 17:55:59.128728720 +0200 *************** *** 633,638 **** --- 633,641 ---- 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,1178 **** --- 1176,1184 ---- , WV_WFW #endif , WV_WRAP + #ifdef FEAT_SIGNS + , WV_SCL + #endif , WV_COUNT /* must be the last one */ }; *** ../vim-7.4.2200/src/proto/option.pro 2016-01-19 13:21:55.845334290 +0100 --- src/proto/option.pro 2016-08-12 17:31:25.093777907 +0200 *************** *** 63,66 **** --- 63,67 ---- 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 : */ *** ../vim-7.4.2200/src/screen.c 2016-08-12 14:08:20.678029453 +0200 --- src/screen.c 2016-08-12 17:30:49.282093893 +0200 *************** *** 2255,2277 **** #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. --- 2255,2260 ---- *************** *** 2313,2319 **** } # endif # ifdef FEAT_SIGNS ! if (draw_signcolumn(wp)) { int nn = n + 2; --- 2296,2302 ---- } # endif # ifdef FEAT_SIGNS ! if (signcolumn_on(wp)) { int nn = n + 2; *************** *** 2363,2369 **** } #endif #ifdef FEAT_SIGNS ! if (draw_signcolumn(wp)) { int nn = n + 2; --- 2346,2352 ---- } #endif #ifdef FEAT_SIGNS ! if (signcolumn_on(wp)) { int nn = n + 2; *************** *** 2507,2513 **** #ifdef FEAT_SIGNS /* If signs are being displayed, add two spaces. */ ! if (draw_signcolumn(wp)) { len = W_WIDTH(wp) - col; if (len > 0) --- 2490,2496 ---- #ifdef FEAT_SIGNS /* If signs are being displayed, add two spaces. */ ! if (signcolumn_on(wp)) { len = W_WIDTH(wp) - col; if (len > 0) *************** *** 3677,3683 **** draw_state = WL_SIGN; /* Show the sign column when there are any signs in this * buffer or when using Netbeans. */ ! if (draw_signcolumn(wp)) { int text_sign; # ifdef FEAT_SIGN_ICONS --- 3660,3666 ---- draw_state = WL_SIGN; /* Show the sign column when there are any signs in this * buffer or when using Netbeans. */ ! if (signcolumn_on(wp)) { int text_sign; # ifdef FEAT_SIGN_ICONS *** ../vim-7.4.2200/src/structs.h 2016-08-07 18:22:30.426091047 +0200 --- src/structs.h 2016-08-12 17:49:30.300172347 +0200 *************** *** 263,268 **** --- 263,272 ---- 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 */ *** ../vim-7.4.2200/src/testdir/test_options.vim 2016-08-07 13:48:05.001106411 +0200 --- src/testdir/test_options.vim 2016-08-12 17:42:58.239644278 +0200 *************** *** 16,22 **** set whichwrap& endfunction ! function! Test_options() let caught = 'ok' try options --- 16,22 ---- set whichwrap& endfunction ! function Test_options() let caught = 'ok' try options *************** *** 29,35 **** close endfunction ! function! Test_path_keep_commas() " Test that changing 'path' keeps two commas. set path=foo,,bar set path-=bar --- 29,35 ---- close endfunction ! function Test_path_keep_commas() " Test that changing 'path' keeps two commas. set path=foo,,bar set path-=bar *************** *** 38,40 **** --- 38,48 ---- set path& endfunction + + func Test_signcolumn() + call assert_equal("auto", &signcolumn) + set signcolumn=yes + set signcolumn=no + call assert_fails('set signcolumn=nope') + endfunc + *** ../vim-7.4.2200/src/version.c 2016-08-12 16:29:03.351068377 +0200 --- src/version.c 2016-08-12 17:27:04.252079167 +0200 *************** *** 765,766 **** --- 765,768 ---- { /* Add new patch number below this line */ + /**/ + 2201, /**/ -- The Feynman problem solving Algorithm: 1) Write down the problem 2) Think real hard 3) Write down the answer /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///