Another issue when searching with ? and CTRL-G

2017-06-29 Thread Ramel Eshed
vim -u NONE -N
:set incsearch
iaaa   (insert 3 lines of 'a')

?a  (now line 2 is highlighted)
^G   (now line 3 is highlighted)
 (cursor ends at line 1!)

Thanks,
Ramel

-- 
-- 
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: Another issue when searching with ? and CTRL-G

2017-06-29 Thread Bram Moolenaar

Ramel Eshed wrote:

> vim -u NONE -N
> :set incsearch
> iaaa   (insert 3 lines of 'a')
> 
> ?a  (now line 2 is highlighted)
> ^G   (now line 3 is highlighted)
>  (cursor ends at line 1!)

Can't reproduce.  What do you mean with "highlighted"? I only see the
cursor.

-- 
>From "know your smileys":
 :-DBig smile

 /// 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: Another issue when searching with ? and CTRL-G

2017-06-29 Thread Ramel
Hi Bram,

If the cursor is on the third line and you start a search backward with:
?a
The cursor now is on the second line. Now CTRL-G will bring the cursor to
the third line. I'd expect that hitting enter now will finish the search
and leave the cursor on the third line, but it goes to the first line
instead.

Ramel


On Jun 29, 2017 11:23 PM, "Bram Moolenaar"  wrote:


Ramel Eshed wrote:

> vim -u NONE -N
> :set incsearch
> iaaa   (insert 3 lines of 'a')
>
> ?a  (now line 2 is highlighted)
> ^G   (now line 3 is highlighted)
>  (cursor ends at line 1!)

Can't reproduce.  What do you mean with "highlighted"? I only see the
cursor.

--
>From "know your smileys":
 :-DBig smile

 /// 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: Another issue when searching with ? and CTRL-G

2017-06-29 Thread Christian Brabandt

On Do, 29 Jun 2017, Bram Moolenaar wrote:

> 
> Ramel Eshed wrote:
> 
> > vim -u NONE -N
> > :set incsearch
> > iaaa   (insert 3 lines of 'a')
> > 
> > ?a  (now line 2 is highlighted)
> > ^G   (now line 3 is highlighted)
> >  (cursor ends at line 1!)
> 
> Can't reproduce.  What do you mean with "highlighted"? I only see the
> cursor.

I can. Will look into it, however I don't have much time currently, so 
if anybody wants to look into it...

Best,
Christian
-- 
In jedem großen Problem steckt ein kleines, das gerne raus möchte.
In jedem kleinen Problem steckt ein großes, das gerne raus möchte.

-- 
-- 
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: Another issue when searching with ? and CTRL-G

2017-06-30 Thread Bram Moolenaar

Ramel Eshed wrote:

> > vim -u NONE -N
> > :set incsearch
> > iaaa   (insert 3 lines of 'a')
> >
> > ?a  (now line 2 is highlighted)
> > ^G   (now line 3 is highlighted)
> >  (cursor ends at line 1!)
> 
> Can't reproduce.  What do you mean with "highlighted"? I only see the
> cursor.
> If the cursor is on the third line and you start a search backward with:
> ?a
> The cursor now is on the second line. Now CTRL-G will bring the cursor to
> the third line. I'd expect that hitting enter now will finish the search
> and leave the cursor on the third line, but it goes to the first line
> instead.

OK, now I get it.  Looks like CTRL-G works in the other direction.
I'll leave this to Christian.

-- 
I AM THANKFUL...
...for the mess to clean after a party because it means I have
been surrounded by friends.

 /// 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: Another issue when searching with ? and CTRL-G

2017-06-30 Thread Christian Brabandt

On Fr, 30 Jun 2017, Bram Moolenaar wrote:

> OK, now I get it.  Looks like CTRL-G works in the other direction.
> I'll leave this to Christian.

Here is a patch.

Best,
Christian
-- 
Augen, die nicht ferne blicken,
Und auch nicht zur Liebe taugen,
Aber ganz entsetzlich drücken,
Sind des Vetters Hühneraugen.

-- Heinrich Heine

-- 
-- 
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 39023f250005e091775c81beea622630ecbc20f2 Mon Sep 17 00:00:00 2001
From: Christian Brabandt 
Date: Fri, 30 Jun 2017 20:12:00 +0200
Subject: [PATCH] searching backwards with ? and  works unexpected

When incsearch is set and one uses ? and  the cursor might be moved
to an unexpected location.

Make sure, the cursor is put at the expected location and add a test.
---
 src/ex_getln.c  |  8 
 src/testdir/test_search.vim | 34 ++
 2 files changed, 42 insertions(+)

diff --git a/src/ex_getln.c b/src/ex_getln.c
index 11de136bf..a888ba412 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -1708,6 +1708,14 @@ getcmdline(
 			search_start = t;
 			(void)decl(&search_start);
 			}
+			else if (c == Ctrl_G && firstc == '?')
+			{
+			/* move just after the current match, so that
+			 * when nv_search finishes the cursor will be
+			 * put back on the match */
+			search_start = t;
+			(void)incl(&search_start);
+			}
 			if (LT_POS(t, search_start) && c == Ctrl_G)
 			{
 			/* wrap around */
diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
index 18a4577b7..69b1335ef 100644
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -322,3 +322,37 @@ func Test_search_cmdline3()
   call test_override("char_avail", 0)
   bw!
 endfunc
+
+func Test_search_cmdline4()
+  if !exists('+incsearch')
+return
+  endif
+  " need to disable char_avail,
+  " so that expansion of commandline works
+  call test_override("char_avail", 1)
+  new
+  call setline(1, ['  1 the first', '  2 the second', '  3 the third'])
+  set incsearch
+  $
+  call feedkeys("?the\\", 'tx')
+  call assert_equal('  3 the third', getline('.'))
+  $
+  call feedkeys("?the\\\", 'tx')
+  call assert_equal('  1 the first', getline('.'))
+  $
+  call feedkeys("?the", 'tx')
+  call assert_equal('  2 the second', getline('.'))
+  $
+  call feedkeys("?the\\", 'tx')
+  call assert_equal('  1 the first', getline('.'))
+  $
+  call feedkeys("?the\\\", 'tx')
+  call assert_equal('  3 the third', getline('.'))
+  $
+  call feedkeys("?the", 'tx')
+  call assert_equal('  2 the second', getline('.'))
+  " clean up
+  set noincsearch
+  call test_override("char_avail", 0)
+  bw!
+endfunc
-- 
2.11.0



Re: Another issue when searching with ? and CTRL-G

2017-07-01 Thread Bram Moolenaar

Christian Brabandt wrote:

> > OK, now I get it.  Looks like CTRL-G works in the other direction.
> > I'll leave this to Christian.
> 
> Here is a patch.

Thanks!

-- 
I AM THANKFUL...
...for the piles of laundry and ironing because it means I
have plenty of clothes to wear.

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