mirror of
https://github.com/neovim/neovim.git
synced 2024-12-21 03:35:02 -07:00
vim-patch:8.2.0577: not all modifiers supported for :options (#18952)
Problem: Not all modifiers supported for :options.
Solution: Use all cmdmod.split flags. (closes vim/vim#4401)
7a1637f4c0
Cherry-pick Test_options_command() change from patch 8.2.0540
This commit is contained in:
parent
837360868b
commit
e13c36e312
@ -1637,10 +1637,13 @@ void ex_compiler(exarg_T *eap)
|
|||||||
/// ":options"
|
/// ":options"
|
||||||
void ex_options(exarg_T *eap)
|
void ex_options(exarg_T *eap)
|
||||||
{
|
{
|
||||||
os_setenv("OPTWIN_CMD", cmdmod.tab ? "tab" : "", 1);
|
char buf[500];
|
||||||
os_setenv("OPTWIN_CMD",
|
bool multi_mods = 0;
|
||||||
cmdmod.tab ? "tab" :
|
|
||||||
(cmdmod.split & WSP_VERT) ? "vert" : "", 1);
|
buf[0] = NUL;
|
||||||
|
(void)add_win_cmd_modifers(buf, &multi_mods);
|
||||||
|
|
||||||
|
os_setenv("OPTWIN_CMD", buf, 1);
|
||||||
cmd_source(SYS_OPTWIN_FILE, NULL);
|
cmd_source(SYS_OPTWIN_FILE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6555,24 +6555,47 @@ static size_t uc_check_code(char *code, size_t len, char *buf, ucmd_T *cmd, exar
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add modifiers from "cmdmod.split" to "buf". Set "multi_mods" when one was
|
||||||
|
/// added.
|
||||||
|
///
|
||||||
|
/// @return the number of bytes added
|
||||||
|
size_t add_win_cmd_modifers(char *buf, bool *multi_mods)
|
||||||
|
{
|
||||||
|
size_t result = 0;
|
||||||
|
|
||||||
|
// :aboveleft and :leftabove
|
||||||
|
if (cmdmod.split & WSP_ABOVE) {
|
||||||
|
result += add_cmd_modifier(buf, "aboveleft", multi_mods);
|
||||||
|
}
|
||||||
|
// :belowright and :rightbelow
|
||||||
|
if (cmdmod.split & WSP_BELOW) {
|
||||||
|
result += add_cmd_modifier(buf, "belowright", multi_mods);
|
||||||
|
}
|
||||||
|
// :botright
|
||||||
|
if (cmdmod.split & WSP_BOT) {
|
||||||
|
result += add_cmd_modifier(buf, "botright", multi_mods);
|
||||||
|
}
|
||||||
|
|
||||||
|
// :tab
|
||||||
|
if (cmdmod.tab > 0) {
|
||||||
|
result += add_cmd_modifier(buf, "tab", multi_mods);
|
||||||
|
}
|
||||||
|
// :topleft
|
||||||
|
if (cmdmod.split & WSP_TOP) {
|
||||||
|
result += add_cmd_modifier(buf, "topleft", multi_mods);
|
||||||
|
}
|
||||||
|
// :vertical
|
||||||
|
if (cmdmod.split & WSP_VERT) {
|
||||||
|
result += add_cmd_modifier(buf, "vertical", multi_mods);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
size_t uc_mods(char *buf)
|
size_t uc_mods(char *buf)
|
||||||
{
|
{
|
||||||
size_t result = 0;
|
size_t result = 0;
|
||||||
bool multi_mods = false;
|
bool multi_mods = false;
|
||||||
|
|
||||||
// :aboveleft and :leftabove
|
|
||||||
if (cmdmod.split & WSP_ABOVE) {
|
|
||||||
result += add_cmd_modifier(buf, "aboveleft", &multi_mods);
|
|
||||||
}
|
|
||||||
// :belowright and :rightbelow
|
|
||||||
if (cmdmod.split & WSP_BELOW) {
|
|
||||||
result += add_cmd_modifier(buf, "belowright", &multi_mods);
|
|
||||||
}
|
|
||||||
// :botright
|
|
||||||
if (cmdmod.split & WSP_BOT) {
|
|
||||||
result += add_cmd_modifier(buf, "botright", &multi_mods);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool *set;
|
bool *set;
|
||||||
char *name;
|
char *name;
|
||||||
@ -6602,14 +6625,6 @@ size_t uc_mods(char *buf)
|
|||||||
if (msg_silent > 0) {
|
if (msg_silent > 0) {
|
||||||
result += add_cmd_modifier(buf, emsg_silent > 0 ? "silent!" : "silent", &multi_mods);
|
result += add_cmd_modifier(buf, emsg_silent > 0 ? "silent!" : "silent", &multi_mods);
|
||||||
}
|
}
|
||||||
// :tab
|
|
||||||
if (cmdmod.tab > 0) {
|
|
||||||
result += add_cmd_modifier(buf, "tab", &multi_mods);
|
|
||||||
}
|
|
||||||
// :topleft
|
|
||||||
if (cmdmod.split & WSP_TOP) {
|
|
||||||
result += add_cmd_modifier(buf, "topleft", &multi_mods);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(vim): How to support :unsilent?
|
// TODO(vim): How to support :unsilent?
|
||||||
|
|
||||||
@ -6617,10 +6632,8 @@ size_t uc_mods(char *buf)
|
|||||||
if (p_verbose > 0) {
|
if (p_verbose > 0) {
|
||||||
result += add_cmd_modifier(buf, "verbose", &multi_mods);
|
result += add_cmd_modifier(buf, "verbose", &multi_mods);
|
||||||
}
|
}
|
||||||
// :vertical
|
// flags from cmdmod.split
|
||||||
if (cmdmod.split & WSP_VERT) {
|
result += add_win_cmd_modifers(buf, &multi_mods);
|
||||||
result += add_cmd_modifier(buf, "vertical", &multi_mods);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,19 @@ func Test_options_command()
|
|||||||
" close option-window
|
" close option-window
|
||||||
close
|
close
|
||||||
|
|
||||||
|
" Open the option-window at the top.
|
||||||
|
set splitbelow
|
||||||
|
topleft options
|
||||||
|
call assert_equal(1, winnr())
|
||||||
|
close
|
||||||
|
|
||||||
|
" Open the option-window at the bottom.
|
||||||
|
set nosplitbelow
|
||||||
|
botright options
|
||||||
|
call assert_equal(winnr('$'), winnr())
|
||||||
|
close
|
||||||
|
set splitbelow&
|
||||||
|
|
||||||
" Open the option-window in a new tab.
|
" Open the option-window in a new tab.
|
||||||
tab options
|
tab options
|
||||||
" Check if the option-window is opened in a tab.
|
" Check if the option-window is opened in a tab.
|
||||||
@ -105,9 +118,15 @@ func Test_options_command()
|
|||||||
call assert_notequal('option-window', bufname(''))
|
call assert_notequal('option-window', bufname(''))
|
||||||
normal gt
|
normal gt
|
||||||
call assert_equal('option-window', bufname(''))
|
call assert_equal('option-window', bufname(''))
|
||||||
|
|
||||||
" close option-window
|
" close option-window
|
||||||
close
|
close
|
||||||
|
|
||||||
|
" Open the options window browse
|
||||||
|
if has('browse')
|
||||||
|
browse set
|
||||||
|
call assert_equal('option-window', bufname(''))
|
||||||
|
close
|
||||||
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_path_keep_commas()
|
func Test_path_keep_commas()
|
||||||
|
@ -4,63 +4,95 @@
|
|||||||
function Test_cmdmods()
|
function Test_cmdmods()
|
||||||
let g:mods = ''
|
let g:mods = ''
|
||||||
|
|
||||||
command! -nargs=* MyCmd let g:mods .= '<mods> '
|
command! -nargs=* MyCmd let g:mods = '<mods>'
|
||||||
|
|
||||||
MyCmd
|
MyCmd
|
||||||
|
call assert_equal('', g:mods)
|
||||||
aboveleft MyCmd
|
aboveleft MyCmd
|
||||||
|
call assert_equal('aboveleft', g:mods)
|
||||||
abo MyCmd
|
abo MyCmd
|
||||||
|
call assert_equal('aboveleft', g:mods)
|
||||||
belowright MyCmd
|
belowright MyCmd
|
||||||
|
call assert_equal('belowright', g:mods)
|
||||||
bel MyCmd
|
bel MyCmd
|
||||||
|
call assert_equal('belowright', g:mods)
|
||||||
botright MyCmd
|
botright MyCmd
|
||||||
|
call assert_equal('botright', g:mods)
|
||||||
bo MyCmd
|
bo MyCmd
|
||||||
|
call assert_equal('botright', g:mods)
|
||||||
browse MyCmd
|
browse MyCmd
|
||||||
|
call assert_equal('browse', g:mods)
|
||||||
bro MyCmd
|
bro MyCmd
|
||||||
|
call assert_equal('browse', g:mods)
|
||||||
confirm MyCmd
|
confirm MyCmd
|
||||||
|
call assert_equal('confirm', g:mods)
|
||||||
conf MyCmd
|
conf MyCmd
|
||||||
|
call assert_equal('confirm', g:mods)
|
||||||
hide MyCmd
|
hide MyCmd
|
||||||
|
call assert_equal('hide', g:mods)
|
||||||
hid MyCmd
|
hid MyCmd
|
||||||
|
call assert_equal('hide', g:mods)
|
||||||
keepalt MyCmd
|
keepalt MyCmd
|
||||||
|
call assert_equal('keepalt', g:mods)
|
||||||
keepa MyCmd
|
keepa MyCmd
|
||||||
|
call assert_equal('keepalt', g:mods)
|
||||||
keepjumps MyCmd
|
keepjumps MyCmd
|
||||||
|
call assert_equal('keepjumps', g:mods)
|
||||||
keepj MyCmd
|
keepj MyCmd
|
||||||
|
call assert_equal('keepjumps', g:mods)
|
||||||
keepmarks MyCmd
|
keepmarks MyCmd
|
||||||
|
call assert_equal('keepmarks', g:mods)
|
||||||
kee MyCmd
|
kee MyCmd
|
||||||
|
call assert_equal('keepmarks', g:mods)
|
||||||
keeppatterns MyCmd
|
keeppatterns MyCmd
|
||||||
|
call assert_equal('keeppatterns', g:mods)
|
||||||
keepp MyCmd
|
keepp MyCmd
|
||||||
|
call assert_equal('keeppatterns', g:mods)
|
||||||
leftabove MyCmd " results in :aboveleft
|
leftabove MyCmd " results in :aboveleft
|
||||||
|
call assert_equal('aboveleft', g:mods)
|
||||||
lefta MyCmd
|
lefta MyCmd
|
||||||
|
call assert_equal('aboveleft', g:mods)
|
||||||
lockmarks MyCmd
|
lockmarks MyCmd
|
||||||
|
call assert_equal('lockmarks', g:mods)
|
||||||
loc MyCmd
|
loc MyCmd
|
||||||
|
call assert_equal('lockmarks', g:mods)
|
||||||
" noautocmd MyCmd
|
" noautocmd MyCmd
|
||||||
noswapfile MyCmd
|
noswapfile MyCmd
|
||||||
|
call assert_equal('noswapfile', g:mods)
|
||||||
nos MyCmd
|
nos MyCmd
|
||||||
|
call assert_equal('noswapfile', g:mods)
|
||||||
rightbelow MyCmd " results in :belowright
|
rightbelow MyCmd " results in :belowright
|
||||||
|
call assert_equal('belowright', g:mods)
|
||||||
rightb MyCmd
|
rightb MyCmd
|
||||||
|
call assert_equal('belowright', g:mods)
|
||||||
" sandbox MyCmd
|
" sandbox MyCmd
|
||||||
silent MyCmd
|
silent MyCmd
|
||||||
|
call assert_equal('silent', g:mods)
|
||||||
sil MyCmd
|
sil MyCmd
|
||||||
|
call assert_equal('silent', g:mods)
|
||||||
tab MyCmd
|
tab MyCmd
|
||||||
|
call assert_equal('tab', g:mods)
|
||||||
topleft MyCmd
|
topleft MyCmd
|
||||||
|
call assert_equal('topleft', g:mods)
|
||||||
to MyCmd
|
to MyCmd
|
||||||
|
call assert_equal('topleft', g:mods)
|
||||||
" unsilent MyCmd
|
" unsilent MyCmd
|
||||||
verbose MyCmd
|
verbose MyCmd
|
||||||
|
call assert_equal('verbose', g:mods)
|
||||||
verb MyCmd
|
verb MyCmd
|
||||||
|
call assert_equal('verbose', g:mods)
|
||||||
vertical MyCmd
|
vertical MyCmd
|
||||||
|
call assert_equal('vertical', g:mods)
|
||||||
vert MyCmd
|
vert MyCmd
|
||||||
|
call assert_equal('vertical', g:mods)
|
||||||
|
|
||||||
aboveleft belowright botright browse confirm hide keepalt keepjumps
|
aboveleft belowright botright browse confirm hide keepalt keepjumps
|
||||||
\ keepmarks keeppatterns lockmarks noswapfile silent tab
|
\ keepmarks keeppatterns lockmarks noswapfile silent tab
|
||||||
\ topleft verbose vertical MyCmd
|
\ topleft verbose vertical MyCmd
|
||||||
|
|
||||||
call assert_equal(' aboveleft aboveleft belowright belowright botright ' .
|
call assert_equal('browse confirm hide keepalt keepjumps ' .
|
||||||
\ 'botright browse browse confirm confirm hide hide ' .
|
\ 'keepmarks keeppatterns lockmarks noswapfile silent ' .
|
||||||
\ 'keepalt keepalt keepjumps keepjumps keepmarks keepmarks ' .
|
\ 'verbose aboveleft belowright botright tab topleft vertical', g:mods)
|
||||||
\ 'keeppatterns keeppatterns aboveleft aboveleft lockmarks lockmarks noswapfile ' .
|
|
||||||
\ 'noswapfile belowright belowright silent silent tab topleft topleft verbose verbose ' .
|
|
||||||
\ 'vertical vertical ' .
|
|
||||||
\ 'aboveleft belowright botright browse confirm hide keepalt keepjumps ' .
|
|
||||||
\ 'keepmarks keeppatterns lockmarks noswapfile silent tab topleft ' .
|
|
||||||
\ 'verbose vertical ', g:mods)
|
|
||||||
|
|
||||||
let g:mods = ''
|
let g:mods = ''
|
||||||
command! -nargs=* MyQCmd let g:mods .= '<q-mods> '
|
command! -nargs=* MyQCmd let g:mods .= '<q-mods> '
|
||||||
|
Loading…
Reference in New Issue
Block a user