vim-patch:8.2.0128: cannot list options one per line

Problem:    Cannot list options one per line.
Solution:   Use ":set!" to list one option per line.
6b915c0c0e
This commit is contained in:
zeertzjq 2022-01-20 14:34:24 +08:00
parent 431915fe6a
commit aa4eadd2be
6 changed files with 53 additions and 36 deletions

View File

@ -20,9 +20,13 @@ achieve special effects. These options come in three forms:
1. Setting options *set-option* *E764* 1. Setting options *set-option* *E764*
*:se* *:set* *:se* *:set*
:se[t] Show all options that differ from their default value. :se[t][!] Show all options that differ from their default value.
When [!] is present every option is on a separate
line.
:se[t] all Show all options. :se[t][!] all Show all options.
When [!] is present every option is on a separate
line.
*E518* *E519* *E518* *E519*
:se[t] {option}? Show value of {option}. :se[t] {option}? Show value of {option}.
@ -235,7 +239,7 @@ happens when the buffer is not loaded, but they are lost when the buffer is
wiped out |:bwipe|. wiped out |:bwipe|.
*:setl* *:setlocal* *:setl* *:setlocal*
:setl[ocal] ... Like ":set" but set only the value local to the :setl[ocal][!] ... Like ":set" but set only the value local to the
current buffer or window. Not all options have a current buffer or window. Not all options have a
local value. If the option does not have a local local value. If the option does not have a local
value the global value is set. value the global value is set.
@ -257,7 +261,7 @@ wiped out |:bwipe|.
{option}, so that the global value will be used. {option}, so that the global value will be used.
*:setg* *:setglobal* *:setg* *:setglobal*
:setg[lobal] ... Like ":set" but set only the global value for a local :setg[lobal][!] ... Like ":set" but set only the global value for a local
option without changing the local value. option without changing the local value.
When displaying an option, the global value is shown. When displaying an option, the global value is shown.
With the "all" argument: display global values for all With the "all" argument: display global values for all

View File

@ -2413,7 +2413,7 @@ module.cmds = {
}, },
{ {
command='set', command='set',
flags=bit.bor(TRLBAR, EXTRA, CMDWIN, SBOXOK), flags=bit.bor(BANG, TRLBAR, EXTRA, CMDWIN, SBOXOK),
addr_type='ADDR_NONE', addr_type='ADDR_NONE',
func='ex_set', func='ex_set',
}, },
@ -2425,13 +2425,13 @@ module.cmds = {
}, },
{ {
command='setglobal', command='setglobal',
flags=bit.bor(TRLBAR, EXTRA, CMDWIN, SBOXOK), flags=bit.bor(BANG, TRLBAR, EXTRA, CMDWIN, SBOXOK),
addr_type='ADDR_NONE', addr_type='ADDR_NONE',
func='ex_set', func='ex_set',
}, },
{ {
command='setlocal', command='setlocal',
flags=bit.bor(TRLBAR, EXTRA, CMDWIN, SBOXOK), flags=bit.bor(BANG, TRLBAR, EXTRA, CMDWIN, SBOXOK),
addr_type='ADDR_NONE', addr_type='ADDR_NONE',
func='ex_set', func='ex_set',
}, },

View File

@ -9600,18 +9600,6 @@ static void ex_digraphs(exarg_T *eap)
} }
} }
static void ex_set(exarg_T *eap)
{
int flags = 0;
if (eap->cmdidx == CMD_setlocal) {
flags = OPT_LOCAL;
} else if (eap->cmdidx == CMD_setglobal) {
flags = OPT_GLOBAL;
}
(void)do_set(eap->arg, flags);
}
void set_no_hlsearch(bool flag) void set_no_hlsearch(bool flag)
{ {
no_hlsearch = flag; no_hlsearch = flag;

View File

@ -281,7 +281,7 @@ typedef struct vimoption {
# include "options.generated.h" # include "options.generated.h"
#endif #endif
#define PARAM_COUNT ARRAY_SIZE(options) #define OPTION_COUNT ARRAY_SIZE(options)
static char *(p_ambw_values[]) = { "single", "double", NULL }; static char *(p_ambw_values[]) = { "single", "double", NULL };
static char *(p_bg_values[]) = { "light", "dark", NULL }; static char *(p_bg_values[]) = { "light", "dark", NULL };
@ -931,6 +931,21 @@ void set_title_defaults(void)
} }
} }
void ex_set(exarg_T *eap)
{
int flags = 0;
if (eap->cmdidx == CMD_setlocal) {
flags = OPT_LOCAL;
} else if (eap->cmdidx == CMD_setglobal) {
flags = OPT_GLOBAL;
}
if (eap->forceit) {
flags |= OPT_ONECOLUMN;
}
(void)do_set(eap->arg, flags);
}
/// Parse 'arg' for option settings. /// Parse 'arg' for option settings.
/// ///
/// 'arg' may be IObuff, but only when no errors can be present and option /// 'arg' may be IObuff, but only when no errors can be present and option
@ -5184,7 +5199,7 @@ static void showoptions(int all, int opt_flags)
#define INC 20 #define INC 20
#define GAP 3 #define GAP 3
vimoption_T **items = xmalloc(sizeof(vimoption_T *) * PARAM_COUNT); vimoption_T **items = xmalloc(sizeof(vimoption_T *) * OPTION_COUNT);
// Highlight title // Highlight title
if (opt_flags & OPT_GLOBAL) { if (opt_flags & OPT_GLOBAL) {
@ -5198,6 +5213,7 @@ static void showoptions(int all, int opt_flags)
// Do the loop two times: // Do the loop two times:
// 1. display the short items // 1. display the short items
// 2. display the long items (only strings and numbers) // 2. display the long items (only strings and numbers)
// When "opt_flags" has OPT_ONECOLUMN do everything in run 2.
for (run = 1; run <= 2 && !got_int; run++) { for (run = 1; run <= 2 && !got_int; run++) {
// collect the items in items[] // collect the items in items[]
item_count = 0; item_count = 0;
@ -5208,7 +5224,7 @@ static void showoptions(int all, int opt_flags)
} }
varp = NULL; varp = NULL;
if (opt_flags != 0) { if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) != 0) {
if (p->indir != PV_NONE) { if (p->indir != PV_NONE) {
varp = get_varp_scope(p, opt_flags); varp = get_varp_scope(p, opt_flags);
} }
@ -5217,8 +5233,10 @@ static void showoptions(int all, int opt_flags)
} }
if (varp != NULL if (varp != NULL
&& (all == 1 || (all == 0 && !optval_default(p, varp)))) { && (all == 1 || (all == 0 && !optval_default(p, varp)))) {
if (p->flags & P_BOOL) { if (opt_flags & OPT_ONECOLUMN) {
len = 1; // a toggle option fits always len = Columns;
} else if (p->flags & P_BOOL) {
len = 1; // a toggle option fits always
} else { } else {
option_value2string(p, opt_flags); option_value2string(p, opt_flags);
len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;

View File

@ -13,16 +13,16 @@
/// When OPT_GLOBAL and OPT_LOCAL are both missing, set both local and global /// When OPT_GLOBAL and OPT_LOCAL are both missing, set both local and global
/// values, get local value. /// values, get local value.
typedef enum { typedef enum {
OPT_FREE = 1, ///< Free old value if it was allocated. OPT_FREE = 0x01, ///< Free old value if it was allocated.
OPT_GLOBAL = 2, ///< Use global value. OPT_GLOBAL = 0x02, ///< Use global value.
OPT_LOCAL = 4, ///< Use local value. OPT_LOCAL = 0x04, ///< Use local value.
OPT_MODELINE = 8, ///< Option in modeline. OPT_MODELINE = 0x08, ///< Option in modeline.
OPT_WINONLY = 16, ///< Only set window-local options. OPT_WINONLY = 0x10, ///< Only set window-local options.
OPT_NOWIN = 32, ///< Dont set window-local options. OPT_NOWIN = 0x20, ///< Dont set window-local options.
OPT_ONECOLUMN = 64, ///< list options one per line OPT_ONECOLUMN = 0x40, ///< list options one per line
OPT_NO_REDRAW = 128, ///< ignore redraw flags on option OPT_NO_REDRAW = 0x80, ///< ignore redraw flags on option
OPT_SKIPRTP = 256, ///< "skiprtp" in 'sessionoptions' OPT_SKIPRTP = 0x100, ///< "skiprtp" in 'sessionoptions'
OPT_CLEAR = 512, ///< Clear local value of an option. OPT_CLEAR = 0x200, ///< Clear local value of an option.
} OptionFlags; } OptionFlags;
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS

View File

@ -51,7 +51,7 @@ func Test_wildoptions()
call assert_equal('tagfile', &wildoptions) call assert_equal('tagfile', &wildoptions)
endfunc endfunc
function! Test_options() func Test_options_command()
let caught = 'ok' let caught = 'ok'
try try
options options
@ -88,7 +88,7 @@ function! Test_options()
" close option-window " close option-window
close close
endfunction endfunc
function! Test_path_keep_commas() function! Test_path_keep_commas()
" Test that changing 'path' keeps two commas. " Test that changing 'path' keeps two commas.
@ -368,6 +368,13 @@ func Test_set_all()
set tw& iskeyword& splitbelow& set tw& iskeyword& splitbelow&
endfunc endfunc
func Test_set_one_column()
let out_mult = execute('set all')->split("\n")
let out_one = execute('set! all')->split("\n")
" one column should be two to four times as many lines
call assert_inrange(len(out_mult) * 2, len(out_mult) * 4, len(out_one))
endfunc
func Test_set_values() func Test_set_values()
" The file is only generated when running "make test" in the src directory. " The file is only generated when running "make test" in the src directory.
if filereadable('opt_test.vim') if filereadable('opt_test.vim')