eregex.vim icon indicating copy to clipboard operation
eregex.vim copied to clipboard

Substitution with an expression breaks messages

Open chocolateboy opened this issue 9 years ago • 3 comments

Vim: 8.0 OS: Linux (Arch) eregex: 950027d

Messages created with echom(sg) aren't displayed correctly or saved to the message history when using :%S/<pattern>/\=<expression>/.

echom-vimrc

call plug#begin()
Plug 'othree/eregex.vim'
call plug#end()

set nocompatible

" echo the supplied arg and return it unchanged
function! Echo(arg)
    echomsg 'arg: ' . a:arg
    return a:arg
endfunction

steps to reproduce

native (:substitute)

  • open a file with vim -u echom-vimrc test.txt
  • insert the word "foo", and replace it with: :%s/foo/\=Echo('bar')/
  • undo the change, then re-run the substitution
  • the message ("arg: foo") is displayed after each substitution, and appears twice in the output of :messages

eregex (:S)

  • open a file with vim -u echom-vimrc test.txt
  • insert the word "foo", and replace it with: :%S/foo/\=Echo('bar')/
  • undo the change, then re-run the substitution
  • the message ("arg: foo") is only displayed after the first substitution, and doesn't appear at all in the output of :messages

chocolateboy avatar Dec 22 '16 00:12 chocolateboy

I can reproduce and I got 0 message. Still looking.

othree avatar Feb 08 '18 03:02 othree

It use silent to execute substitute ref: http://vimdoc.sourceforge.net/htmldoc/various.html#:silent

othree avatar Feb 08 '18 04:02 othree

Not sure why original author try to manage error by itsself. https://github.com/othree/eregex.vim/blob/master/plugin/eregex_e.vim#L4-L6 https://github.com/othree/eregex.vim/blob/master/plugin/eregex.vim#L844-L873

othree avatar Feb 08 '18 04:02 othree