Patch 8.2.2992
Problem:    Vim9: completion for :disassemble is incomplete.
Solution:   Recognize the "debug" and "profile" arguments.
Files:      src/cmdexpand.c, src/vim9execute.c, src/proto/vim9execute.pro,
            src/vim.h, src/testdir/test_cmdline.vim


*** ../vim-8.2.2991/src/cmdexpand.c     2021-06-13 17:20:04.827963921 +0200
--- src/cmdexpand.c     2021-06-13 17:51:58.490964718 +0200
***************
*** 1557,1566 ****
  
        case CMD_function:
        case CMD_delfunction:
-       case CMD_disassemble:
            xp->xp_context = EXPAND_USER_FUNC;
            xp->xp_pattern = arg;
            break;
  
        case CMD_echohl:
            set_context_in_echohl_cmd(xp, arg);
--- 1557,1568 ----
  
        case CMD_function:
        case CMD_delfunction:
            xp->xp_context = EXPAND_USER_FUNC;
            xp->xp_pattern = arg;
            break;
+       case CMD_disassemble:
+           set_context_in_disassemble_cmd(xp, arg);
+           break;
  
        case CMD_echohl:
            set_context_in_echohl_cmd(xp, arg);
***************
*** 2120,2125 ****
--- 2122,2128 ----
            {EXPAND_USER_VARS, get_user_var_name, FALSE, TRUE},
            {EXPAND_FUNCTIONS, get_function_name, FALSE, TRUE},
            {EXPAND_USER_FUNC, get_user_func_name, FALSE, TRUE},
+           {EXPAND_DISASSEMBLE, get_disassemble_argument, FALSE, TRUE},
            {EXPAND_EXPRESSION, get_expr_name, FALSE, TRUE},
  # endif
  # ifdef FEAT_MENU
*** ../vim-8.2.2991/src/vim9execute.c   2021-06-13 14:33:16.407820426 +0200
--- src/vim9execute.c   2021-06-13 18:26:29.459985603 +0200
***************
*** 5371,5376 ****
--- 5371,5410 ----
  }
  
  /*
+  * Handle command line completion for the :disassemble command.
+  */
+     void
+ set_context_in_disassemble_cmd(expand_T *xp, char_u *arg)
+ {
+     char_u    *p;
+ 
+     // Default: expand user functions, "debug" and "profile"
+     xp->xp_context = EXPAND_DISASSEMBLE;
+     xp->xp_pattern = arg;
+ 
+     // first argument already typed: only user function names
+     if (*arg != NUL && *(p = skiptowhite(arg)) != NUL)
+     {
+       xp->xp_context = EXPAND_USER_FUNC;
+       xp->xp_pattern = skipwhite(p);
+     }
+ }
+ 
+ /*
+  * Function given to ExpandGeneric() to obtain the list of :disassemble
+  * arguments.
+  */
+     char_u *
+ get_disassemble_argument(expand_T *xp, int idx)
+ {
+     if (idx == 0)
+       return (char_u *)"debug";
+     if (idx == 1)
+       return (char_u *)"profile";
+     return get_user_func_name(xp, idx - 2);
+ }
+ 
+ /*
   * ":disassemble".
   * We don't really need this at runtime, but we do have tests that require it,
   * so always include this.
*** ../vim-8.2.2991/src/proto/vim9execute.pro   2021-05-07 17:55:51.967584415 
+0200
--- src/proto/vim9execute.pro   2021-06-13 17:55:24.670198729 +0200
***************
*** 7,12 ****
--- 7,14 ----
  int exe_typval_instr(typval_T *tv, typval_T *rettv);
  char_u *exe_substitute_instr(void);
  int call_def_function(ufunc_T *ufunc, int argc_arg, typval_T *argv, partial_T 
*partial, typval_T *rettv);
+ void set_context_in_disassemble_cmd(expand_T *xp, char_u *arg);
+ char_u *get_disassemble_argument(expand_T *xp, int idx);
  void ex_disassemble(exarg_T *eap);
  int tv2bool(typval_T *tv);
  void emsg_using_string_as(typval_T *tv, int as_number);
*** ../vim-8.2.2991/src/vim.h   2021-06-13 15:15:58.412822225 +0200
--- src/vim.h   2021-06-13 17:49:27.703373124 +0200
***************
*** 777,782 ****
--- 777,783 ----
  #define EXPAND_MAPCLEAR               47
  #define EXPAND_ARGLIST                48
  #define EXPAND_DIFF_BUFFERS   49
+ #define EXPAND_DISASSEMBLE    50
  
  // Values for exmode_active (0 is no exmode)
  #define EXMODE_NORMAL         1
*** ../vim-8.2.2991/src/testdir/test_cmdline.vim        2021-06-13 
17:20:04.827963921 +0200
--- src/testdir/test_cmdline.vim        2021-06-13 18:34:05.241839830 +0200
***************
*** 810,815 ****
--- 810,825 ----
    call feedkeys(":legac call strle\<C-A>\<C-B>\"\<CR>", 'xt')
    call assert_equal("\"legac call strlen(", @:)
  
+   " completion for the :disassemble command
+   call feedkeys(":disas deb\<C-A>\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"disas debug", @:)
+   call feedkeys(":disas pro\<C-A>\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"disas profile", @:)
+   call feedkeys(":disas debug Test_cmdline_complete_var\<C-A>\<C-B>\"\<CR>", 
'xt')
+   call assert_equal("\"disas debug Test_cmdline_complete_various", @:)
+   call feedkeys(":disas profile 
Test_cmdline_complete_var\<C-A>\<C-B>\"\<CR>", 'xt')
+   call assert_equal("\"disas profile Test_cmdline_complete_various", @:)
+ 
    " completion for the :match command
    call feedkeys(":match Search /pat/\<C-A>\<C-B>\"\<CR>", 'xt')
    call assert_equal("\"match Search /pat/\<C-A>", @:)
*** ../vim-8.2.2991/src/version.c       2021-06-13 17:20:04.831963910 +0200
--- src/version.c       2021-06-13 17:45:23.384033351 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2992,
  /**/

-- 
CRONE:  Who sent you?
ARTHUR: The Knights Who Say GNU!
CRONE:  Aaaagh!  (she looks around in rear) No!  We have no licenses here.
           "Monty Python and the Holy editor wars" PYTHON (MONTY) SOFTWARE LTD

 /// Bram Moolenaar -- b...@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    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202106131639.15DGdMuS642494%40masaka.moolenaar.net.

Raspunde prin e-mail lui