Skip to content

Commit a08030c

Browse files
dkearnschrisbra
authored andcommitted
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 <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 2447131 commit a08030c

11 files changed

Lines changed: 11 additions & 32 deletions

File tree

runtime/doc/options.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*options.txt* For Vim version 9.1. Last change: 2025 Nov 09
1+
*options.txt* For Vim version 9.1. Last change: 2025 Nov 20
22

33

44
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|.
19911991
*'commentstring'* *'cms'* *E537*
19921992
'commentstring' 'cms' string (default "/* %s */")
19931993
local to buffer
1994-
{not available when compiled without the |+folding|
1995-
feature}
19961994
A template for a comment. The "%s" in the value is replaced with the
19971995
comment text, and should be padded with a space when possible.
19981996
Currently used to add markers for folding, see |fold-marker|. Also

runtime/doc/version9.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*version9.txt* For Vim version 9.1. Last change: 2025 Nov 09
1+
*version9.txt* For Vim version 9.1. Last change: 2025 Nov 20
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -41692,6 +41692,8 @@ Completion: ~
4169241692
- 'smartcase' applies to completion filtering
4169341693

4169441694
Options: ~
41695+
- 'commentstring' is now available in all builds and no longer requires the
41696+
|+folding| feature
4169541697
- the default for 'commentstring' contains whitespace padding to have
4169641698
automatic comments look nicer |comment-install|
4169741699
- 'completeopt' is now a |global-local| option.

runtime/optwin.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" These commands create the option window.
22
"
33
" Maintainer: The Vim Project <https://github.com/vim/vim>
4-
" Last Change: 2025 Oct 07
4+
" Last Change: 2025 Nov 20
55
" Former Maintainer: Bram Moolenaar <[email protected]>
66

77
" If there already is an option window, jump to that one.
@@ -860,6 +860,8 @@ call append("$", " \tset bs=" . &bs)
860860
call <SID>AddOption("comments", gettext("definition of what comment lines look like"))
861861
call append("$", "\t" .. s:local_to_buffer)
862862
call <SID>OptionL("com")
863+
call <SID>AddOption("commentstring", gettext("template for comments; used to put the marker in"))
864+
call <SID>OptionL("cms")
863865
call <SID>AddOption("formatoptions", gettext("list of flags that tell how automatic formatting works"))
864866
call append("$", "\t" .. s:local_to_buffer)
865867
call <SID>OptionL("fo")
@@ -1039,8 +1041,6 @@ if has("folding")
10391041
call <SID>AddOption("foldminlines", gettext("minimum number of screen lines for a fold to be closed"))
10401042
call append("$", "\t" .. s:local_to_window)
10411043
call <SID>OptionL("fml")
1042-
call <SID>AddOption("commentstring", gettext("template for comments; used to put the marker in"))
1043-
call <SID>OptionL("cms")
10441044
call <SID>AddOption("foldmethod", gettext("folding type: \"manual\", \"indent\", \"expr\", \"marker\",\n\"syntax\" or \"diff\""))
10451045
call append("$", "\t" .. s:local_to_window)
10461046
call <SID>OptionL("fdm")

src/buffer.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2476,9 +2476,7 @@ free_buf_options(
24762476
ga_clear(&buf->b_kmap_ga);
24772477
#endif
24782478
clear_string_option(&buf->b_p_com);
2479-
#ifdef FEAT_FOLDING
24802479
clear_string_option(&buf->b_p_cms);
2481-
#endif
24822480
clear_string_option(&buf->b_p_nf);
24832481
#ifdef FEAT_SYN_HL
24842482
clear_string_option(&buf->b_p_syn);

src/errors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,9 +1364,9 @@ EXTERN char e_illegal_character_after_chr[]
13641364
#ifdef FEAT_FOLDING
13651365
EXTERN char e_comma_required[]
13661366
INIT(= N_("E536: Comma required"));
1367+
#endif
13671368
EXTERN char e_commentstring_must_be_empty_or_contain_str[]
13681369
INIT(= N_("E537: 'commentstring' must be empty or contain %s"));
1369-
#endif
13701370
EXTERN char e_pattern_found_in_every_line_str[]
13711371
INIT(= N_("E538: Pattern found in every line: %s"));
13721372
EXTERN char e_illegal_character_str[]

src/option.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6866,9 +6866,7 @@ get_varp(struct vimoption *p)
68666866
case PV_CINSD: return (char_u *)&(curbuf->b_p_cinsd);
68676867
case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
68686868
case PV_COM: return (char_u *)&(curbuf->b_p_com);
6869-
#ifdef FEAT_FOLDING
68706869
case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
6871-
#endif
68726870
case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
68736871
#ifdef BACKSLASH_IN_FILENAME
68746872
case PV_CSL: return (char_u *)&(curbuf->b_p_csl);
@@ -7457,10 +7455,8 @@ buf_copy_options(buf_T *buf, int flags)
74577455
COPY_OPT_SCTX(buf, BV_SN);
74587456
buf->b_p_com = vim_strsave(p_com);
74597457
COPY_OPT_SCTX(buf, BV_COM);
7460-
#ifdef FEAT_FOLDING
74617458
buf->b_p_cms = vim_strsave(p_cms);
74627459
COPY_OPT_SCTX(buf, BV_CMS);
7463-
#endif
74647460
buf->b_p_fo = vim_strsave(p_fo);
74657461
COPY_OPT_SCTX(buf, BV_FO);
74667462
buf->b_p_flp = vim_strsave(p_flp);

src/option.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,7 @@ EXTERN char_u *p_cb; // 'clipboard'
510510
EXTERN char_u *p_cpm; // 'clipmethod'
511511
#endif
512512
EXTERN long p_ch; // 'cmdheight'
513-
#ifdef FEAT_FOLDING
514513
EXTERN char_u *p_cms; // 'commentstring'
515-
#endif
516514
EXTERN char_u *p_cpt; // 'complete'
517515
EXTERN long p_cto; // 'completetimeout'
518516
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
@@ -1191,9 +1189,7 @@ enum
11911189
, BV_CINSD
11921190
, BV_CINW
11931191
, BV_CM
1194-
#ifdef FEAT_FOLDING
11951192
, BV_CMS
1196-
#endif
11971193
, BV_COM
11981194
, BV_COT
11991195
, BV_CPT

src/optiondefs.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@
4848
#define PV_CINSD OPT_BUF(BV_CINSD)
4949
#define PV_CINW OPT_BUF(BV_CINW)
5050
#define PV_CM OPT_BOTH(OPT_BUF(BV_CM))
51-
#ifdef FEAT_FOLDING
52-
# define PV_CMS OPT_BUF(BV_CMS)
53-
#endif
51+
#define PV_CMS OPT_BUF(BV_CMS)
5452
#define PV_COM OPT_BUF(BV_COM)
5553
#define PV_COT OPT_BOTH(OPT_BUF(BV_COT))
5654
#define PV_CPT OPT_BUF(BV_CPT)
@@ -671,13 +669,8 @@ static struct vimoption options[] =
671669
(char_u *)0L}
672670
SCTX_INIT},
673671
{"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF,
674-
#ifdef FEAT_FOLDING
675672
(char_u *)&p_cms, PV_CMS, did_set_commentstring, NULL,
676673
{(char_u *)"/* %s */", (char_u *)0L}
677-
#else
678-
(char_u *)NULL, PV_NONE, NULL, NULL,
679-
{(char_u *)0L, (char_u *)0L}
680-
#endif
681674
SCTX_INIT},
682675
// P_PRI_MKRC isn't needed here, optval_default()
683676
// always returns TRUE for 'compatible'

src/optionstr.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,7 @@ check_buf_options(buf_T *buf)
307307
check_string_option(&buf->b_p_flp);
308308
check_string_option(&buf->b_p_isk);
309309
check_string_option(&buf->b_p_com);
310-
#ifdef FEAT_FOLDING
311310
check_string_option(&buf->b_p_cms);
312-
#endif
313311
check_string_option(&buf->b_p_nf);
314312
check_string_option(&buf->b_p_qe);
315313
#ifdef FEAT_SYN_HL
@@ -1581,7 +1579,6 @@ did_set_comments(optset_T *args)
15811579
return errmsg;
15821580
}
15831581

1584-
#if defined(FEAT_FOLDING)
15851582
/*
15861583
* The 'commentstring' option is changed.
15871584
*/
@@ -1595,7 +1592,6 @@ did_set_commentstring(optset_T *args)
15951592

15961593
return NULL;
15971594
}
1598-
#endif
15991595

16001596
/*
16011597
* Check if value for 'complete' is valid when 'complete' option is changed.

src/structs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3312,9 +3312,7 @@ struct file_buffer
33123312
char_u *b_p_cinsd; // 'cinscopedecls'
33133313
char_u *b_p_cinw; // 'cinwords'
33143314
char_u *b_p_com; // 'comments'
3315-
#ifdef FEAT_FOLDING
33163315
char_u *b_p_cms; // 'commentstring'
3317-
#endif
33183316
char_u *b_p_cot; // 'completeopt' local value
33193317
unsigned b_cot_flags; // flags for 'completeopt'
33203318
char_u *b_p_cpt; // 'complete'

0 commit comments

Comments
 (0)