0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 9.0.1379: functions for handling options are not ordered

Problem:    Functions for handling options are not ordered.
Solution:   Put functions in alphabetical order. (Yegappan Lakshmanan,
            closes #12101)
This commit is contained in:
Yegappan Lakshmanan
2023-03-04 19:57:32 +00:00
committed by Bram Moolenaar
parent c99cbf8f28
commit 5284b23e14
9 changed files with 1338 additions and 1320 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -2506,7 +2506,7 @@ static struct vimoption options[] =
#endif
SCTX_INIT},
{"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
(char_u *)&T_NAME, PV_NONE, NULL,
(char_u *)&T_NAME, PV_NONE, did_set_term,
{(char_u *)"", (char_u *)0L} SCTX_INIT},
{"termbidi", "tbidi", P_BOOL|P_VI_DEF,
#ifdef FEAT_ARABIC
@@ -2662,7 +2662,7 @@ static struct vimoption options[] =
(char_u *)&p_ttyscroll, PV_NONE, NULL,
{(char_u *)999L, (char_u *)0L} SCTX_INIT},
{"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
(char_u *)&T_NAME, PV_NONE, NULL,
(char_u *)&T_NAME, PV_NONE, did_set_term,
{(char_u *)"", (char_u *)0L} SCTX_INIT},
{"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
|P_VI_DEF,

View File

@@ -2247,8 +2247,7 @@ did_set_scrollopt(optset_T *args UNUSED)
char *
did_set_selection(optset_T *args UNUSED)
{
if (*p_sel == NUL
|| check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
if (*p_sel == NUL || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
return e_invalid_argument;
return NULL;
@@ -2398,7 +2397,7 @@ did_set_spelloptions(optset_T *args)
{
char_u **varp = (char_u **)args->os_varp;
if (**varp != NUL && STRCMP("camel", *varp) != 0)
if (**varp != NUL && STRCMP(*varp, "camel") != 0)
return e_invalid_argument;
return NULL;
@@ -2499,34 +2498,24 @@ did_set_tagcase(optset_T *args)
/*
* The 'term' option is changed.
*/
static char *
did_set_term(int *opt_idx, long_u *free_oldval)
char *
did_set_term(optset_T *args UNUSED)
{
char *errmsg = NULL;
if (T_NAME[0] == NUL)
errmsg = e_cannot_set_term_to_empty_string;
return e_cannot_set_term_to_empty_string;
#ifdef FEAT_GUI
else if (gui.in_use)
errmsg = e_cannot_change_term_in_GUI;
else if (term_is_gui(T_NAME))
errmsg = e_use_gui_to_start_GUI;
if (gui.in_use)
return e_cannot_change_term_in_GUI;
if (term_is_gui(T_NAME))
return e_use_gui_to_start_GUI;
#endif
else if (set_termname(T_NAME) == FAIL)
errmsg = e_not_found_in_termcap;
else
{
// Screen colors may have changed.
redraw_later_clear();
if (set_termname(T_NAME) == FAIL)
return e_not_found_in_termcap;
// Both 'term' and 'ttytype' point to T_NAME, only set the
// P_ALLOCED flag on 'term'.
*opt_idx = findoption((char_u *)"term");
if (*opt_idx >= 0)
*free_oldval = (get_option_flags(*opt_idx) & P_ALLOCED);
}
// Screen colors may have changed.
redraw_later_clear();
return errmsg;
return NULL;
}
/*
@@ -2604,8 +2593,7 @@ did_set_term_option(optset_T *args)
char *
did_set_termwinkey(optset_T *args UNUSED)
{
if (*curwin->w_p_twk != NUL
&& string_to_key(curwin->w_p_twk, TRUE) == 0)
if (*curwin->w_p_twk != NUL && string_to_key(curwin->w_p_twk, TRUE) == 0)
return e_invalid_argument;
return NULL;
@@ -2664,8 +2652,8 @@ did_set_titlestring(optset_T *args)
char *
did_set_toolbar(optset_T *args UNUSED)
{
if (opt_strings_flags(p_toolbar, p_toolbar_values,
&toolbar_flags, TRUE) != OK)
if (opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags,
TRUE) != OK)
return e_invalid_argument;
out_flush();
@@ -2971,8 +2959,7 @@ did_set_winaltkeys(optset_T *args UNUSED)
{
char *errmsg = NULL;
if (*p_wak == NUL
|| check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
if (*p_wak == NUL || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
errmsg = e_invalid_argument;
# ifdef FEAT_MENU
# if defined(FEAT_GUI_MOTIF)
@@ -3097,13 +3084,24 @@ did_set_string_option(
// need to set P_INSECURE
{
char *errmsg = NULL;
int restore_chartab = FALSE;
long_u free_oldval = (get_option_flags(opt_idx) & P_ALLOCED);
int value_changed = FALSE;
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
int did_swaptcap = FALSE;
#endif
opt_did_set_cb_T did_set_cb = get_option_did_set_cb(opt_idx);
optset_T args;
// 'ttytype' is an alias for 'term'. Both 'term' and 'ttytype' point to
// T_NAME. If 'term' or 'ttytype' is modified, then use the index for the
// 'term' option. Only set the P_ALLOCED flag on 'term'.
if (varp == &T_NAME)
{
opt_idx = findoption((char_u *)"term");
if (opt_idx >= 0)
{
free_oldval = (get_option_flags(opt_idx) & P_ALLOCED);
did_set_cb = get_option_did_set_cb(opt_idx);
}
}
CLEAR_FIELD(args);
// Disallow changing some options from secure mode
if ((secure
@@ -3117,9 +3115,6 @@ did_set_string_option(
errmsg = e_invalid_argument;
else if (did_set_cb != NULL)
{
optset_T args;
CLEAR_FIELD(args);
args.os_varp = (char_u *)varp;
args.os_idx = opt_idx;
args.os_flags = opt_flags;
@@ -3130,22 +3125,10 @@ did_set_string_option(
// the new option value.
errmsg = did_set_cb(&args);
// The 'filetype' and 'syntax' option callback functions may change
// the os_value_changed field.
value_changed = args.os_value_changed;
// The 'keymap', 'filetype' and 'syntax' option callback functions
// may change the os_value_checked field.
*value_checked = args.os_value_checked;
// The 'isident', 'iskeyword', 'isprint' and 'isfname' options may
// change the character table. On failure, this needs to be restored.
restore_chartab = args.os_restore_chartab;
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
// The 't_xxx' terminal options may swap the termcap entries.
did_swaptcap = args.os_did_swaptcap;
#endif
}
else if (varp == &T_NAME) // 'term'
errmsg = did_set_term(&opt_idx, &free_oldval);
// If an error is detected, restore the previous value.
if (errmsg != NULL)
@@ -3153,7 +3136,7 @@ did_set_string_option(
free_string_option(*varp);
*varp = oldval;
// When resetting some values, need to act on it.
if (restore_chartab)
if (args.os_restore_chartab)
(void)init_chartab();
if (varp == &p_hl)
(void)highlight_changed();
@@ -3188,10 +3171,10 @@ did_set_string_option(
// Trigger the autocommand only after setting the flags.
#ifdef FEAT_SYN_HL
if (varp == &(curbuf->b_p_syn))
do_syntax_autocmd(value_changed);
do_syntax_autocmd(args.os_value_changed);
#endif
else if (varp == &(curbuf->b_p_ft))
do_filetype_autocmd(varp, opt_flags, value_changed);
do_filetype_autocmd(varp, opt_flags, args.os_value_changed);
#ifdef FEAT_SPELL
if (varp == &(curwin->w_s->b_p_spl))
do_spelllang_source();
@@ -3252,7 +3235,7 @@ did_set_string_option(
}
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
if (did_swaptcap)
if (args.os_did_swaptcap)
{
set_termname((char_u *)"win32");
init_highlight(TRUE, FALSE);

View File

@@ -24,68 +24,69 @@ int valid_name(char_u *val, char *allowed);
void set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx);
sctx_T *get_option_sctx(char *name);
void set_term_option_sctx_idx(char *name, int opt_idx);
char *did_set_compatible(optset_T *args);
char *did_set_langremap(optset_T *args);
char *did_set_langnoremap(optset_T *args);
char *did_set_undofile(optset_T *args);
char *did_set_readonly(optset_T *args);
char *did_set_mousehide(optset_T *args);
char *did_set_modifiable(optset_T *args);
char *did_set_eof_eol_fixeol_bomb(optset_T *args);
char *did_set_binary(optset_T *args);
char *did_set_buflisted(optset_T *args);
char *did_set_swapfile(optset_T *args);
char *did_set_terse(optset_T *args);
char *did_set_paste(optset_T *args);
char *did_set_insertmode(optset_T *args);
char *did_set_ignorecase(optset_T *args);
char *did_set_hlsearch(optset_T *args);
char *did_set_scrollbind(optset_T *args);
char *did_set_previewwindow(optset_T *args);
char *did_set_smoothscroll(optset_T *args);
char *did_set_textmode(optset_T *args);
char *did_set_textauto(optset_T *args);
char *did_set_lisp(optset_T *args);
char *did_set_title_icon(optset_T *args);
char *did_set_modified(optset_T *args);
char *did_set_shellslash(optset_T *args);
char *did_set_wrap(optset_T *args);
char *did_set_equalalways(optset_T *args);
char *did_set_weirdinvert(optset_T *args);
char *did_set_arabic(optset_T *args);
char *did_set_autochdir(optset_T *args);
char *did_set_ballooneval(optset_T *args);
char *did_set_balloonevalterm(optset_T *args);
char *did_set_autochdir(optset_T *args);
char *did_set_binary(optset_T *args);
char *did_set_breakat(optset_T *args);
char *did_set_buflisted(optset_T *args);
char *did_set_cmdheight(optset_T *args);
char *did_set_compatible(optset_T *args);
char *did_set_conceallevel(optset_T *args);
char *did_set_diff(optset_T *args);
char *did_set_imdisable(optset_T *args);
char *did_set_spell(optset_T *args);
char *did_set_arabic(optset_T *args);
char *did_set_number_relativenumber(optset_T *args);
char *did_set_termguicolors(optset_T *args);
char *did_set_winheight_helpheight(optset_T *args);
char *did_set_winminheight(optset_T *args);
char *did_set_winwidth(optset_T *args);
char *did_set_winminwidth(optset_T *args);
char *did_set_laststatus(optset_T *args);
char *did_set_showtabline(optset_T *args);
char *did_set_linespace(optset_T *args);
char *did_set_eof_eol_fixeol_bomb(optset_T *args);
char *did_set_equalalways(optset_T *args);
char *did_set_foldcolumn(optset_T *args);
char *did_set_foldlevel(optset_T *args);
char *did_set_foldminlines(optset_T *args);
char *did_set_foldnestmax(optset_T *args);
char *did_set_foldcolumn(optset_T *args);
char *did_set_shiftwidth_tabstop(optset_T *args);
char *did_set_maxcombine(optset_T *args);
char *did_set_hlsearch(optset_T *args);
char *did_set_ignorecase(optset_T *args);
char *did_set_imdisable(optset_T *args);
char *did_set_iminsert(optset_T *args);
char *did_set_imstyle(optset_T *args);
char *did_set_window(optset_T *args);
char *did_set_imsearch(optset_T *args);
char *did_set_titlelen(optset_T *args);
char *did_set_cmdheight(optset_T *args);
char *did_set_updatecount(optset_T *args);
char *did_set_conceallevel(optset_T *args);
char *did_set_pyxversion(optset_T *args);
char *did_set_imstyle(optset_T *args);
char *did_set_insertmode(optset_T *args);
char *did_set_langnoremap(optset_T *args);
char *did_set_langremap(optset_T *args);
char *did_set_laststatus(optset_T *args);
char *did_set_linespace(optset_T *args);
char *did_set_lisp(optset_T *args);
char *did_set_maxcombine(optset_T *args);
char *did_set_modifiable(optset_T *args);
char *did_set_modified(optset_T *args);
char *did_set_mousehide(optset_T *args);
char *did_set_number_relativenumber(optset_T *args);
char *did_set_numberwidth(optset_T *args);
char *did_set_paste(optset_T *args);
char *did_set_previewwindow(optset_T *args);
char *did_set_pyxversion(optset_T *args);
char *did_set_readonly(optset_T *args);
char *did_set_scrollbind(optset_T *args);
char *did_set_shellslash(optset_T *args);
char *did_set_shiftwidth_tabstop(optset_T *args);
char *did_set_showtabline(optset_T *args);
char *did_set_smoothscroll(optset_T *args);
char *did_set_spell(optset_T *args);
char *did_set_swapfile(optset_T *args);
char *did_set_termguicolors(optset_T *args);
char *did_set_terse(optset_T *args);
char *did_set_textauto(optset_T *args);
char *did_set_textmode(optset_T *args);
char *did_set_textwidth(optset_T *args);
char *did_set_title_icon(optset_T *args);
char *did_set_titlelen(optset_T *args);
char *did_set_undofile(optset_T *args);
char *did_set_undolevels(optset_T *args);
char *did_set_updatecount(optset_T *args);
char *did_set_weirdinvert(optset_T *args);
char *did_set_window(optset_T *args);
char *did_set_winheight_helpheight(optset_T *args);
char *did_set_winminheight(optset_T *args);
char *did_set_winminwidth(optset_T *args);
char *did_set_winwidth(optset_T *args);
char *did_set_wrap(optset_T *args);
void check_redraw(long_u flags);
int findoption(char_u *arg);
getoption_T get_option_value(char_u *name, long *numval, char_u **stringval, int *flagsp, int scope);
@@ -135,7 +136,6 @@ void vimrc_found(char_u *fname, char_u *envname);
void change_compatible(int on);
int option_was_set(char_u *name);
int reset_option_was_set(char_u *name);
char *did_set_breakat(optset_T *args);
int can_bs(int what);
long get_scrolloff_value(void);
long get_sidescrolloff_value(void);

View File

@@ -100,6 +100,7 @@ char *did_set_swapsync(optset_T *args);
char *did_set_switchbuf(optset_T *args);
char *did_set_tabline(optset_T *args);
char *did_set_tagcase(optset_T *args);
char *did_set_term(optset_T *args);
char *did_set_term_option(optset_T *args);
char *did_set_termwinkey(optset_T *args);
char *did_set_termwinsize(optset_T *args);

View File

@@ -138,4 +138,32 @@ func Test_backspace_ctrl_u()
close!
endfunc
" Test for setting 'backspace' to a number value (for backward compatibility)
func Test_backspace_number_value()
new
set backspace=0
call setline(1, ['one two', 'three four'])
call cursor(2, 1)
exe "normal! A\<C-W>\<C-U>"
call assert_equal('three four', getline(2))
set backspace=1
exe "normal! A\<CR>five\<C-W>\<C-U>\<C-W>\<C-U>"
call assert_equal(['one two', 'three four'], getline(1, '$'))
set backspace=2
call cursor(2, 7)
exe "normal! ihalf\<C-U>"
call assert_equal('three four', getline(2))
set backspace=3
call cursor(2, 7)
exe "normal! ihalf\<C-U>"
call assert_equal('four', getline(2))
bw!
set backspace&
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -878,6 +878,13 @@ func Test_highlight_start_stop()
call assert_match("stop=^[[27h;^[[ r;", HighlightArgs('HlGrp2'))
hi HlGrp2 stop=NONE
call assert_notmatch("stop=", HighlightArgs('HlGrp2'))
set t_xy=^[foo;
set t_xz=^[bar;
hi HlGrp3 start=t_xy stop=t_xz
let d = hlget('HlGrp3')
call assert_equal('^[foo;', d[0].start)
call assert_equal('^[bar;', d[0].stop)
set t_xy= t_xz=
hi clear
endfunc

View File

@@ -375,6 +375,7 @@ func Test_python3_opt_reset_local_to_global()
\ ['include', 'ginc', 'linc', ''],
\ ['dict', 'gdict', 'ldict', ''],
\ ['thesaurus', 'gtsr', 'ltsr', ''],
\ ['thesaurusfunc', 'Gtsrfu', 'Ltsrfu', ''],
\ ['formatprg', 'gfprg', 'lfprg', ''],
\ ['errorformat', '%f:%l:%m', '%s-%l-%m', ''],
\ ['grepprg', 'ggprg', 'lgprg', ''],
@@ -408,9 +409,13 @@ func Test_python3_opt_reset_local_to_global()
" Set the global and window-local option values and then clear the
" window-local option value.
let wopts = [
\ ['fillchars', 'fold:>', 'fold:+', ''],
\ ['listchars', 'tab:>>', 'tab:--', ''],
\ ['scrolloff', 5, 10, -1],
\ ['showbreak', '>>', '++', ''],
\ ['sidescrolloff', 6, 12, -1],
\ ['statusline', '%<%f', '%<%F', '']]
\ ['statusline', '%<%f', '%<%F', ''],
\ ['virtualedit', 'block', 'insert', '']]
for opt in wopts
py3 << trim
pyopt = vim.bindeval("opt")

View File

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