Hi Bram and Good developers,

2018-7-23(Mon) 0:00:23 UTC+9 h_east:
> Hi Dominique and developers,
> 
> 2018-7-22(Sun) 19:49:19 UTC+9 Dominique Pellé:
> > :help inputlist() says:
> > inputlist({textlist})                                       *inputlist()*
> > ...snip...
> >                 The user can also select an item by clicking on it with the
> >             mouse.  For the first string 0 is returned.  When clicking
> >             above the first item a negative number is returned.  When
> >             clicking on the prompt one more than the length of {textlist}
> >             is returned.
> > ...snip...
> >             Example: >
> >                     let color = inputlist(['Select color:', '1. red',
> >                             \ '2. green', '3. blue'])
> > 
> > 
> > Yet, the mouse is taken into account.
> > 
> > I tried this:
> > $ vim --clean -c 'set mouse=a' -c "let color = inputlist(['Select color:', 
> > '1. red', '2. green', '3. blue'])"
> > 
> > 
> > I can only select an item with the keyboard but not with the mouse.
> > 
> > It's broken at least in the latest vim-8.1.203 in terminal and the gtk3 GUI.
> > 
> > I see that it works fine in the older /usr/bin/vim (8.0.1453) which comes 
> > with xubuntu-18.04.
> > 
> > Doing a git bissection, I found that:
> > 
> > vim-8.0.1755 works fine
> > vim-8.0.1756 does not work
> > 
> > 
> > So this patch broke mouse selection in inputlist():
> > commit 73658317bacd9a0264dfaa32288de6ea1f236fe5
> > Author: Bram Moolenaar <[email protected]>
> > Date:   Tue Apr 24 17:41:57 2018 +0200
> > 
> >     patch 8.0.1756: GUI: after prompting for a number the mouse shape is 
> > wrong
> >     
> >     Problem:    GUI: after prompting for a number the mouse shape is 
> > sometimes
> >                 wrong.
> >     Solution:   Call setmouse() after setting "State". (Hirohito Higashi,
> >                 closes #2709)
> 
> Thank you for reporting this.
> 
> I investigated a little.
> Certainly the behavior on the terminal is broken at 8.0.1756.
> However, the behavior is not working properly before 8.0.1756 on gvim.
> I did `git bisect`. gvim broken at 8.0.0722
> 
> commit c9041079a199d753e73d3b242f21cc8db620179a (tag: v8.0.0722)
> Author: Bram Moolenaar <[email protected]>
> Date:   Sun Jul 16 15:48:46 2017 +0200
> 
>     patch 8.0.0722: screen is messed by timer up at inputlist() prompt
> 
>     Problem:    Screen is messed by timer up at inputlist() prompt.
>     Solution:   Set state to ASKMORE. (closes #1843)

I had more investigation.

I figured out why the cursor position moves to a wrong position when timer 
expired.

---- Simple function call stack ----
// On calling inputlist()
f_inputlist();
  prompt_for_number();
    cmdline_row = 0;    // (A)
    State = CMDLINE;
    get_number();
      windgoto(msg_row, msg_col);
      c = safe_vgetc();    // <----- waiting key typed


// On timer expired
check_due_timer();
  redraw_after_callback();
    redrawcmd():
      if (ccline.cmdbuff == NULL)
      {
          // cmdline_row is Zero by (A).  So cursor position set to wrong.
          windgoto(cmdline_row, 0);
          msg_clr_eos();
          return;
      }
--------

I wrote and attached a patch.
- Revert 8.0.0722 and 8.0.1756
- when cmdline_row greater than zero, call redrawcmd() in 
redraw_after_callback().

I confirmed Vim 8.1.0304 on fedora 28 via PuTTY(TERM=xterm-256color) from Win10
and GVim on fedora 28.  Also good Ubuntu 18.04.

Please check out this.
--
Best regards,
Hirohito Higashi (h_east)

-- 
-- 
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].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/misc1.c b/src/misc1.c
index 1647aa952..6b93889ea 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -3752,12 +3752,7 @@ prompt_for_number(int *mouse_used)
     save_cmdline_row = cmdline_row;
     cmdline_row = 0;
     save_State = State;
-    State = ASKMORE;	/* prevents a screen update when using a timer */
-#ifdef FEAT_MOUSE
-    /* May show different mouse shape. */
-    setmouse();
-#endif
-
+    State = CMDLINE;
 
     i = get_number(TRUE, mouse_used);
     if (KeyTyped)
@@ -3772,10 +3767,6 @@ prompt_for_number(int *mouse_used)
     else
 	cmdline_row = save_cmdline_row;
     State = save_State;
-#ifdef FEAT_MOUSE
-    /* May need to restore mouse shape. */
-    setmouse();
-#endif
 
     return i;
 }
diff --git a/src/screen.c b/src/screen.c
index a4eef3205..db5f1dbc2 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -458,9 +458,11 @@ redraw_after_callback(int call_update_screen)
 #endif
 		&& call_update_screen)
 	    update_screen(0);
-	/* Redraw in the same position, so that the user can continue
-	 * editing the command. */
-	redrawcmdline_ex(FALSE);
+
+	if (cmdline_row > 0)
+	    /* Redraw in the same position, so that the user can continue
+	     * editing the command. */
+	    redrawcmdline_ex(FALSE);
     }
     else if (State & (NORMAL | INSERT | TERMINAL))
     {

Raspunde prin e-mail lui