patch 9.0.1707: Cannot wrap around in popup_filter_menu()
Commit:
https://github.com/vim/vim/commit/badeedd913d9d6456ad8087911d024fd36800743
Author: Christian Brabandt <[email protected]>
Date: Sun Aug 13 19:25:28 2023 +0200
patch 9.0.1707: Cannot wrap around in popup_filter_menu()
Problem: Cannot wrap around in popup_filter_menu()
Solution: Allow to wrap around by default
Currently, it is not possible, to wrap around at the end of the list
using e.g. down (and go back to the top) or up at the beginning of the
list and go directly to the last item. This is not consistent behaviour
with e.g. how the pum-menu currently works, so let's just allow this.
Also adjust tests about it.
closes: #12689
closes: #12693
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/popupwin.c b/src/popupwin.c
index 9f76cb16b..4f72d0720 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -2583,12 +2583,20 @@ f_popup_filter_menu(typval_T *argvars, typval_T *rettv)
res.v_type = VAR_NUMBER;
old_lnum = wp->w_cursor.lnum;
- if ((c == 'k' || c == 'K' || c == K_UP || c == Ctrl_P)
- && wp->w_cursor.lnum > 1)
- --wp->w_cursor.lnum;
- if ((c == 'j' || c == 'J' || c == K_DOWN || c == Ctrl_N)
- && wp->w_cursor.lnum < wp->w_buffer->b_ml.ml_line_count)
- ++wp->w_cursor.lnum;
+ if (c == 'k' || c == 'K' || c == K_UP || c == Ctrl_P)
+ {
+ if (wp->w_cursor.lnum > 1)
+ --wp->w_cursor.lnum;
+ else
+ wp->w_cursor.lnum = wp->w_buffer->b_ml.ml_line_count;
+ }
+ if (c == 'j' || c == 'J' || c == K_DOWN || c == Ctrl_N)
+ {
+ if (wp->w_cursor.lnum < wp->w_buffer->b_ml.ml_line_count)
+ ++wp->w_cursor.lnum;
+ else
+ wp->w_cursor.lnum = 1;
+ }
if (old_lnum != wp->w_cursor.lnum)
{
// caller will call popup_highlight_curline()
diff --git a/src/testdir/dumps/Test_popupwin_menu_scroll_3.dump
b/src/testdir/dumps/Test_popupwin_menu_scroll_3.dump
index 00fe0c816..26bb3f913 100644
--- a/src/testdir/dumps/Test_popupwin_menu_scroll_3.dump
+++ b/src/testdir/dumps/Test_popupwin_menu_scroll_3.dump
@@ -1,9 +1,9 @@
>1+0&#ffffff0| @73
|2| @73
|3| @29|╔+0#0000001#ffd7ff255|═@10|╗| +0#0000000#ffffff0@30
-|4| @29|║+0#0000001#ffd7ff255| |s|e|v|e|n| @3|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
-|5| @29|║+0#0000001#ffd7ff255| |e|i|g|h|t| @3|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
-|6| @29|║+0#0000001#ffd7ff255| |n+0&#e0e0e08|i|n|e| @3| +0&#ffd7ff255|
+0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|4| @29|║+0#0000001#ffd7ff255| |f|i|v|e| @4|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|5| @29|║+0#0000001#ffd7ff255| |s|i|x| @5|
+0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|6| @29|║+0#0000001#ffd7ff255| |s+0&#e0e0e08|e|v|e|n| @2| +0&#ffd7ff255|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|7| @29|╚+0#0000001#ffd7ff255|═@10|╝| +0#0000000#ffffff0@30
|8| @73
|9| @73
diff --git a/src/testdir/dumps/Test_popupwin_menu_scroll_3a.dump
b/src/testdir/dumps/Test_popupwin_menu_scroll_3a.dump
new file mode 100644
index 000000000..00fe0c816
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_menu_scroll_3a.dump
@@ -0,0 +1,10 @@
+>1+0&#ffffff0| @73
+|2| @73
+|3| @29|╔+0#0000001#ffd7ff255|═@10|╗| +0#0000000#ffffff0@30
+|4| @29|║+0#0000001#ffd7ff255| |s|e|v|e|n| @3|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|5| @29|║+0#0000001#ffd7ff255| |e|i|g|h|t| @3|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|6| @29|║+0#0000001#ffd7ff255| |n+0&#e0e0e08|i|n|e| @3| +0&#ffd7ff255|
+0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|7| @29|╚+0#0000001#ffd7ff255|═@10|╝| +0#0000000#ffffff0@30
+|8| @73
+|9| @73
+@57|1|,|1| @10|T|o|p|
diff --git a/src/testdir/dumps/Test_popupwin_menu_scroll_6.dump
b/src/testdir/dumps/Test_popupwin_menu_scroll_6.dump
index 6718bb37b..f4272aff2 100644
--- a/src/testdir/dumps/Test_popupwin_menu_scroll_6.dump
+++ b/src/testdir/dumps/Test_popupwin_menu_scroll_6.dump
@@ -1,9 +1,9 @@
>1+0&#ffffff0| @73
|2| @73
|3| @29|╔+0#0000001#ffd7ff255|═@10|╗| +0#0000000#ffffff0@30
-|4| @29|║+0#0000001#ffd7ff255| |o+0&#e0e0e08|n|e| @4| +0&#ffd7ff255|
+0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
-|5| @29|║+0#0000001#ffd7ff255| |t|w|o| @5|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
-|6| @29|║+0#0000001#ffd7ff255| |t|h|r|e@1| @3|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|4| @29|║+0#0000001#ffd7ff255| |f+0&#e0e0e08|o|u|r| @3| +0&#ffd7ff255|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|5| @29|║+0#0000001#ffd7ff255| |f|i|v|e| @4|
+0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|6| @29|║+0#0000001#ffd7ff255| |s|i|x| @5|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
|7| @29|╚+0#0000001#ffd7ff255|═@10|╝| +0#0000000#ffffff0@30
|8| @73
|9| @73
diff --git a/src/testdir/dumps/Test_popupwin_menu_scroll_6a.dump
b/src/testdir/dumps/Test_popupwin_menu_scroll_6a.dump
new file mode 100644
index 000000000..6718bb37b
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_menu_scroll_6a.dump
@@ -0,0 +1,10 @@
+>1+0&#ffffff0| @73
+|2| @73
+|3| @29|╔+0#0000001#ffd7ff255|═@10|╗| +0#0000000#ffffff0@30
+|4| @29|║+0#0000001#ffd7ff255| |o+0&#e0e0e08|n|e| @4| +0&#ffd7ff255|
+0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|5| @29|║+0#0000001#ffd7ff255| |t|w|o| @5|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|6| @29|║+0#0000001#ffd7ff255| |t|h|r|e@1| @3|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@30
+|7| @29|╚+0#0000001#ffd7ff255|═@10|╝| +0#0000000#ffffff0@30
+|8| @73
+|9| @73
+@57|1|,|1| @10|T|o|p|
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index c0842f45a..60dc5d9b9 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -1794,7 +1794,8 @@ func Test_popup_menu()
let winid = ShowMenu(" ", 1)
let winid = ShowMenu("j \<CR>", 2)
let winid = ShowMenu("JjK \<CR>", 2)
- let winid = ShowMenu("jjjjjj ", 3)
+ " wraps around
+ let winid = ShowMenu("jjjjjj ", 1)
let winid = ShowMenu("kkk ", 1)
let winid = ShowMenu("x", -1)
let winid = ShowMenu("X", -1)
@@ -3053,20 +3054,28 @@ func Test_popup_menu_with_scrollbar()
call term_sendkeys(buf, "jjj")
call VerifyScreenDump(buf, 'Test_popupwin_menu_scroll_2', {})
- " if the cursor is the bottom line, it stays at the bottom line.
+ " the cursor wraps around at the bottom
call term_sendkeys(buf, repeat("j", 20))
call VerifyScreenDump(buf, 'Test_popupwin_menu_scroll_3', {})
+ " if the cursor is again at the bottom line
+ call term_sendkeys(buf, repeat("j", 2))
+ call VerifyScreenDump(buf, 'Test_popupwin_menu_scroll_3a', {})
+
call term_sendkeys(buf, "kk")
call VerifyScreenDump(buf, 'Test_popupwin_menu_scroll_4', {})
call term_sendkeys(buf, "k")
call VerifyScreenDump(buf, 'Test_popupwin_menu_scroll_5', {})
- " if the cursor is in the top line, it stays in the top line.
+ " the cursor wraps around at the top
call term_sendkeys(buf, repeat("k", 20))
call VerifyScreenDump(buf, 'Test_popupwin_menu_scroll_6', {})
+ " the cursor at the top of the window again
+ call term_sendkeys(buf, repeat("k", 3))
+ call VerifyScreenDump(buf, 'Test_popupwin_menu_scroll_6a', {})
+
" close the menu popupwin.
call term_sendkeys(buf, " ")
diff --git a/src/version.c b/src/version.c
index ea360458c..edc013b75 100644
--- a/src/version.c
+++ b/src/version.c
@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1707,
/**/
1706,
/**/
--
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/E1qVEui-000JyI-9m%40256bit.org.