vim-textobj-user icon indicating copy to clipboard operation
vim-textobj-user copied to clipboard

Support `move-[nNpP]` when patterns is a list

Open Boolean263 opened this issue 4 years ago • 3 comments

This patch allows move-n etc. to work when a textobject is defined using a list with separate start and end patterns. Without this fix, an error is generated when the keybind is pressed for moving between these objects.

Boolean263 avatar Jan 19 '20 23:01 Boolean263

Thank you for the patch. I'll update tests and the document, then merge this patch.

kana avatar Jan 21 '20 11:01 kana

I thought at first your patch looks good, but there is a problem. If a text object is defined by a list "pattern", that text object can be nested like HTML tags. Your patch doesn't correctly handle nested objects.

Suppose that a text object is defined by ['<<', '>>'], and the current buffer contains the following text:

AAA <<BBB <<CCC>> DDD>> EEE

Doing move-N at the first column should move the cursor to the end of DDD>>, but, with your patch, the cursor is moved to the end of CCC>>.

kana avatar Jan 28 '20 13:01 kana

Ah, drat. I should have thought of that, but I only tested it in my own use case. Sorry to waste your time!

Boolean263 avatar Jan 28 '20 23:01 Boolean263