To: vim_dev@googlegroups.com Subject: Patch 9.0.1520 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1520 Problem: Completion for option name includes all bool options. Solution: Do not recognize the "noinv" prefix. Prefix "no" or "inv" when appropriate. Files: src/option.c, src/structs.h, src/cmdexpand.c, src/testdir/test_options.vim *** ../vim-9.0.1519/src/option.c 2023-04-23 17:50:14.857935970 +0100 --- src/option.c 2023-05-06 22:10:20.622240975 +0100 *************** *** 7265,7275 **** if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0) { xp->xp_context = EXPAND_BOOL_SETTINGS; p += 2; } ! if (STRNCMP(p, "inv", 3) == 0) { xp->xp_context = EXPAND_BOOL_SETTINGS; p += 3; } xp->xp_pattern = arg = p; --- 7265,7277 ---- if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0) { xp->xp_context = EXPAND_BOOL_SETTINGS; + xp->xp_prefix = XP_PREFIX_NO; p += 2; } ! else if (STRNCMP(p, "inv", 3) == 0) { xp->xp_context = EXPAND_BOOL_SETTINGS; + xp->xp_prefix = XP_PREFIX_INV; p += 3; } xp->xp_pattern = arg = p; *************** *** 7528,7534 **** if (options[opt_idx].var == NULL) continue; if (xp->xp_context == EXPAND_BOOL_SETTINGS ! && !(options[opt_idx].flags & P_BOOL)) continue; is_term_opt = istermoption_idx(opt_idx); if (is_term_opt && num_normal > 0) --- 7530,7536 ---- if (options[opt_idx].var == NULL) continue; if (xp->xp_context == EXPAND_BOOL_SETTINGS ! && !(options[opt_idx].flags & P_BOOL)) continue; is_term_opt = istermoption_idx(opt_idx); if (is_term_opt && num_normal > 0) *************** *** 7600,7606 **** name_buf[4] = NUL; if (match_str(name_buf, regmatch, *matches, count, ! (loop == 0), fuzzy, fuzzystr, fuzmatch)) { if (loop == 0) num_term++; --- 7602,7608 ---- name_buf[4] = NUL; if (match_str(name_buf, regmatch, *matches, count, ! (loop == 0), fuzzy, fuzzystr, fuzmatch)) { if (loop == 0) num_term++; *** ../vim-9.0.1519/src/structs.h 2023-04-23 17:50:14.857935970 +0100 --- src/structs.h 2023-05-06 22:09:46.134233562 +0100 *************** *** 578,583 **** --- 578,589 ---- buffheader_T sr_old_redobuff; } save_redo_T; + typedef enum { + XP_PREFIX_NONE, // prefix not used + XP_PREFIX_NO, // "no" prefix for bool option + XP_PREFIX_INV, // "inv" prefix for bool option + } xp_prefix_T; + /* * used for completion on the command line */ *************** *** 586,591 **** --- 592,598 ---- char_u *xp_pattern; // start of item to expand int xp_context; // type of expansion int xp_pattern_len; // bytes in xp_pattern before cursor + xp_prefix_T xp_prefix; #if defined(FEAT_EVAL) char_u *xp_arg; // completion function sctx_T xp_script_ctx; // SCTX for completion function *** ../vim-9.0.1519/src/cmdexpand.c 2023-04-22 22:54:28.045802345 +0100 --- src/cmdexpand.c 2023-05-06 22:16:36.470896112 +0100 *************** *** 1012,1025 **** --- 1012,1042 ---- { len = 0; for (i = 0; i < xp->xp_numfiles; ++i) + { + if (i > 0) + { + if (xp->xp_prefix == XP_PREFIX_NO) + len += 2; // prefix "no" + else if (xp->xp_prefix == XP_PREFIX_INV) + len += 3; // prefix "inv" + } len += (long_u)STRLEN(xp->xp_files[i]) + 1; + } ss = alloc(len); if (ss != NULL) { *ss = NUL; for (i = 0; i < xp->xp_numfiles; ++i) { + if (i > 0) + { + if (xp->xp_prefix == XP_PREFIX_NO) + STRCAT(ss, "no"); + else if (xp->xp_prefix == XP_PREFIX_INV) + STRCAT(ss, "inv"); + } STRCAT(ss, xp->xp_files[i]); + if (i != xp->xp_numfiles - 1) STRCAT(ss, (options & WILD_USE_NL) ? "\n" : " "); } *************** *** 1044,1049 **** --- 1061,1067 ---- { CLEAR_POINTER(xp); xp->xp_backslash = XP_BS_NONE; + xp->xp_prefix = XP_PREFIX_NONE; xp->xp_numfiles = -1; } *** ../vim-9.0.1519/src/testdir/test_options.vim 2023-03-06 08:09:58.951487769 +0000 --- src/testdir/test_options.vim 2023-05-06 22:19:23.259103167 +0100 *************** *** 278,290 **** call feedkeys(":setglobal di\\\"\", 'tx') call assert_equal('"setglobal dictionary diff diffexpr diffopt digraph directory display', @:) ! " Expand boolean options. When doing :set no ! " vim displays the options names without "no" but completion uses "no...". call feedkeys(":set nodi\\\"\", 'tx') ! call assert_equal('"set nodiff digraph', @:) call feedkeys(":set invdi\\\"\", 'tx') ! call assert_equal('"set invdiff digraph', @:) " Expand abbreviation of options. call feedkeys(":set ts\\\"\", 'tx') --- 278,294 ---- call feedkeys(":setglobal di\\\"\", 'tx') call assert_equal('"setglobal dictionary diff diffexpr diffopt digraph directory display', @:) ! " Expand boolean options. When doing :set no Vim prefixes the option ! " names with "no". call feedkeys(":set nodi\\\"\", 'tx') ! call assert_equal('"set nodiff nodigraph', @:) call feedkeys(":set invdi\\\"\", 'tx') ! call assert_equal('"set invdiff invdigraph', @:) ! ! " Expanding "set noinv" does nothing. ! call feedkeys(":set noinv\\\"\", 'tx') ! call assert_equal('"set noinv', @:) " Expand abbreviation of options. call feedkeys(":set ts\\\"\", 'tx') *** ../vim-9.0.1519/src/version.c 2023-05-06 21:21:48.400778151 +0100 --- src/version.c 2023-05-06 22:09:16.870227171 +0100 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1520, /**/ -- hundred-and-one symptoms of being an internet addict: 4. Your eyeglasses have a web site burned in on them. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///