From 8e2903d2fe810cfa3be41fc1e7a4d8394c84cf11 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 14 Apr 2023 09:11:37 +0800 Subject: vim-patch:8.2.1049: Vim9: leaking memory when using continuation line Problem: Vim9: leaking memory when using continuation line. Solution: Keep a pointer to the continuation line in evalarg_T. Centralize checking for a next command. https://github.com/vim/vim/commit/b171fb179053fa631fec74911b5fb9374cb6a8a1 Omit eval_next_line(): Vim9 script only. vim-patch:8.2.1050: missing change in struct Problem: Missing change in struct. Solution: Add missing change. https://github.com/vim/vim/commit/65a8ed37f7bc61fbe5c612a7b0eb0dfc16ad3e11 Co-authored-by: Bram Moolenaar --- src/nvim/ex_cmds_defs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/ex_cmds_defs.h') diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index 629aaf14cf..7932649114 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -185,6 +185,7 @@ struct exarg { char *nextcmd; ///< next command (NULL if none) char *cmd; ///< the name of the command (except for :make) char **cmdlinep; ///< pointer to pointer of allocated cmdline + char *cmdline_tofree; ///< free later cmdidx_T cmdidx; ///< the index for the command uint32_t argt; ///< flags for the command int skip; ///< don't execute the command, only parse it -- cgit From fa1baa9a47cdb3eed17d48b6011a164d4009d2ee Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 7 May 2023 08:00:08 +0800 Subject: vim-patch:9.0.1520: completion for option name includes all bool options (#23518) Problem: Completion for option name includes all bool options. Solution: Do not recognize the "noinv" prefix. Prefix "no" or "inv" when appropriate. https://github.com/vim/vim/commit/048d9d25214049dfde04c468c14bd1708fb692b8 Co-authored-by: Bram Moolenaar --- src/nvim/ex_cmds_defs.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/nvim/ex_cmds_defs.h') diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index 7932649114..2acedb5ec3 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -222,11 +222,18 @@ struct exarg { #define EXFLAG_NR 0x02 // '#': number #define EXFLAG_PRINT 0x04 // 'p': print +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 struct expand { char *xp_pattern; // start of item to expand int xp_context; // type of expansion size_t xp_pattern_len; // bytes in xp_pattern before cursor + xp_prefix_T xp_prefix; char *xp_arg; // completion function LuaRef xp_luaref; // Ref to Lua completion function sctx_T xp_script_ctx; // SCTX for completion function -- cgit From 6a273af10517d1f7e4ea85635f1d25a9158adeb5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 May 2023 10:40:53 +0800 Subject: refactor: remove typval.h from most header files (#23601) Because typval_defs.h is enough for most of them. --- src/nvim/ex_cmds_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_cmds_defs.h') diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index 2acedb5ec3..568d4d38ba 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -4,7 +4,7 @@ #include #include -#include "nvim/eval/typval.h" +#include "nvim/eval/typval_defs.h" #include "nvim/normal.h" #include "nvim/pos.h" #include "nvim/regexp_defs.h" -- cgit From 1d6c4ad073ecff42a4421c7b30b42937809bd248 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 18 Aug 2023 07:23:43 +0800 Subject: vim-patch:9.0.1735: Rename completion specific findex var (#24769) Problem: Rename completion specific findex var Solution: Move "findex" static variable to xp_selected in expand_T closes: vim/vim#12548 https://github.com/vim/vim/commit/e9ef347c137aca6c2592beb19da45a8aece65e11 --- src/nvim/ex_cmds_defs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/ex_cmds_defs.h') diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index 568d4d38ba..d07532dc11 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -244,6 +244,7 @@ struct expand { #endif int xp_numfiles; // number of files found by file name completion int xp_col; // cursor position in line + int xp_selected; // selected index in completion char **xp_files; // list of files char *xp_line; // text being completed #define EXPAND_BUF_LEN 256 -- cgit From af7d317f3ff31d5ac5d8724b5057a422e1451b54 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 26 Sep 2023 22:36:08 +0200 Subject: refactor: remove long long is 32-bits even on 64-bit windows which makes the type suboptimal for a codebase meant to be cross-platform. --- src/nvim/ex_cmds_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_cmds_defs.h') diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index d07532dc11..4280ff70b9 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -290,7 +290,7 @@ typedef struct { // values for undo_cmdmod() char *cmod_save_ei; ///< saved value of 'eventignore' int cmod_did_sandbox; ///< set when "sandbox" was incremented - long cmod_verbose_save; ///< if 'verbose' was set: value of p_verbose plus one + OptInt cmod_verbose_save; ///< if 'verbose' was set: value of p_verbose plus one int cmod_save_msg_silent; ///< if non-zero: saved value of msg_silent + 1 int cmod_save_msg_scroll; ///< for restoring msg_scroll int cmod_did_esilent; ///< incremented when emsg_silent is -- cgit From dbfdb52ea867ccd900575bd7dd52a71add7a7346 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 06:30:10 +0800 Subject: vim-patch:9.0.1956: Custom completion skips orig cmdline if it invokes glob() (#25427) Problem: Custom cmdline completion skips original cmdline when pressing Ctrl-P at first match if completion function invokes glob(). Solution: Move orig_save into struct expand_T. closes: vim/vim#13216 https://github.com/vim/vim/commit/28a23602e8f88937645b8506b7915ecea6e09b18 --- src/nvim/ex_cmds_defs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/ex_cmds_defs.h') diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index 4280ff70b9..78f880db56 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -245,6 +245,7 @@ struct expand { int xp_numfiles; // number of files found by file name completion int xp_col; // cursor position in line int xp_selected; // selected index in completion + char *xp_orig; // originally expanded string char **xp_files; // list of files char *xp_line; // text being completed #define EXPAND_BUF_LEN 256 -- cgit From 09a17f91d0d362c6e58bfdbe3ccdeacffb0b44b9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 2 Oct 2023 10:45:33 +0800 Subject: refactor: move cmdline completion types to cmdexpand_defs.h (#25465) --- src/nvim/ex_cmds_defs.h | 113 ++++++++---------------------------------------- 1 file changed, 19 insertions(+), 94 deletions(-) (limited to 'src/nvim/ex_cmds_defs.h') diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index 78f880db56..111e9539c4 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -5,6 +5,7 @@ #include #include "nvim/eval/typval_defs.h" +#include "nvim/ex_eval_defs.h" #include "nvim/normal.h" #include "nvim/pos.h" #include "nvim/regexp_defs.h" @@ -69,20 +70,20 @@ #define EX_FILE1 (EX_FILES | EX_NOSPC) // 1 file, defaults to current file #define EX_WORD1 (EX_EXTRA | EX_NOSPC) // one extra word allowed -// values for cmd_addr_type +/// values for cmd_addr_type typedef enum { - ADDR_LINES, // buffer line numbers - ADDR_WINDOWS, // window number - ADDR_ARGUMENTS, // argument number - ADDR_LOADED_BUFFERS, // buffer number of loaded buffer - ADDR_BUFFERS, // buffer number - ADDR_TABS, // tab page number - ADDR_TABS_RELATIVE, // Tab page that only relative - ADDR_QUICKFIX_VALID, // quickfix list valid entry number - ADDR_QUICKFIX, // quickfix list entry number - ADDR_UNSIGNED, // positive count or zero, defaults to 1 - ADDR_OTHER, // something else, use line number for '$', '%', etc. - ADDR_NONE, // no range used + ADDR_LINES, ///< buffer line numbers + ADDR_WINDOWS, ///< window number + ADDR_ARGUMENTS, ///< argument number + ADDR_LOADED_BUFFERS, ///< buffer number of loaded buffer + ADDR_BUFFERS, ///< buffer number + ADDR_TABS, ///< tab page number + ADDR_TABS_RELATIVE, ///< Tab page that only relative + ADDR_QUICKFIX_VALID, ///< quickfix list valid entry number + ADDR_QUICKFIX, ///< quickfix list entry number + ADDR_UNSIGNED, ///< positive count or zero, defaults to 1 + ADDR_OTHER, ///< something else, use line number for '$', '%', etc. + ADDR_NONE, ///< no range used } cmd_addr_T; typedef struct exarg exarg_T; @@ -128,54 +129,13 @@ typedef char *(*LineGetter)(int, void *, int, bool); /// Structure for command definition. typedef struct cmdname { - char *cmd_name; ///< Name of the command. - ex_func_T cmd_func; ///< Function with implementation of this command. - ex_preview_func_T cmd_preview_func; ///< Preview callback function of this command. - uint32_t cmd_argt; ///< Relevant flags from the declared above. - cmd_addr_T cmd_addr_type; ///< Flag for address type. + char *cmd_name; ///< Name of the command. + ex_func_T cmd_func; ///< Function with implementation of this command. + ex_preview_func_T cmd_preview_func; ///< Preview callback function of this command. + uint32_t cmd_argt; ///< Relevant flags from the declared above. + cmd_addr_T cmd_addr_type; ///< Flag for address type. } CommandDefinition; -// A list used for saving values of "emsg_silent". Used by ex_try() to save the -// value of "emsg_silent" if it was non-zero. When this is done, the CSF_SILENT -// flag below is set. -typedef struct eslist_elem eslist_T; -struct eslist_elem { - int saved_emsg_silent; // saved value of "emsg_silent" - eslist_T *next; // next element on the list -}; - -// For conditional commands a stack is kept of nested conditionals. -// When cs_idx < 0, there is no conditional command. -enum { - CSTACK_LEN = 50, -}; - -typedef struct { - int cs_flags[CSTACK_LEN]; // CSF_ flags - char cs_pending[CSTACK_LEN]; // CSTP_: what's pending in ":finally" - union { - void *csp_rv[CSTACK_LEN]; // return typeval for pending return - void *csp_ex[CSTACK_LEN]; // exception for pending throw - } cs_pend; - void *cs_forinfo[CSTACK_LEN]; // info used by ":for" - int cs_line[CSTACK_LEN]; // line nr of ":while"/":for" line - int cs_idx; // current entry, or -1 if none - int cs_looplevel; // nr of nested ":while"s and ":for"s - int cs_trylevel; // nr of nested ":try"s - eslist_T *cs_emsg_silent_list; // saved values of "emsg_silent" - int cs_lflags; // loop flags: CSL_ flags -} cstack_T; -#define cs_rettv cs_pend.csp_rv -#define cs_exception cs_pend.csp_ex - -// Flags for the cs_lflags item in cstack_T. -enum { - CSL_HAD_LOOP = 1, // just found ":while" or ":for" - CSL_HAD_ENDLOOP = 2, // just found ":endwhile" or ":endfor" - CSL_HAD_CONT = 4, // just found ":continue" - CSL_HAD_FINA = 8, // just found ":finally" -}; - /// Arguments used for Ex commands. struct exarg { char *arg; ///< argument of the command @@ -222,41 +182,6 @@ struct exarg { #define EXFLAG_NR 0x02 // '#': number #define EXFLAG_PRINT 0x04 // 'p': print -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 -struct expand { - char *xp_pattern; // start of item to expand - int xp_context; // type of expansion - size_t xp_pattern_len; // bytes in xp_pattern before cursor - xp_prefix_T xp_prefix; - char *xp_arg; // completion function - LuaRef xp_luaref; // Ref to Lua completion function - sctx_T xp_script_ctx; // SCTX for completion function - int xp_backslash; // one of the XP_BS_ values -#ifndef BACKSLASH_IN_FILENAME - int xp_shell; // true for a shell command, more - // characters need to be escaped -#endif - int xp_numfiles; // number of files found by file name completion - int xp_col; // cursor position in line - int xp_selected; // selected index in completion - char *xp_orig; // originally expanded string - char **xp_files; // list of files - char *xp_line; // text being completed -#define EXPAND_BUF_LEN 256 - char xp_buf[EXPAND_BUF_LEN]; // buffer for returned match -}; - -// values for xp_backslash -#define XP_BS_NONE 0 // nothing special for backslashes -#define XP_BS_ONE 1 // uses one backslash before a space -#define XP_BS_THREE 2 // uses three backslashes before a space - enum { CMOD_SANDBOX = 0x0001, ///< ":sandbox" CMOD_SILENT = 0x0002, ///< ":silent" -- cgit From e72b546354cd90bf0cd8ee6dd045538d713009ad Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 29 Sep 2023 14:58:48 +0200 Subject: refactor: the long goodbye long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types. --- src/nvim/ex_cmds_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_cmds_defs.h') diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index 111e9539c4..e15ba673ce 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -94,7 +94,7 @@ typedef struct exarg exarg_T; #define BAD_DROP (-2) // erase it typedef void (*ex_func_T)(exarg_T *eap); -typedef int (*ex_preview_func_T)(exarg_T *eap, long cmdpreview_ns, handle_T cmdpreview_bufnr); +typedef int (*ex_preview_func_T)(exarg_T *eap, int cmdpreview_ns, handle_T cmdpreview_bufnr); // NOTE: These possible could be removed and changed so that // Callback could take a "command" style string, and simply -- cgit From 4f8941c1a5f1ef6caa410feeb52e343db22763ce Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 10 Nov 2023 12:23:42 +0100 Subject: refactor: replace manual header guards with #pragma once It is less error-prone than manually defining header guards. Pretty much all compilers support it even if it's not part of the C standard. --- src/nvim/ex_cmds_defs.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/nvim/ex_cmds_defs.h') diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index e15ba673ce..9359c6ed12 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -1,5 +1,4 @@ -#ifndef NVIM_EX_CMDS_DEFS_H -#define NVIM_EX_CMDS_DEFS_H +#pragma once #include #include @@ -230,5 +229,3 @@ typedef struct { bool bar; } magic; } CmdParseInfo; - -#endif // NVIM_EX_CMDS_DEFS_H -- cgit From f4aedbae4cb1f206f5b7c6142697b71dd473059b Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 18:39:38 +0100 Subject: build(IWYU): fix includes for undo_defs.h --- src/nvim/ex_cmds_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_cmds_defs.h') diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index 9359c6ed12..ffdb4ba6af 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -6,7 +6,7 @@ #include "nvim/eval/typval_defs.h" #include "nvim/ex_eval_defs.h" #include "nvim/normal.h" -#include "nvim/pos.h" +#include "nvim/pos_defs.h" #include "nvim/regexp_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -- cgit From 64b53b71ba5d804b2c8cf186be68931b2621f53c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 29 Nov 2023 12:10:42 +0800 Subject: refactor(IWYU): create normal_defs.h (#26293) --- src/nvim/ex_cmds_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/ex_cmds_defs.h') diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index ffdb4ba6af..00363884ec 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -5,7 +5,7 @@ #include "nvim/eval/typval_defs.h" #include "nvim/ex_eval_defs.h" -#include "nvim/normal.h" +#include "nvim/normal_defs.h" #include "nvim/pos_defs.h" #include "nvim/regexp_defs.h" -- cgit