patch 9.1.1924: 'commentstring' requires +folding feature

Problem:  'commentstring' requires the +folding feature but is used in
	  contexts other than folding.
Solution: Remove the +folding feature guards from 'commentstring' and
          make it available in all builds (Doug Kearns).

closes: #18731

Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Doug Kearns
2025-11-20 21:16:48 +00:00
committed by Christian Brabandt
parent 2447131e00
commit a08030c9f7
11 changed files with 11 additions and 32 deletions

View File

@ -1,4 +1,4 @@
*options.txt* For Vim version 9.1. Last change: 2025 Nov 09
*options.txt* For Vim version 9.1. Last change: 2025 Nov 20
VIM REFERENCE MANUAL by Bram Moolenaar
@ -1991,8 +1991,6 @@ A jump table for the options with a short description can be found at |Q_op|.
*'commentstring'* *'cms'* *E537*
'commentstring' 'cms' string (default "/* %s */")
local to buffer
{not available when compiled without the |+folding|
feature}
A template for a comment. The "%s" in the value is replaced with the
comment text, and should be padded with a space when possible.
Currently used to add markers for folding, see |fold-marker|. Also

View File

@ -1,4 +1,4 @@
*version9.txt* For Vim version 9.1. Last change: 2025 Nov 09
*version9.txt* For Vim version 9.1. Last change: 2025 Nov 20
VIM REFERENCE MANUAL by Bram Moolenaar
@ -41692,6 +41692,8 @@ Completion: ~
- 'smartcase' applies to completion filtering
Options: ~
- 'commentstring' is now available in all builds and no longer requires the
|+folding| feature
- the default for 'commentstring' contains whitespace padding to have
automatic comments look nicer |comment-install|
- 'completeopt' is now a |global-local| option.

View File

@ -1,7 +1,7 @@
" These commands create the option window.
"
" Maintainer: The Vim Project <https://github.com/vim/vim>
" Last Change: 2025 Oct 07
" Last Change: 2025 Nov 20
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" If there already is an option window, jump to that one.
@ -860,6 +860,8 @@ call append("$", " \tset bs=" . &bs)
call <SID>AddOption("comments", gettext("definition of what comment lines look like"))
call append("$", "\t" .. s:local_to_buffer)
call <SID>OptionL("com")
call <SID>AddOption("commentstring", gettext("template for comments; used to put the marker in"))
call <SID>OptionL("cms")
call <SID>AddOption("formatoptions", gettext("list of flags that tell how automatic formatting works"))
call append("$", "\t" .. s:local_to_buffer)
call <SID>OptionL("fo")
@ -1039,8 +1041,6 @@ if has("folding")
call <SID>AddOption("foldminlines", gettext("minimum number of screen lines for a fold to be closed"))
call append("$", "\t" .. s:local_to_window)
call <SID>OptionL("fml")
call <SID>AddOption("commentstring", gettext("template for comments; used to put the marker in"))
call <SID>OptionL("cms")
call <SID>AddOption("foldmethod", gettext("folding type: \"manual\", \"indent\", \"expr\", \"marker\",\n\"syntax\" or \"diff\""))
call append("$", "\t" .. s:local_to_window)
call <SID>OptionL("fdm")

View File

@ -2476,9 +2476,7 @@ free_buf_options(
ga_clear(&buf->b_kmap_ga);
#endif
clear_string_option(&buf->b_p_com);
#ifdef FEAT_FOLDING
clear_string_option(&buf->b_p_cms);
#endif
clear_string_option(&buf->b_p_nf);
#ifdef FEAT_SYN_HL
clear_string_option(&buf->b_p_syn);

View File

@ -1364,9 +1364,9 @@ EXTERN char e_illegal_character_after_chr[]
#ifdef FEAT_FOLDING
EXTERN char e_comma_required[]
INIT(= N_("E536: Comma required"));
#endif
EXTERN char e_commentstring_must_be_empty_or_contain_str[]
INIT(= N_("E537: 'commentstring' must be empty or contain %s"));
#endif
EXTERN char e_pattern_found_in_every_line_str[]
INIT(= N_("E538: Pattern found in every line: %s"));
EXTERN char e_illegal_character_str[]

View File

@ -6866,9 +6866,7 @@ get_varp(struct vimoption *p)
case PV_CINSD: return (char_u *)&(curbuf->b_p_cinsd);
case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
case PV_COM: return (char_u *)&(curbuf->b_p_com);
#ifdef FEAT_FOLDING
case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
#endif
case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
#ifdef BACKSLASH_IN_FILENAME
case PV_CSL: return (char_u *)&(curbuf->b_p_csl);
@ -7457,10 +7455,8 @@ buf_copy_options(buf_T *buf, int flags)
COPY_OPT_SCTX(buf, BV_SN);
buf->b_p_com = vim_strsave(p_com);
COPY_OPT_SCTX(buf, BV_COM);
#ifdef FEAT_FOLDING
buf->b_p_cms = vim_strsave(p_cms);
COPY_OPT_SCTX(buf, BV_CMS);
#endif
buf->b_p_fo = vim_strsave(p_fo);
COPY_OPT_SCTX(buf, BV_FO);
buf->b_p_flp = vim_strsave(p_flp);

View File

@ -510,9 +510,7 @@ EXTERN char_u *p_cb; // 'clipboard'
EXTERN char_u *p_cpm; // 'clipmethod'
#endif
EXTERN long p_ch; // 'cmdheight'
#ifdef FEAT_FOLDING
EXTERN char_u *p_cms; // 'commentstring'
#endif
EXTERN char_u *p_cpt; // 'complete'
EXTERN long p_cto; // 'completetimeout'
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
@ -1191,9 +1189,7 @@ enum
, BV_CINSD
, BV_CINW
, BV_CM
#ifdef FEAT_FOLDING
, BV_CMS
#endif
, BV_COM
, BV_COT
, BV_CPT

View File

@ -48,9 +48,7 @@
#define PV_CINSD OPT_BUF(BV_CINSD)
#define PV_CINW OPT_BUF(BV_CINW)
#define PV_CM OPT_BOTH(OPT_BUF(BV_CM))
#ifdef FEAT_FOLDING
#define PV_CMS OPT_BUF(BV_CMS)
#endif
#define PV_COM OPT_BUF(BV_COM)
#define PV_COT OPT_BOTH(OPT_BUF(BV_COT))
#define PV_CPT OPT_BUF(BV_CPT)
@ -671,13 +669,8 @@ static struct vimoption options[] =
(char_u *)0L}
SCTX_INIT},
{"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF,
#ifdef FEAT_FOLDING
(char_u *)&p_cms, PV_CMS, did_set_commentstring, NULL,
{(char_u *)"/* %s */", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
{(char_u *)0L, (char_u *)0L}
#endif
SCTX_INIT},
// P_PRI_MKRC isn't needed here, optval_default()
// always returns TRUE for 'compatible'

View File

@ -307,9 +307,7 @@ check_buf_options(buf_T *buf)
check_string_option(&buf->b_p_flp);
check_string_option(&buf->b_p_isk);
check_string_option(&buf->b_p_com);
#ifdef FEAT_FOLDING
check_string_option(&buf->b_p_cms);
#endif
check_string_option(&buf->b_p_nf);
check_string_option(&buf->b_p_qe);
#ifdef FEAT_SYN_HL
@ -1581,7 +1579,6 @@ did_set_comments(optset_T *args)
return errmsg;
}
#if defined(FEAT_FOLDING)
/*
* The 'commentstring' option is changed.
*/
@ -1595,7 +1592,6 @@ did_set_commentstring(optset_T *args)
return NULL;
}
#endif
/*
* Check if value for 'complete' is valid when 'complete' option is changed.

View File

@ -3312,9 +3312,7 @@ struct file_buffer
char_u *b_p_cinsd; // 'cinscopedecls'
char_u *b_p_cinw; // 'cinwords'
char_u *b_p_com; // 'comments'
#ifdef FEAT_FOLDING
char_u *b_p_cms; // 'commentstring'
#endif
char_u *b_p_cot; // 'completeopt' local value
unsigned b_cot_flags; // flags for 'completeopt'
char_u *b_p_cpt; // 'complete'

View File

@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1924,
/**/
1923,
/**/