From 543e0256c19f397921a332e06b423215fd9aecb5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 30 Nov 2023 15:51:05 +0800 Subject: build: don't define FUNC_ATTR_* as empty in headers (#26317) FUNC_ATTR_* should only be used in .c files with generated headers. Defining FUNC_ATTR_* as empty in headers causes misuses of them to be silently ignored. Instead don't define them by default, and only define them as empty after a .c file has included its generated header. --- src/nvim/quickfix.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/quickfix.c') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 4e20eb8925..112f9aa35a 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -29,7 +29,6 @@ #include "nvim/ex_getln.h" #include "nvim/fileio.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.h" -- cgit From 6346987601a28b00564295ee8be0a8b00d9ff911 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Thu, 7 Dec 2023 23:46:57 +0600 Subject: refactor(options): reduce `findoption()` usage Problem: Many places in the code use `findoption()` to access an option using its name, even if the option index is available. This is very slow because it requires looping through the options array over and over. Solution: Use option index instead of name wherever possible. Also introduce an `OptIndex` enum which contains the index for every option as enum constants, this eliminates the need to pass static option names as strings. --- src/nvim/quickfix.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/nvim/quickfix.c') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 112f9aa35a..976b7e837d 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -3645,12 +3645,12 @@ static int qf_goto_cwindow(const qf_info_T *qi, bool resize, int sz, bool vertsp static void qf_set_cwindow_options(void) { // switch off 'swapfile' - set_option_value_give_err("swf", BOOLEAN_OPTVAL(false), OPT_LOCAL); - set_option_value_give_err("bt", STATIC_CSTR_AS_OPTVAL("quickfix"), OPT_LOCAL); - set_option_value_give_err("bh", STATIC_CSTR_AS_OPTVAL("hide"), OPT_LOCAL); + set_option_value_give_err(kOptSwapfile, BOOLEAN_OPTVAL(false), OPT_LOCAL); + set_option_value_give_err(kOptBuftype, STATIC_CSTR_AS_OPTVAL("quickfix"), OPT_LOCAL); + set_option_value_give_err(kOptBufhidden, STATIC_CSTR_AS_OPTVAL("hide"), OPT_LOCAL); RESET_BINDING(curwin); curwin->w_p_diff = false; - set_option_value_give_err("fdm", STATIC_CSTR_AS_OPTVAL("manual"), OPT_LOCAL); + set_option_value_give_err(kOptFoldmethod, STATIC_CSTR_AS_OPTVAL("manual"), OPT_LOCAL); } // Open a new quickfix or location list window, load the quickfix buffer and @@ -4212,7 +4212,7 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int q // resembles reading a file into a buffer, it's more logical when using // autocommands. curbuf->b_ro_locked++; - set_option_value_give_err("ft", STATIC_CSTR_AS_OPTVAL("qf"), OPT_LOCAL); + set_option_value_give_err(kOptFiletype, STATIC_CSTR_AS_OPTVAL("qf"), OPT_LOCAL); curbuf->b_p_ma = false; keep_filetype = true; // don't detect 'filetype' @@ -5090,7 +5090,7 @@ void ex_cfile(exarg_T *eap) } } if (*eap->arg != NUL) { - set_string_option_direct("ef", -1, eap->arg, OPT_FREE, 0); + set_string_option_direct(kOptErrorfile, eap->arg, OPT_FREE, 0); } char *enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; @@ -7220,7 +7220,7 @@ void ex_helpgrep(exarg_T *eap) bool updated = false; // Make 'cpoptions' empty, the 'l' flag should not be used here. char *const save_cpo = p_cpo; - const bool save_cpo_allocated = is_option_allocated("cpo"); + const bool save_cpo_allocated = (get_option(kOptCpoptions)->flags & P_ALLOCED); p_cpo = empty_string_option; bool new_qi = false; @@ -7258,7 +7258,7 @@ void ex_helpgrep(exarg_T *eap) // Darn, some plugin changed the value. If it's still empty it was // changed and restored, need to restore in the complicated way. if (*p_cpo == NUL) { - set_option_value_give_err("cpo", CSTR_AS_OPTVAL(save_cpo), 0); + set_option_value_give_err(kOptCpoptions, CSTR_AS_OPTVAL(save_cpo), 0); } if (save_cpo_allocated) { free_string_option(save_cpo); -- cgit From 7f6b775b45de5011ff1c44e63e57551566d80704 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 16 Dec 2023 22:14:28 +0100 Subject: refactor: use `bool` to represent boolean values --- src/nvim/quickfix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/quickfix.c') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 976b7e837d..e25f6b9b5e 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -5689,7 +5689,7 @@ static buf_T *load_dummy_buffer(char *fname, char *dirname_start, char *resultin return NULL; } - int failed = true; + bool failed = true; bufref_T newbufref; set_bufref(&newbufref, newbuf); @@ -7318,7 +7318,7 @@ void free_quickfix(void) } #endif -static void get_qf_loc_list(int is_qf, win_T *wp, typval_T *what_arg, typval_T *rettv) +static void get_qf_loc_list(bool is_qf, win_T *wp, typval_T *what_arg, typval_T *rettv) { if (what_arg->v_type == VAR_UNKNOWN) { tv_list_alloc_ret(rettv, kListLenMayKnow); -- cgit From 0c120307ca1ab613e63865c634d7e10ad67fb0ba Mon Sep 17 00:00:00 2001 From: dundargoc Date: Wed, 20 Dec 2023 14:32:22 +0100 Subject: refactor: eliminate cyclic includes --- src/nvim/quickfix.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/quickfix.c') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index e25f6b9b5e..59207dba17 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -14,6 +14,7 @@ #include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/buffer.h" +#include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cursor.h" #include "nvim/drawscreen.h" -- cgit From c89292fcb7f2ebf06efb7c1d00c28f34c6f68fec Mon Sep 17 00:00:00 2001 From: dundargoc Date: Thu, 28 Dec 2023 13:42:24 +0100 Subject: refactor: follow style guide --- src/nvim/quickfix.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/nvim/quickfix.c') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 59207dba17..0bd8ef6bcd 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -1603,7 +1603,7 @@ static int qf_parse_get_fields(char *linebuf, size_t linelen, efm_T *fmt_ptr, qf // Always ignore case when looking for a matching error. regmatch.rm_ic = true; regmatch.regprog = fmt_ptr->prog; - int r = vim_regexec(®match, linebuf, 0); + bool r = vim_regexec(®match, linebuf, 0); fmt_ptr->prog = regmatch.regprog; int status = QF_FAIL; if (r) { @@ -1970,7 +1970,7 @@ static qf_info_T *ll_get_or_alloc_list(win_T *wp) /// For a location list command, returns the stack for the current window. If /// the location list is not found, then returns NULL and prints an error /// message if 'print_emsg' is true. -static qf_info_T *qf_cmd_get_stack(exarg_T *eap, int print_emsg) +static qf_info_T *qf_cmd_get_stack(exarg_T *eap, bool print_emsg) { qf_info_T *qi = &ql_info; @@ -2512,7 +2512,7 @@ static void win_set_loclist(win_T *wp, qf_info_T *qi) /// Find a help window or open one. If 'newwin' is true, then open a new help /// window. -static int jump_to_help_window(qf_info_T *qi, bool newwin, int *opened_window) +static int jump_to_help_window(qf_info_T *qi, bool newwin, bool *opened_window) { win_T *wp = NULL; @@ -2715,7 +2715,7 @@ static void qf_goto_win_with_qfl_file(int qf_fnum) // window, jump to it. Otherwise open a new window to display the file. If // 'newwin' is true, then always open a new window. This is called from either // a quickfix or a location list window. -static int qf_jump_to_usable_window(int qf_fnum, bool newwin, int *opened_window) +static int qf_jump_to_usable_window(int qf_fnum, bool newwin, bool *opened_window) { win_T *usable_wp = NULL; bool usable_win = false; @@ -2770,7 +2770,7 @@ static int qf_jump_to_usable_window(int qf_fnum, bool newwin, int *opened_window /// QF_ABORT if the quickfix/location list was freed by an autocmd /// when opening the buffer. static int qf_jump_edit_buffer(qf_info_T *qi, qfline_T *qf_ptr, int forceit, int prev_winid, - int *opened_window) + bool *opened_window) { qf_list_T *qfl = qf_get_curlist(qi); int old_changetick = qfl->qf_changedtick; @@ -2905,7 +2905,7 @@ static void qf_jump_print_msg(qf_info_T *qi, int qf_index, qfline_T *qf_ptr, buf /// FAIL if not able to jump/open a window. /// NOTDONE if a file is not associated with the entry. /// QF_ABORT if the quickfix/location list was modified by an autocmd. -static int qf_jump_open_window(qf_info_T *qi, qfline_T *qf_ptr, bool newwin, int *opened_window) +static int qf_jump_open_window(qf_info_T *qi, qfline_T *qf_ptr, bool newwin, bool *opened_window) { qf_list_T *qfl = qf_get_curlist(qi); int old_changetick = qfl->qf_changedtick; @@ -2964,7 +2964,7 @@ static int qf_jump_open_window(qf_info_T *qi, qfline_T *qf_ptr, bool newwin, int /// QF_ABORT if the quickfix/location list is freed by an autocmd when opening /// the file. static int qf_jump_to_buffer(qf_info_T *qi, int qf_index, qfline_T *qf_ptr, int forceit, - int prev_winid, int *opened_window, int openfold, int print_message) + int prev_winid, bool *opened_window, int openfold, bool print_message) { // If there is a file name, read the wanted file if needed, and check // autowrite etc. @@ -3051,7 +3051,7 @@ static void qf_jump_newwin(qf_info_T *qi, int dir, int errornr, int forceit, boo int prev_winid = curwin->handle; - int opened_window = false; + bool opened_window = false; int retval = qf_jump_open_window(qi, qf_ptr, newwin, &opened_window); if (retval == FAIL) { goto failed; @@ -3988,7 +3988,7 @@ static void qf_update_buffer(qf_info_T *qi, qfline_T *old_last) buf_inc_changedtick(buf); if (old_last == NULL) { - (void)qf_win_pos_update(qi, 0); + qf_win_pos_update(qi, 0); // restore curwin/curbuf and a few other things aucmd_restbuf(&aco); @@ -4199,7 +4199,7 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int q } if (old_last == NULL) { // Delete the empty line which is now at the end - (void)ml_delete(lnum + 1, false); + ml_delete(lnum + 1, false); } qfga_clear(); @@ -4583,7 +4583,7 @@ int qf_get_cur_valid_idx(exarg_T *eap) /// Used by :cdo, :ldo, :cfdo and :lfdo commands. /// For :cdo and :ldo, returns the 'n'th valid error entry. /// For :cfdo and :lfdo, returns the 'n'th valid file entry. -static size_t qf_get_nth_valid_entry(qf_list_T *qfl, size_t n, int fdo) +static size_t qf_get_nth_valid_entry(qf_list_T *qfl, size_t n, bool fdo) FUNC_ATTR_NONNULL_ALL { // Check if the list has valid errors. @@ -5706,7 +5706,7 @@ static buf_T *load_dummy_buffer(char *fname, char *dirname_start, char *resultin aucmd_prepbuf(&aco, newbuf); // Need to set the filename for autocommands. - (void)setfname(curbuf, fname, NULL, false); + setfname(curbuf, fname, NULL, false); // Create swap file now to avoid the ATTENTION message. check_need_swap(true); @@ -5958,7 +5958,7 @@ static int qf_get_list_from_lines(dict_T *what, dictitem_T *di, dict_T *retdict) if (qf_init_ext(qi, 0, NULL, NULL, &di->di_tv, errorformat, true, 0, 0, NULL, NULL) > 0) { - (void)get_errorlist(qi, NULL, 0, 0, l); + get_errorlist(qi, NULL, 0, 0, l); qf_free(&qi->qf_lists[0]); } xfree(qi); @@ -7324,7 +7324,7 @@ static void get_qf_loc_list(bool is_qf, win_T *wp, typval_T *what_arg, typval_T if (what_arg->v_type == VAR_UNKNOWN) { tv_list_alloc_ret(rettv, kListLenMayKnow); if (is_qf || wp != NULL) { - (void)get_errorlist(NULL, wp, -1, 0, rettv->vval.v_list); + get_errorlist(NULL, wp, -1, 0, rettv->vval.v_list); } } else { tv_dict_alloc_ret(rettv); -- cgit From b49d4e18a67d16548fa72013237a87564656170e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 1 Jan 2024 15:56:00 +0100 Subject: refactor: remove redundant NOLINT comments --- src/nvim/quickfix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/quickfix.c') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 0bd8ef6bcd..9d78a570bb 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -272,7 +272,7 @@ enum { QF_WINHEIGHT = 10, }; ///< default height for quickfix window // Macro to loop through all the items in a quickfix list // Quickfix item index starts from 1, so i below starts at 1 #define FOR_ALL_QFL_ITEMS(qfl, qfp, i) \ - for ((i) = 1, (qfp) = (qfl)->qf_start; /* NOLINT(readability/braces) */ \ + for ((i) = 1, (qfp) = (qfl)->qf_start; \ !got_int && (i) <= (qfl)->qf_count && (qfp) != NULL; \ (i)++, (qfp) = (qfp)->qf_next) -- cgit From 735aa4c4c89943b26f1d6ba0d3e076002490c09d Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 31 Dec 2023 01:54:34 +0100 Subject: refactor: remove redundant struct names A struct can be anonymous if only its typedef is used. --- src/nvim/quickfix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/quickfix.c') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 9d78a570bb..3683679daa 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -107,7 +107,7 @@ typedef enum { /// Usually the list contains one or more entries. But an empty list can be /// created using setqflist()/setloclist() with a title and/or user context /// information and entries can be added later using setqflist()/setloclist(). -typedef struct qf_list_S { +typedef struct { unsigned qf_id; ///< Unique identifier for this list qfltype_T qfl_type; qfline_T *qf_start; ///< pointer to the first error @@ -232,7 +232,7 @@ typedef struct { } qffields_T; /// :vimgrep command arguments -typedef struct vgr_args_S { +typedef struct { int tomatch; ///< maximum number of matches to find char *spat; ///< search pattern int flags; ///< search modifier -- cgit From 10f36af84d4ccb0b626cd6c79c6ba2f2735a56fd Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Wed, 10 Jan 2024 04:15:22 +0600 Subject: refactor(options): remove `OPT_FREE` (#26963) Problem: `OPT_FREE` macro doesn't seem to do anything as `P_ALLOCED` already handles allocations. Solution: Remove `OPT_FREE`. --- src/nvim/quickfix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/quickfix.c') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 3683679daa..6dc45cffcf 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -5091,7 +5091,7 @@ void ex_cfile(exarg_T *eap) } } if (*eap->arg != NUL) { - set_string_option_direct(kOptErrorfile, eap->arg, OPT_FREE, 0); + set_string_option_direct(kOptErrorfile, eap->arg, 0, 0); } char *enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; -- cgit From 1813661a6197c76ea6621284570aca1d56597099 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Thu, 4 Jan 2024 15:38:16 +0100 Subject: refactor(IWYU): fix headers Remove `export` pramgas from defs headers as it causes IWYU to believe that the definitions from the defs headers comes from main header, which is not what we really want. --- src/nvim/quickfix.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/nvim/quickfix.c') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 6dc45cffcf..3ae3807937 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -13,6 +13,7 @@ #include "nvim/arglist.h" #include "nvim/ascii_defs.h" #include "nvim/autocmd.h" +#include "nvim/autocmd_defs.h" #include "nvim/buffer.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" @@ -27,19 +28,24 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" +#include "nvim/ex_eval_defs.h" #include "nvim/ex_getln.h" #include "nvim/fileio.h" #include "nvim/fold.h" #include "nvim/garray.h" -#include "nvim/gettext.h" +#include "nvim/garray_defs.h" +#include "nvim/gettext_defs.h" #include "nvim/globals.h" #include "nvim/help.h" #include "nvim/highlight.h" +#include "nvim/highlight_defs.h" #include "nvim/highlight_group.h" #include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" +#include "nvim/mbyte_defs.h" #include "nvim/memline.h" +#include "nvim/memline_defs.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/move.h" @@ -49,12 +55,15 @@ #include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/fs.h" +#include "nvim/os/fs_defs.h" #include "nvim/os/input.h" #include "nvim/os/os.h" +#include "nvim/os/os_defs.h" #include "nvim/path.h" #include "nvim/pos_defs.h" #include "nvim/quickfix.h" #include "nvim/regexp.h" +#include "nvim/regexp_defs.h" #include "nvim/search.h" #include "nvim/strings.h" #include "nvim/types_defs.h" -- cgit From 73e1942abe7a96d63ce3749af4187f2cdff87e69 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 16 Jan 2024 08:00:08 +0800 Subject: vim-patch:9.1.0009: Cannot easily get the list of matches (#27028) Problem: Cannot easily get the list of matches Solution: Add the matchstrlist() and matchbufline() Vim script functions (Yegappan Lakshmanan) closes: vim/vim#13766 Omit CHECK_LIST_MATERIALIZE(): it populates a List with numbers only, and there is a check for strings below. https://github.com/vim/vim/commit/f93b1c881a99fa847a1bafa71877d7e16f18e6ef vim-patch:eb3475df0d92 runtime(doc): Replace non-breaking space with normal space (vim/vim#13868) https://github.com/vim/vim/commit/eb3475df0d927a178789cf8e7fc4983932e1cdbe Co-authored-by: Yegappan Lakshmanan <4298407+yegappan@users.noreply.github.com> --- src/nvim/quickfix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/quickfix.c') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 3ae3807937..801c00933a 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -6916,7 +6916,7 @@ static int cbuffer_process_args(exarg_T *eap, buf_T **bufp, linenr_T *line1, lin } if (buf->b_ml.ml_mfp == NULL) { - emsg(_("E681: Buffer is not loaded")); + emsg(_(e_buffer_is_not_loaded)); return FAIL; } -- cgit From e98decf9a68e41b09214aa60b77d0db29b7d648a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 2 Feb 2024 21:17:37 +0800 Subject: feat(quickfix): support -q - to read 'errorfile' from stdin (#27303) Note that this only works when stdin is a pipe. --- src/nvim/quickfix.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/quickfix.c') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 801c00933a..14758c8cea 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -1065,7 +1065,9 @@ static int qf_setup_state(qfstate_T *pstate, char *restrict enc, const char *res } if (efile != NULL - && (pstate->fd = os_fopen(efile, "r")) == NULL) { + && (pstate->fd = (strequal(efile, "-") + ? fdopen(os_open_stdin_fd(), "r") + : os_fopen(efile, "r"))) == NULL) { semsg(_(e_openerrf), efile); return FAIL; } -- cgit From c1fa8789c1ba5549dc37163dfa9be039c5092a41 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 16 Feb 2024 06:35:30 +0800 Subject: vim-patch:9.1.0112: Remove undo information, when cleaning quickfix buffer Problem: When the quickfix buffer has been modified an autocommand may invalidate the undo stack (kawarimidoll) Solution: When clearing the quickfix buffer, also wipe the undo stack fixes: vim/vim#13905 closes: vim/vim#13928 https://github.com/vim/vim/commit/f0d3d4a42657dca996e790aa829de3c6be7fdb63 Co-authored-by: Christian Brabandt --- src/nvim/quickfix.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/nvim/quickfix.c') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 14758c8cea..16290b76c6 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -68,6 +68,7 @@ #include "nvim/strings.h" #include "nvim/types_defs.h" #include "nvim/ui.h" +#include "nvim/undo.h" #include "nvim/vim_defs.h" #include "nvim/window.h" @@ -4142,6 +4143,12 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int q } // delete all existing lines + // + // Note: we cannot store undo information, because + // qf buffer is usually not allowed to be modified. + // + // So we need to clean up undo information + // otherwise autocommands may invalidate the undo stack while ((curbuf->b_ml.ml_flags & ML_EMPTY) == 0) { // If deletion fails, this loop may run forever, so // signal error and return. @@ -4150,6 +4157,10 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int q return; } } + + // Remove all undo information + u_blockfree(curbuf); + u_clearall(curbuf); } // Check if there is anything to display -- cgit From 163add40b8b98b91dfb8eff589f49dc75f1032ea Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 16 Feb 2024 06:56:12 +0800 Subject: vim-patch:9.1.0113: duplicate code when cleaning undo stack Problem: duplicate code when cleaning undo stack Solution: refactor undo cleanup into a single public function related: vim/vim#13928 https://github.com/vim/vim/commit/9071ed8107244e0c56a16b77d1c28e975cb21dd2 Co-authored-by: Christian Brabandt --- src/nvim/quickfix.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/nvim/quickfix.c') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 16290b76c6..651ebc9f93 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4159,8 +4159,7 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int q } // Remove all undo information - u_blockfree(curbuf); - u_clearall(curbuf); + u_clearallandblockfree(curbuf); } // Check if there is anything to display -- cgit