Re: Patch 8.0.0041

2016-10-18 Fir de Conversatie Tommy A
On Tuesday, October 18, 2016 at 7:07:10 AM UTC-4, Bram Moolenaar wrote:
> Tommy Allen wrote:
> 
> > Thanks again, Bram!  There is one (hopefully last) issue.  This works
> > perfectly when using `` and ``, but the problem remains the
> > same when `` and `` are used.
> 
> Ah, yes.  I'll fix this with a more generic solution.  This completion
> code has way too many states...
> 
> -- 
> There are only two hard things in programming: Cache invalidation,
> naming things and off-by-one errors.
> 
>  /// Bram Moolenaar -- b...@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///

This appears to be resolved AFAIC.  Thanks again!

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


Re: Patch 8.0.0041

2016-10-18 Fir de Conversatie Bram Moolenaar

Tommy Allen wrote:

> Thanks again, Bram!  There is one (hopefully last) issue.  This works
> perfectly when using `` and ``, but the problem remains the
> same when `` and `` are used.

Ah, yes.  I'll fix this with a more generic solution.  This completion
code has way too many states...

-- 
There are only two hard things in programming: Cache invalidation,
naming things and off-by-one errors.

 /// Bram Moolenaar -- b...@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_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.


Re: Patch 8.0.0041

2016-10-17 Fir de Conversatie Tommy A
On Monday, October 17, 2016 at 5:06:47 PM UTC-4, Tommy A wrote:
> Thanks again, Bram!  There is one (hopefully last) issue.  This works 
> perfectly when using `` and ``, but the problem remains the same 
> when `` and `` are used.

It looks like adding `(void)stop_arrow()` on line 1431 of edit.c fixes it.  
Does that look right?

-- 
-- 
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.
>From 22b0ca189295922480f2cd932bf26746ebb01c9e Mon Sep 17 00:00:00 2001
From: Tommy Allen 
Date: Mon, 17 Oct 2016 17:41:31 -0400
Subject: [PATCH] Fix completion undo when using Ctrl_N and Ctrl_P

---
 src/edit.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/edit.c b/src/edit.c
index 776a420..753000c 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -1428,6 +1428,7 @@ doESCkey:
 		goto normalchar;
 
 docomplete:
+(void)stop_arrow();
 	compl_busy = TRUE;
 	disable_fold_update++;  /* don't redraw folds here */
 	if (ins_complete(c, TRUE) == FAIL)
-- 
2.10.0



Re: Patch 8.0.0041

2016-10-17 Fir de Conversatie Tommy A
Thanks again, Bram!  There is one (hopefully last) issue.  This works perfectly 
when using `` and ``, but the problem remains the same when `` 
and `` are used.

On Monday, October 17, 2016 at 2:47:40 PM UTC-4, Bram Moolenaar wrote:
> Tommy Allen wrote:
> 
> > This was a faster turn around than I expected, thanks!  Unfortunately
> > there's another issue that comes from this: undo items are
> > overwritten.  If you place text on the line, then press ``, the
> > undo entry should be created for the text on that line (e.g. "aaa").
> > If you jump to the end of the line and insert with `A`, trigger the
> > completion, then select an item in the menu, the text on the line is
> > completely replaced with the selected menu entry (because complete()
> > starts at column 1).  This causes an undo to erase the line instead of
> > reverting to "aaa".
> > 
> > Here's the steps to make the problem clearer:
> > 
> > 1. Enter on first line: "aaa", press `o`
> > 2. Enter text on second line: "aaa", press `ao`
> > 3. Enter text on third line: "aaa"
> > 4. Press `u` twice.
> > 
> > On the last step, I would expect there to be two lines with "aaa" on
> > them, but instead there's only one.
> 
> Thanks for the steps.  I added a test and fixed the problme.
> 
> Please look out for any similar problems.  I suspect not many users have
> "noinsert" in 'completeopt'.
> 
> 
> -- 
> Why don't cannibals eat clowns?
> Because they taste funny.
> 
>  /// Bram Moolenaar -- b...@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_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.


Re: Patch 8.0.0041

2016-10-17 Fir de Conversatie Bram Moolenaar

Tommy Allen wrote:

> This was a faster turn around than I expected, thanks!  Unfortunately
> there's another issue that comes from this: undo items are
> overwritten.  If you place text on the line, then press ``, the
> undo entry should be created for the text on that line (e.g. "aaa").
> If you jump to the end of the line and insert with `A`, trigger the
> completion, then select an item in the menu, the text on the line is
> completely replaced with the selected menu entry (because complete()
> starts at column 1).  This causes an undo to erase the line instead of
> reverting to "aaa".
> 
> Here's the steps to make the problem clearer:
> 
> 1. Enter on first line: "aaa", press `o`
> 2. Enter text on second line: "aaa", press `ao`
> 3. Enter text on third line: "aaa"
> 4. Press `u` twice.
> 
> On the last step, I would expect there to be two lines with "aaa" on
> them, but instead there's only one.

Thanks for the steps.  I added a test and fixed the problme.

Please look out for any similar problems.  I suspect not many users have
"noinsert" in 'completeopt'.


-- 
Why don't cannibals eat clowns?
Because they taste funny.

 /// Bram Moolenaar -- b...@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_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.


Re: Patch 8.0.0041

2016-10-17 Fir de Conversatie Tommy A
Bram,

This was a faster turn around than I expected, thanks!  Unfortunately there's 
another issue that comes from this: undo items are overwritten.  If you place 
text on the line, then press ``, the undo entry should be created for the 
text on that line (e.g. "aaa").  If you jump to the end of the line and insert 
with `A`, trigger the completion, then select an item in the menu, the text on 
the line is completely replaced with the selected menu entry (because 
complete() starts at column 1).  This causes an undo to erase the line instead 
of reverting to "aaa".

Here's the steps to make the problem clearer:

1. Enter on first line: "aaa", press `o`
2. Enter text on second line: "aaa", press `ao`
3. Enter text on third line: "aaa"
4. Press `u` twice.

On the last step, I would expect there to be two lines with "aaa" on them, but 
instead there's only one.

On Sunday, October 16, 2016 at 9:36:30 AM UTC-4, Bram Moolenaar wrote:
> Patch 8.0.0041
> Problem:When using Insert mode completion but not actually inserting
> anything an undo item is still created. (Tommy Allen)
> Solution:   Do not call stop_arrow() when not inserting anything.
> Files:  src/edit.c, src/testdir/test_popup.vim
> 
> 
> *** ../vim-8.0.0040/src/edit.c2016-10-15 17:06:42.086912756 +0200
> --- src/edit.c2016-10-16 15:34:26.985734970 +0200
> ***
> *** 2799,2807 
>   ins_compl_prep(' ');
>   ins_compl_clear();
>   
> - if (stop_arrow() == FAIL)
> - return;
> - 
>   compl_direction = FORWARD;
>   if (startcol > curwin->w_cursor.col)
>   startcol = curwin->w_cursor.col;
> --- 2799,2804 
> ***
> *** 3876,3882 
>   /* put the cursor on the last char, for 'tw' formatting */
>   if (prev_col > 0)
>   dec_cursor();
> ! if (stop_arrow() == OK)
>   insertchar(NUL, 0, -1);
>   if (prev_col > 0
>&& ml_get_curline()[curwin->w_cursor.col] != NUL)
> --- 3873,3880 
>   /* put the cursor on the last char, for 'tw' formatting */
>   if (prev_col > 0)
>   dec_cursor();
> ! /* only format when something was inserted */
> ! if (!arrow_used && !ins_need_undo)
>   insertchar(NUL, 0, -1);
>   if (prev_col > 0
>&& ml_get_curline()[curwin->w_cursor.col] != NUL)
> *** ../vim-8.0.0040/src/testdir/test_popup.vim2016-10-15 
> 17:06:42.094912699 +0200
> --- src/testdir/test_popup.vim2016-10-16 15:33:41.586069579 +0200
> ***
> *** 378,384 
> endif
>   endfunc
>   
> ! :"Test that 'completefunc' works when it's OK.
>   func Test_omnifunc_with_check()
> new
> setlocal omnifunc=DummyCompleteFour
> --- 378,384 
> endif
>   endfunc
>   
> ! " Test that 'completefunc' works when it's OK.
>   func Test_omnifunc_with_check()
> new
> setlocal omnifunc=DummyCompleteFour
> ***
> *** 400,403 
> --- 400,429 
> q!
>   endfunc
>   
> + function UndoComplete()
> +   call complete(1, ['January', 'February', 'March',
> + \ 'April', 'May', 'June', 'July', 'August', 'September',
> + \ 'October', 'November', 'December'])
> +   return ''
> + endfunc
> + 
> + " Test that no undo item is created when no completion is inserted
> + func Test_complete_no_undo()
> +   set completeopt=menu,preview,noinsert,noselect
> +   inoremap  =UndoComplete()
> +   new
> +   call feedkeys("ixxx\\yyy\k", 'xt')
> +   call feedkeys("iaaa\0", 'xt')
> +   call assert_equal('aaa', getline(2))
> +   call feedkeys("i\\", 'xt')
> +   call assert_equal('aaa', getline(2))
> +   call feedkeys("u", 'xt')
> +   call assert_equal('', getline(2))
> + 
> +   iunmap 
> +   set completeopt&
> +   q!
> + endfunc
> + 
> + 
>   " vim: shiftwidth=2 sts=2 expandtab
> *** ../vim-8.0.0040/src/version.c 2016-10-16 14:35:44.547696415 +0200
> --- src/version.c 2016-10-16 15:35:09.805419375 +0200
> ***
> *** 766,767 
> --- 766,769 
>   {   /* Add new patch number below this line */
> + /**/
> + 41,
>   /**/
> 
> -- 
> Sometimes I think the surest sign that intelligent life exists elsewhere
> in the universe is that none of it has tried to contact us. (Calvin)
> 
>  /// Bram Moolenaar -- b...@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_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 thi