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 <cb@256bit.org>
diff --git a/src/popupwin.c b/src/popupwin.c
index 9f76cb1..4f72d07 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -2583,12 +2583,20 @@
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()