Friday, October 10, 2014

TextChanged triggered on save

I've got a plugin that registers an autocmd on TextChanged and uses the '[ and '] marks to act on the modified lines (trim trailing whitespace). There's a weird edge case that happens if you open a file and immediately save it. The save triggers TextChanged, and '[,'] defaults to 1,$. Here's a simple repro using a recently-built vim at 7.4.473:

$ cat > foo
foo
bar
baz
^D
$ vim -N -u NONE foo
:autocmd TextChanged * echomsg(line("'[") . "," . line("']"))
:w

And notice that "1,3" is printed in the status line.

I can understand why '[,'] defaults to 1,$, but why does save trigger TextChanged?

-Bob

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment