pear-tree icon indicating copy to clipboard operation
pear-tree copied to clipboard

autocmds break executing of macros

Open vladimiroff opened this issue 5 years ago • 3 comments

Executing a macro where <esc>f<something> happens goes into insert mode.

For instance let's say we have (^ denotes where the cursor is):

foo("bar")
     ^

Executing a macro ciwfoo^[f)i, 1^[ makes:

foo("foo"))i, 1

instead of

foo("foo", 1)

After some fair amount of debugging the issue seems to be going away after removing the plugin which makes me think the autocmds for InsertEnter or CursorMovedI cause this.

vladimiroff avatar Apr 19 '19 09:04 vladimiroff

I can't reproduce this problem. I don't really see how the autocmds could cause this, but there could be a conflict with another plugin. Does it still happen if Pear Tree is the only plugin enabled?

Another possibility: Pear Tree remaps <Esc> by default. Depending on your Vim version and terminal emulator, it's possible that this could cause unexpected behavior that I'm unaware of. Try putting the following in your vimrc:

imap jk <Plug>(PearTreeFinishExpansion)

The jk is unimportant. Just map something to <Plug>(PearTreeFinishExpansion) to prevent Pear Tree from mapping <Esc>, then see if your issue is still present.

tmsvg avatar May 23 '19 16:05 tmsvg

Remapping <Plug>(PearTreeFinishExpansion) to something else fixes the issue. Of course this breaks the finish expansion of multi-line brackets that now has to be applied manually with the new mapping.

The terminal emulator is Konsole 19.04.1 $TERM is xterm-256color Vim is 8.1 (2018 May 18, compiled Apr 26 2019 21:55:55); Included patches: 1-1186; Compiled by Arch Linux

vladimiroff avatar May 30 '19 14:05 vladimiroff

I was worried that would be the case. This is a terminal limitation that I can't do much to fix. As a workaround, I added g:pear_tree_map_special_keys, so you can prevent this issue with the following configuration:

let g:pear_tree_repeatable_expand = 0
let g:pear_tree_map_special_keys = 0
imap <BS> <Plug>(PearTreeBackspace)
imap <CR> <Plug>(PearTreeExpand)

Pair expansion will not be dot-repeatable, but it will work essentially how many other auto-pair plugins do.

tmsvg avatar Jun 03 '19 03:06 tmsvg