Saturday, March 26, 2011

Re: Strange Tab Behaviour When Cancelling a Close-Window

Yongwei Wu wrote:

> Hi Bram and other gurus,
>
> I noticed this behaviour when my plug-in cost me data loss, and would
> like to have your comment.
>
> Operations:
>
> 1. Open a file in the first Vim tab, and make some edits
> 2. Open another with tabedit
> 3. Click the top-right corner, or press Alt-F4, to close Vim
> 4. Click on Cancel, when I found there are unsaved edits
>
> Expected behaviour:
>
> * Everything returns to before I try to close the Vim window.
>
> What happens really:
>
> * The second file is closed, and the first file I edit is displayed in
> the second tab.
>
> By the way, my data loss was caused by my BufWinEnter script, which
> assumes that it is only triggered when the file is opened. Since this
> is obviously wrong, my side-question is:
>
> * Is there a way to trigger the Vim script after modeline is executed
> on file loading, and only then?
>
> I am using gvim 7.3.141 on Win32.

When you try to exit and there is a modified buffer, Vim will try to
show you that modified buffer in the current window, so that you can see
what it is and possibly write it. That's intentional.

Autocommands can always cause things to go wrong. You need to take care
about that when writing them. Especially when using commands such as
":q!".

You do need to use BufWinEnter to do something after the modelines, but
it's also triggered when displaying a buffer in any window. You could
set a b: variable to flag whether it's the first time.

--
(letter from Mark to Mike, about the film's probable certificate)
I would like to get back to the Censor and agree to lose the shits, take
the odd Jesus Christ out and lose Oh fuck off, but to retain 'fart in
your general direction', 'castanets of your testicles' and 'oral sex'
and ask him for an 'A' rating on that basis.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
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

No comments:

Post a Comment