To: vim_dev@googlegroups.com Subject: Patch 8.2.0577 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0577 Problem: Not all modifiers supported for :options. Solution: Use all cmdmod.split flags. (closes #4401) Files: src/usercmd.c, src/proto/usercmd.pro, src/scriptfile.c, src/testdir/test_options.vim, src/testdir/test_usercommands.vim *** ../vim-8.2.0576/src/usercmd.c 2019-12-29 23:04:20.294639884 +0100 --- src/usercmd.c 2020-04-13 20:33:05.165345219 +0200 *************** *** 1234,1239 **** --- 1234,1270 ---- } /* + * 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_u *buf, int *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; + } + + /* * Check for a <> code in a user command. * "code" points to the '<'. "len" the length of the <> (inclusive). * "buf" is where the result is to be added. *************** *** 1451,1466 **** *buf = '\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); - // the modifiers that are simple flags for (i = 0; mod_entries[i].varp != NULL; ++i) if (*mod_entries[i].varp) --- 1482,1487 ---- *************** *** 1475,1493 **** if (msg_silent > 0) 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: How to support :unsilent? // :verbose if (p_verbose > 0) result += add_cmd_modifier(buf, "verbose", &multi_mods); ! // :vertical ! if (cmdmod.split & WSP_VERT) ! result += add_cmd_modifier(buf, "vertical", &multi_mods); if (quote && buf != NULL) { buf += result - 2; --- 1496,1507 ---- if (msg_silent > 0) result += add_cmd_modifier(buf, emsg_silent > 0 ? "silent!" : "silent", &multi_mods); // TODO: How to support :unsilent? // :verbose if (p_verbose > 0) result += add_cmd_modifier(buf, "verbose", &multi_mods); ! // flags from cmdmod.split ! result += add_win_cmd_modifers(buf, &multi_mods); if (quote && buf != NULL) { buf += result - 2; *** ../vim-8.2.0576/src/proto/usercmd.pro 2019-12-12 12:55:36.000000000 +0100 --- src/proto/usercmd.pro 2020-04-13 20:33:09.173334462 +0200 *************** *** 14,18 **** --- 14,19 ---- void ex_comclear(exarg_T *eap); void uc_clear(garray_T *gap); void ex_delcommand(exarg_T *eap); + size_t add_win_cmd_modifers(char_u *buf, int *multi_mods); void do_ucmd(exarg_T *eap); /* vim: set ft=c : */ *** ../vim-8.2.0576/src/scriptfile.c 2020-03-28 19:41:29.595765241 +0100 --- src/scriptfile.c 2020-04-13 20:32:31.353436133 +0200 *************** *** 967,975 **** ex_options( exarg_T *eap UNUSED) { ! vim_setenv((char_u *)"OPTWIN_CMD", ! (char_u *)(cmdmod.tab ? "tab" ! : (cmdmod.split & WSP_VERT) ? "vert" : "")); cmd_source((char_u *)SYS_OPTWIN_FILE, NULL); } #endif --- 967,979 ---- ex_options( exarg_T *eap UNUSED) { ! char_u buf[500]; ! int multi_mods = 0; ! ! buf[0] = NUL; ! (void)add_win_cmd_modifers(buf, &multi_mods); ! ! vim_setenv((char_u *)"OPTWIN_CMD", buf); cmd_source((char_u *)SYS_OPTWIN_FILE, NULL); } #endif *** ../vim-8.2.0576/src/testdir/test_options.vim 2020-04-12 13:50:22.832171856 +0200 --- src/testdir/test_options.vim 2020-04-13 20:37:49.500592958 +0200 *************** *** 87,92 **** --- 87,105 ---- " close option-window 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. tab options " Check if the option-window is opened in a tab. *************** *** 94,100 **** call assert_notequal('option-window', bufname('')) normal gt call assert_equal('option-window', bufname('')) - " close option-window close --- 107,112 ---- *** ../vim-8.2.0576/src/testdir/test_usercommands.vim 2020-03-20 18:20:47.080975621 +0100 --- src/testdir/test_usercommands.vim 2020-04-13 20:50:39.198718145 +0200 *************** *** 4,66 **** function Test_cmdmods() let g:mods = '' ! command! -nargs=* MyCmd let g:mods .= ' ' MyCmd aboveleft MyCmd abo MyCmd belowright MyCmd bel MyCmd botright MyCmd bo MyCmd browse MyCmd bro MyCmd confirm MyCmd conf MyCmd hide MyCmd hid MyCmd keepalt MyCmd keepa MyCmd keepjumps MyCmd keepj MyCmd keepmarks MyCmd kee MyCmd keeppatterns MyCmd keepp MyCmd leftabove MyCmd " results in :aboveleft lefta MyCmd lockmarks MyCmd loc MyCmd " noautocmd MyCmd noswapfile MyCmd nos MyCmd rightbelow MyCmd " results in :belowright rightb MyCmd " sandbox MyCmd silent MyCmd sil MyCmd tab MyCmd topleft MyCmd to MyCmd " unsilent MyCmd verbose MyCmd verb MyCmd vertical MyCmd vert MyCmd aboveleft belowright botright browse confirm hide keepalt keepjumps \ keepmarks keeppatterns lockmarks noswapfile silent tab \ topleft verbose vertical MyCmd ! call assert_equal(' aboveleft aboveleft belowright belowright botright ' . ! \ 'botright browse browse confirm confirm hide hide ' . ! \ 'keepalt keepalt keepjumps keepjumps keepmarks keepmarks ' . ! \ '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 = '' command! -nargs=* MyQCmd let g:mods .= ' ' --- 4,98 ---- function Test_cmdmods() let g:mods = '' ! command! -nargs=* MyCmd let g:mods = '' MyCmd + call assert_equal('', g:mods) aboveleft MyCmd + call assert_equal('aboveleft', g:mods) abo MyCmd + call assert_equal('aboveleft', g:mods) belowright MyCmd + call assert_equal('belowright', g:mods) bel MyCmd + call assert_equal('belowright', g:mods) botright MyCmd + call assert_equal('botright', g:mods) bo MyCmd + call assert_equal('botright', g:mods) browse MyCmd + call assert_equal('browse', g:mods) bro MyCmd + call assert_equal('browse', g:mods) confirm MyCmd + call assert_equal('confirm', g:mods) conf MyCmd + call assert_equal('confirm', g:mods) hide MyCmd + call assert_equal('hide', g:mods) hid MyCmd + call assert_equal('hide', g:mods) keepalt MyCmd + call assert_equal('keepalt', g:mods) keepa MyCmd + call assert_equal('keepalt', g:mods) keepjumps MyCmd + call assert_equal('keepjumps', g:mods) keepj MyCmd + call assert_equal('keepjumps', g:mods) keepmarks MyCmd + call assert_equal('keepmarks', g:mods) kee MyCmd + call assert_equal('keepmarks', g:mods) keeppatterns MyCmd + call assert_equal('keeppatterns', g:mods) keepp MyCmd + call assert_equal('keeppatterns', g:mods) leftabove MyCmd " results in :aboveleft + call assert_equal('aboveleft', g:mods) lefta MyCmd + call assert_equal('aboveleft', g:mods) lockmarks MyCmd + call assert_equal('lockmarks', g:mods) loc MyCmd + call assert_equal('lockmarks', g:mods) " noautocmd MyCmd noswapfile MyCmd + call assert_equal('noswapfile', g:mods) nos MyCmd + call assert_equal('noswapfile', g:mods) rightbelow MyCmd " results in :belowright + call assert_equal('belowright', g:mods) rightb MyCmd + call assert_equal('belowright', g:mods) " sandbox MyCmd silent MyCmd + call assert_equal('silent', g:mods) sil MyCmd + call assert_equal('silent', g:mods) tab MyCmd + call assert_equal('tab', g:mods) topleft MyCmd + call assert_equal('topleft', g:mods) to MyCmd + call assert_equal('topleft', g:mods) " unsilent MyCmd verbose MyCmd + call assert_equal('verbose', g:mods) verb MyCmd + call assert_equal('verbose', g:mods) vertical MyCmd + call assert_equal('vertical', g:mods) vert MyCmd + call assert_equal('vertical', g:mods) aboveleft belowright botright browse confirm hide keepalt keepjumps \ keepmarks keeppatterns lockmarks noswapfile silent tab \ topleft verbose vertical MyCmd ! call assert_equal('browse confirm hide keepalt keepjumps ' . ! \ 'keepmarks keeppatterns lockmarks noswapfile silent ' . ! \ 'verbose aboveleft belowright botright tab topleft vertical', g:mods) let g:mods = '' command! -nargs=* MyQCmd let g:mods .= ' ' *** ../vim-8.2.0576/src/version.c 2020-04-13 19:55:47.567369413 +0200 --- src/version.c 2020-04-13 21:15:52.059354411 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 577, /**/ -- I used to wonder about the meaning of life. But I looked it up in the dictionary under "L" and there it was - the meaning of life. It was less than I expected. - Dogbert /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///