From e13c36e312a9128f5c2ffd5a444939efc43bc0b5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Jun 2022 22:04:39 +0800 Subject: 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) https://github.com/vim/vim/commit/7a1637f4c00ac3d0cbf894803ada1586a1717470 Cherry-pick Test_options_command() change from patch 8.2.0540 --- src/nvim/ex_docmd.c | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 8c6a32ee01..bbac74fc55 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -6555,23 +6555,46 @@ static size_t uc_check_code(char *code, size_t len, char *buf, ucmd_T *cmd, exar return result; } -size_t uc_mods(char *buf) +/// 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; - bool multi_mods = false; // :aboveleft and :leftabove if (cmdmod.split & WSP_ABOVE) { - result += add_cmd_modifier(buf, "aboveleft", &multi_mods); + result += add_cmd_modifier(buf, "aboveleft", multi_mods); } // :belowright and :rightbelow if (cmdmod.split & WSP_BELOW) { - result += add_cmd_modifier(buf, "belowright", &multi_mods); + result += add_cmd_modifier(buf, "belowright", multi_mods); } // :botright if (cmdmod.split & WSP_BOT) { - result += add_cmd_modifier(buf, "botright", &multi_mods); + 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 result = 0; + bool multi_mods = false; typedef struct { bool *set; @@ -6602,14 +6625,6 @@ size_t uc_mods(char *buf) 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(vim): How to support :unsilent? @@ -6617,10 +6632,8 @@ size_t uc_mods(char *buf) 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); - } + // flags from cmdmod.split + result += add_win_cmd_modifers(buf, &multi_mods); return result; } -- cgit