Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapped CTRL-C doesn't work in gvim due to focus out/in events confusing ctrl_c_interrupts. #12

Open
GoogleCodeExporter opened this issue Aug 18, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?

1. Run Gnome 2 desktop environment.

2. In Gnome, System menu -> Preferences -> Assistive Technologies, pops up a 
window, click "Mouse Accessibility" button, pops up a window, click "General" 
tab, enable "Show position of pointer when the Control key is pressed".

3. In .vimrc, map C-C to something (e.g. use mswin.vim to map C-C to copy)

4. Run gvim

5. Press C-C (e.g if in mswin mode, select some text (e.g. Shift-DownArrow a 
couple of times then press Ctrl-C)

What is the expected output?

Selected text is copied. Selected text stays highlighted.

What do you see instead?

No text is copied (C-V won't paste it). Selected text gets unhighlighted; 
visual mode is exited.

What version of the product are you using? On what operating system?

64-bit Ubuntu Natty, Ubuntu-packaged gvim (vim 7.3.35). Also happens with 
7.3.219 built from latest Hg source.

Please provide any additional information below.

This can be fixed (or perhaps just hacked around) by editing gui_gtk_x11.c near 
the end of function key_press_event() from:

    if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts)
           || (string[0] == intr_char && intr_char != Ctrl_C)))
    {
    trash_input_buf();
    got_int = TRUE;
    }

to:

    if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts && !mapped_ctrl_c)
           || (string[0] == intr_char && intr_char != Ctrl_C)))
    {
    trash_input_buf();
    got_int = TRUE;
    }

But a better solution probably relies on correctly setting ctrl_c_interrupts to 
WAR the issue described below.

Background:

If the Gnome option "show mouse pointer position" is not set, ctrl_c_interrupts 
is false when the C-C keypress is received, and everything works.

However, due to the extra keypress events processed when "show mouse pointer 
position" is enabled, ctrl_c_interrupts gets set back to true, and C-C triggers 
trash_input_buf() etc. The extra keypress events from the Control key being 
pressed are injected from focus lost/gained events, which IIRC get injected 
from gui.c function gui_focus_change().

Original issue reported on code.google.com by stephen....@gmail.com on 16 Jun 2011 at 3:19

rbtnn referenced this issue in rbtnn/vim Apr 9, 2017
Because the same function is present `longest` in the 'wildmenu' option.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant