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