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/textobject.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index d4310d47a4..6e61e9be61 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -11,7 +11,6 @@ #include "nvim/edit.h" #include "nvim/eval/funcs.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/globals.h" #include "nvim/indent.h" #include "nvim/macros_defs.h" -- 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/textobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 6e61e9be61..3a7cc2a633 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -586,7 +586,7 @@ int current_word(oparg_T *oap, int count, bool include, bool bigword) { pos_T start_pos; bool inclusive = true; - int include_white = false; + bool include_white = false; cls_bigword = bigword; clearpos(&start_pos); @@ -1079,7 +1079,7 @@ int current_tagblock(oparg_T *oap, int count_arg, bool include) bool do_include = include; bool save_p_ws = p_ws; int retval = FAIL; - int is_inclusive = true; + bool is_inclusive = true; p_ws = false; -- 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/textobject.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 3a7cc2a633..9c601769c0 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -6,6 +6,7 @@ #include #include "nvim/ascii_defs.h" +#include "nvim/buffer_defs.h" #include "nvim/cursor.h" #include "nvim/drawscreen.h" #include "nvim/edit.h" -- cgit From af93a74a0f4afa9a3a4f55ffdf28141eaf776d22 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 18 Dec 2023 10:55:23 +0100 Subject: refactor: run IWYU on entire repo Reference: https://github.com/neovim/neovim/issues/6371. --- src/nvim/textobject.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 9c601769c0..0cfbb50684 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -14,7 +14,6 @@ #include "nvim/fold.h" #include "nvim/globals.h" #include "nvim/indent.h" -#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" -- cgit From b3940cf8a1b388a49a2076573a7702ca4a22d059 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 28 Dec 2023 08:12:20 +0800 Subject: vim-patch:9.0.2188: cursor wrong after { in single line buffer (#26766) Problem: cursor wrong after { in single line buffer (Edwin Chan) Solution: do not place the cursor at the end for a single line buffer when moving backwards (Gary Johnson) closes: vim/vim#13780 closes: vim/vim#13783 https://github.com/vim/vim/commit/9e6549d2fb282c45a2492ea95fe7ba54c2082c3e Co-authored-by: Gary Johnson --- src/nvim/textobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 0cfbb50684..2d1fd8c699 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -213,7 +213,7 @@ bool findpar(bool *pincl, int dir, int count, int what, bool both) curr++; } curwin->w_cursor.lnum = curr; - if (curr == curbuf->b_ml.ml_line_count && what != '}') { + if (curr == curbuf->b_ml.ml_line_count && what != '}' && dir == FORWARD) { char *line = ml_get(curr); // Put the cursor on the last character in the last line and make the -- 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/textobject.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 2d1fd8c699..3d8e7c9901 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -169,14 +169,13 @@ found: /// @return true if the next paragraph or section was found. bool findpar(bool *pincl, int dir, int count, int what, bool both) { - linenr_T curr; bool first; // true on first line linenr_T fold_first; // first line of a closed fold linenr_T fold_last; // last line of a closed fold bool fold_skipped; // true if a closed fold was skipped this // iteration - curr = curwin->w_cursor.lnum; + linenr_T curr = curwin->w_cursor.lnum; while (count--) { bool did_skip = false; // true after separating lines have been skipped @@ -259,9 +258,7 @@ static bool inmacro(char *opt, const char *s) /// If 'both' is true also stop at '}' bool startPS(linenr_T lnum, int para, bool both) { - char *s; - - s = ml_get(lnum); + char *s = ml_get(lnum); if ((uint8_t)(*s) == para || *s == '\f' || (both && *s == '}')) { return true; } @@ -293,9 +290,7 @@ static bool cls_bigword; ///< true for "W", "B" or "E" /// boundaries are of interest. static int cls(void) { - int c; - - c = gchar_cursor(); + int c = gchar_cursor(); if (c == ' ' || c == '\t' || c == NUL) { return 0; } @@ -534,9 +529,7 @@ static bool skip_chars(int cclass, int dir) /// Go back to the start of the word or the start of white space static void back_in_line(void) { - int sclass; // starting class - - sclass = cls(); + int sclass = cls(); // starting class while (true) { if (curwin->w_cursor.col == 0) { // stop at start of line break; @@ -723,15 +716,13 @@ int current_word(oparg_T *oap, int count, bool include, bool bigword) /// When Visual active, extend it by one or more sentences. int current_sent(oparg_T *oap, int count, bool include) { - pos_T start_pos; - pos_T pos; bool start_blank; int c; bool at_start_sent; int ncount; - start_pos = curwin->w_cursor; - pos = start_pos; + pos_T start_pos = curwin->w_cursor; + pos_T pos = start_pos; findsent(FORWARD, 1); // Find start of next sentence. // When the Visual area is bigger than one character: Extend it. @@ -1314,7 +1305,7 @@ extend: } // First move back to the start_lnum of the paragraph or white lines - int white_in_front = linewhite(start_lnum); + bool white_in_front = linewhite(start_lnum); while (start_lnum > 1) { if (white_in_front) { // stop at first white line if (!linewhite(start_lnum - 1)) { -- cgit From f38f86b1ad8ad2ae3236f36e56fcdb416f679e65 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 6 Jan 2024 06:19:19 +0800 Subject: vim-patch:9.1.0007: can select empty inner text blocks Problem: can select empty inner text blocks (laurentalacoque) Solution: make selecting empty inner text blocks an error textobjects: Make selecting inner empty blocks an error fixes: vim/vim#13514 closes: vim/vim#13523 https://github.com/vim/vim/commit/ad4d7f446dc6754bde212234d46f4849b520b6e0 Co-authored-by: Christian Brabandt --- src/nvim/textobject.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 3d8e7c9901..3e696167e2 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -955,6 +955,12 @@ int current_block(oparg_T *oap, int count, bool include, int what, int other) } } + if (equalpos(start_pos, *end_pos)) { + // empty block like this: () + // there is no inner block to select, abort + return FAIL; + } + // In Visual mode, when the resulting area is not bigger than what we // started with, extend it to the next block, and then exclude again. // Don't try to expand the area if the area is empty. -- cgit From 14918118e86a7d113331f4445c51e6e48a6a99c4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 6 Jan 2024 06:24:15 +0800 Subject: vim-patch:9.1.0012: regression with empty inner blocks introduced Problem: regression with empty inner blocks introduced (after v9.1.0007) Solution: Set correct cursor position, Check for visual mode being active (Maxim Kim) relates: vim/vim#13514 closes: vim/vim#13819 https://github.com/vim/vim/commit/3779516988f14f2070d827514c79383334a0946b Co-authored-by: Maxim Kim --- src/nvim/textobject.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 3e696167e2..76ea24039a 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -955,9 +955,10 @@ int current_block(oparg_T *oap, int count, bool include, int what, int other) } } - if (equalpos(start_pos, *end_pos)) { - // empty block like this: () - // there is no inner block to select, abort + // In Visual mode, when resulting area is empty + // i.e. there is no inner block to select, abort. + if (equalpos(start_pos, *end_pos) && VIsual_active) { + curwin->w_cursor = old_pos; return FAIL; } -- 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/textobject.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/textobject.c') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 76ea24039a..d9c2b3b111 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -15,6 +15,7 @@ #include "nvim/globals.h" #include "nvim/indent.h" #include "nvim/mark.h" +#include "nvim/mark_defs.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" -- cgit