Hi Bram!

I'd like for my plugin (which ensures parentheses are balanced) to merge
the setline() change with the insertion.  As far as I can tell, there's no
way to do that with this fix.  (undojoin does not work in insert mode)

In addition to this allowing the user to unbalance the parentheses by using
undo, undoing triggers TextChangedI (which is good) and I reapply the same
parenthesis-balancing fix made the first time, getting the user stuck and
unable to undo.

Thoughts?  Work-around or different approach?  Should, in theory at least,
undojoin work in insert mode?

Thanks,
-Jason

On Tue, Aug 7, 2018 at 2:00 PM Christ van Willegen <cvwille...@gmail.com>
wrote:

> Hi,
>
>
>
> Op di 7 aug. 2018 19:05 schreef Bram Moolenaar <b...@moolenaar.net>:
>
>>
>> Patch 8.1.0245
>> Problem:    Calling setline() in TextChangedI autocmd breaks undo. (Jason
>>             Felice)
>> Solution:   Don't save lines for undo when already saved. (closes #3291)
>> Files:      src/edit.c, src/testdir/test_autocmd.vim
>>
>>
>> *** ../vim-8.1.0244/src/edit.c  2018-08-07 14:55:04.905259782 +0200
>> --- src/edit.c  2018-08-07 18:26:35.026760346 +0200
>> ***************
>> *** 1722,1732 ****
>> --- 1722,1740 ----
>>       {
>>         aco_save_T      aco;
>>
>> +       // Sync undo when the autocommand calls setline() or append(), so
>> that
>> +       // it can be undone separately.
>> +       u_sync_once = 2;
>> +
>>         // save and restore curwin and curbuf, in case the autocmd
>> changes them
>>         aucmd_prepbuf(&aco, curbuf);
>>         apply_autocmds(EVENT_TEXTCHANGEDI, NULL, NULL, FALSE, curbuf);
>>         aucmd_restbuf(&aco);
>>         curbuf->b_last_changedtick = CHANGEDTICK(curbuf);
>> +
>> +       if (u_sync_once == 1)
>> +           ins_need_undo = TRUE;
>> +       u_sync_once = 0;
>>       }
>>
>
> The "if" condition looks weird. It looks as if the variable u_sync_once is
> set to 2 unconditionally, and then tested if it is == 1. I'm probably
> wrong, though...
>
> Christ van Willegen
>
>> --
> --
> 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/d/optout.
>

-- 
-- 
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/d/optout.

Raspunde prin e-mail lui