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') 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') 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