[vim/vim] (regression) inputlist() no longer takes mouse into account in inputlist() (#3239)

96 views
Skip to first unread message

Dominique Pellé

unread,
Jul 22, 2018, 6:49:19 AM7/22/18
to vim/vim, Subscribed

: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 <Br...@vim.org>
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)


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

h_east

unread,
Jul 22, 2018, 11:00:23 AM7/22/18
to vim_dev
Hi Dominique and developers,

2018-7-22(Sun) 19:49:19 UTC+9 Dominique Pellé:
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 <Br...@vim.org>
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)


--
Best regards,
Hirohito Higashi (h_east)

h_east

unread,
Aug 21, 2018, 9:09:12 AM8/21/18
to vim_dev
Hi Bram and Good developers,

2018-7-23(Mon) 0:00:23 UTC+9 h_east:
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.
fix_mouse_select_regression.patch

h_east

unread,
Aug 21, 2018, 9:21:31 AM8/21/18
to vim/vim, Subscribed

Bram Moolenaar

unread,
Aug 21, 2018, 9:57:39 AM8/21/18
to vim...@googlegroups.com, h_east
Why remove the calls to setmouse()? We do want the mouse pointer shape
to be adjusted.

redraw_after_callback() also calls update_screen(), depending on some
conditions. Perhaps the check for cmdline_row to be non-zero should be
added there as well?


--
Looking at Perl through Lisp glasses, Perl looks atrocious.

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

h_east

unread,
Aug 21, 2018, 11:30:20 AM8/21/18
to vim_dev
Hi Bram,

2018-8-21(Tue) 22:57:39 UTC+9 Bram Moolenaar:
Before 8.0.0722 worked fine. So that I reverted this.
But implement again.

>
> redraw_after_callback() also calls update_screen(), depending on some
> conditions. Perhaps the check for cmdline_row to be non-zero should be
> added there as well?

Probably I think so.
Patch updated.

Note:
I have not confirmed yet on GUI version.
I will be able to confirm by going to work. (After about 8 hours)

Thanks.
fix_mouse_select_regression2.patch

h_east

unread,
Aug 21, 2018, 8:44:40 PM8/21/18
to vim_dev
Hi,

2018-8-22(Wed) 0:30:20 UTC+9 h_east:
I confirmed "fix_mouse_select_regression2.patch" on Ubuntu 18.04 at my workplace.
it seems for me that it works properly.

Bram Moolenaar

unread,
Aug 26, 2018, 3:23:49 PM8/26/18
to vim/vim, Subscribed

Closed #3239 via 4cbdf15.

Dominique Pellé

unread,
Aug 26, 2018, 5:09:57 PM8/26/18
to vim/vim, Subscribed

Patch 8.1.0328 is meant to fix this issue. However, the fix introduces problems in the terminal: moving the mouse shows garbage characters both in the buffer and in the statusline.

To reproduce it, run this in a terminal:

$  vim --clean -c 'set mouse=a' -c "let color = inputlist(['Select color:', '1. red', '2. green', '3. blue'])

Then click with the mouse on red, green or blue. Observe that the buffer is then in INSERT mode (prior to patch, vim was in normal mode) and moving the mouse inserts displays gibberish in the buffer as well as in the status line at the bottom: status line shows things like "E6[[<MCED1,1" for example at the bottom right and it keeps changing as the mouse is moved.

I'm using vim-8.0.128 (huge) on xubuntu-18.04.1

h_east

unread,
Aug 26, 2018, 9:10:40 PM8/26/18
to vim/vim, Subscribed

@dpelle
I can not reproduce it.
What the terminal emulator are you using?

I am using GNOME treminal 3.28.2 (VTE 0.52.2) or PuTTY 0.70.
Both are using with "TERM=xterm-256color"

--
Best regards,
Hirohito Higashi (h_east)

Dominique Pellé

unread,
Aug 27, 2018, 12:40:29 AM8/27/18
to vim/vim, Subscribed

@h-east wrote:

I can not reproduce it.
What the terminal emulator are you using?

I see this bug in both xfce4-terminal (0.8.7.4) and xterm (330).
I use "TERM=xterm-256color". Same issue happens with "TERM=xterm".

Here is my full vim version:

$ ./vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 26 2018 23:07:20)
Included patches: 1-328
Compiled by pel@pel-cirrus7
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               +extra_search      +mouse_netterm     +tag_old_static
+arabic            +farsi             +mouse_sgr         -tag_any_white
+autocmd           +file_in_path      -mouse_sysmouse    +tcl
+autochdir         +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
+balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
+browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          +toolbar
+cindent           +insert_expand     +path_extra        +user_commands
+clientserver      +job               +perl              +vartabs
+clipboard         +jumplist          +persistent_undo   +vertsplit
+cmdline_compl     +keymap            +postscript        +virtualedit
+cmdline_hist      +lambda            +printer           +visual
+cmdline_info      +langmap           +profile           +visualextra
+comments          +libcall           +python/dyn        +viminfo
+conceal           +linebreak         +python3/dyn       +vreplace
+cryptv            +lispindent        +quickfix          +wildignore
+cscope            +listcmds          +reltime           +wildmenu
+cursorbind        +localmap          +rightleft         +windows
+cursorshape       +lua               +ruby              +writebackup
+dialog_con_gui    +menu              +scrollbind        +X11
+diff              +mksession         +signs             -xfontset
+digraphs          +modify_fname      +smartindent       +xim
+dnd               +mouse             +startuptime       +xpm
-ebcdic            +mouseshape        +statusline        +xsmp_interact
+emacs_tags        +mouse_dec         -sun_workshop      +xterm_clipboard
+eval              +mouse_gpm         +syntax            -xterm_save
+ex_extra          -mouse_jsbterm     +tag_binary        
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang-6.0 -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include   -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1   -DEXITFREE -DABORT_ON_INTERNAL_ERROR   
Linking: clang-6.0   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux   -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.26/CORE -lperl -ldl -lm -lpthread -lcrypt   -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm -lruby-2.5 -lpthread -lgmp -ldl -lcrypt -lm  

The bug does not happen in the GUI version, i.e. it works fine when adding -g as follows:

$ vim --clean -g -c 'set mouse=a' -c "let color = inputlist(['Select color:', '1. red', '2. green', '3. blue'])"

h_east

unread,
Aug 27, 2018, 1:36:02 AM8/27/18
to vim/vim, Subscribed

@dpelle
Tnaks! I can reproduced on xfce4-terminal (0.8.7.4).

This also be reproduced in the 8.0.0721 just before the first regression (8.0.0722) of a series of issues.
The first regression (8.0.0722) does not reproduce the bug reported today.
Because regression makes it impossible to select inputlist() with the mouse.
Since 8.1.0328 inputlist() can be selected again with the mouse, the problem was revealed.

Namely, it seems that the bug reported today was originally latent.

Related comment is here.
https://groups.google.com/d/msg/vim_dev/WY7QoL85sBM/UhRh0SaRBAAJ

--
Best regards,
Hirohito Higashi (h_east)

Related comment is here.
https://groups.google.com/d/msg/vim_dev/WY7QoL85sBM/UhRh0SaRBAAJ

Bram Moolenaar

unread,
Aug 27, 2018, 5:25:10 PM8/27/18
to vim/vim, Subscribed

> Patch 8.1.0328 is meant to fix this issue. However, the fix introduces
> problems in the terminal: moving the mouse shows garbage characters
> both in the buffer and in the statusline.
>
> To reproduce it, run this in a terminal:
> ```

> $ vim --clean -c 'set mouse=a' -c "let color = inputlist(['Select color:', '1. red', '2. green', '3. blue'])
> ```

> Then click with the mouse on red, green or blue. Observe that the buffer is then in INSERT mode (prior to patch, vim was in normal mode) and moving the mouse inserts displays gibberish in the buffer as well as in the status line at the bottom: status line shows things like "E6[[<MCED1,1" for example at the bottom right and it keeps changing as the mouse is moved.
>
> I'm using vim-8.0.128 (huge) on xubuntu-18.04.1

This looks very weird. I managed to track it down to the xterm_trace
feature. It's not stopped when switching the mouse mode.

--
The fastest way to get an engineer to solve a problem is to declare that the
problem is unsolvable. No engineer can walk away from an unsolvable problem
until it's solved.
(Scott Adams - The Dilbert principle)


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

h_east

unread,
Aug 27, 2018, 7:49:51 PM8/27/18
to vim/vim, Subscribed

Fixed by 8.1.0329
Thanks👍

--
Best regards,
Hirohito Higashi (h_east)

Reply all
Reply to author
Forward
0 new messages