wincent/terminus

Pasting into the search prompt ("/") while BracketedPaste is enabled.

damnskippy opened this issue · 4 comments

Trying to understand this behavior (which may be FAD) while pasting into the vim search prompt.
I have a global terminal shortcut <M-v> set to paste from clipboard.
When BracketedPaste is set to 1, pasting into the vim search prompt i.e. hit / followed by <M-v>, what actually gets entered behind the scenes is <nop>search-pattern<CR>
But doing a <C-r>+ i.e. pasting from the register does not exhibit this behavior, maybe because that's vim doing the "input" versus <M-v> is terminal doing the "input", I'm guessing.

Looking at this from the vim debugger, I noticed what is entered is <F22>search-pattern<F23>
Terminus uses F22/F23 to do the paste toggling it appears. <F22> seems to map to <nop>

Any thoughts on how I can work around this?
Basically I would like to disable the "bracketed paste" while pasting at the search prompt, so I can avoid the spurious characters being inserted when pasting with a terminal shortcut.
FWIW, mapping <M-v> to <C-r>+ in vimrc doesn't seem to cut it for search (but works for command mode in general).

Thank you.

Wondering if the recently introduced Autogroup events can help here.
CmdlineEnter
CmdlineLeave
Basically, when entering command line strip the and wrappers (and maybe restore when exiting, if that's possible). Haven't got any clear ideas as to how to go about stripping these wrappers unfortunately. Just noting a thought nevertheless, in case it helps here.

That sounds like a great idea.

I just noticed that this is only an issue if vim is in paste mode (i.e. set paste is on).
With ":set nopaste" pasting doesn't seem to engage the bracketed mode.
I also just updated vim to the latest just moments ago, and did some clean up of my exrc.
With the following lines in my vimrc, I'm able to avoid this issue 100% :)

augroup disable-terminus-bracketed-paste-in-command-line
    autocmd!
    autocmd CmdlineEnter [/\?] :set nopaste
augroup END

As a complete aside, I think these autogroups seem very useful.
Just had a thought for consistent "find-next" navigation with something like this:

augroup sane-search-direction
    autocmd!
    autocmd CmdlineEnter [\?] :nnoremap n N
    autocmd CmdlineEnter [\?] :nnoremap N n
    autocmd CmdlineEnter [/] :nnoremap n n
    autocmd CmdlineEnter [/] :nnoremap N N
augroup END

Between tmux & vim and the search directions for / & ? every once in a while throws me off. At least within vim, this will keep the search direction consistent regardless of / or ? that started the find.