On 13-Aug-2013 11:15 +0200, Bram Moolenaar wrote:

> Einar Lielmanis wrote:
> 
>> Encrypted file contents are destroyed, if something (e.g autocmd)
>> triggers write event, while user is being asked for password.
>>
>> To repro:
>> 1. have an encrypted.txt ready (:X)
>> 2. gvim, :au focuslost * w
>> 3. :e encrypted.txt, don't type in the password yet,
>> 4. lose window focus, e.g via switching to another window, to trigger
>>    the focuslost event,
>>
>> Expected:
>> The file hasn't changed, so it should stay unmodified,
>>
>> Actual behavior:
>> encrypted.txt is truncated to a zero size.
> 
> Doing a ":write" on FocusLost is a bad idea.

This is a common idiom to auto-save, e.g. see
    http://vim.wikia.com/wiki/Auto_save_files_when_focus_is_lost

> Perhaps ":update" would be acceptable, but generally a FocusLost event
> should not do something like this, because it can happen at any time.

Doesn't "at any time" imply more multithreading than is actually
available in Vim(script)?! I had naively assumed that the FocusLost
event would only be processed after the blocking password query has been
concluded. Isn't that (blocking, or maybe just ignoring autocmd events
if that's simpler to implement) a proper way to fix the problem?

-- regards, ingo

-- 
-- 
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to