Mercurial > vim
comparison src/getchar.c @ 30479:cabceac53ade v9.0.0575
patch 9.0.0575: the getchar() function behaves strangely with bracketed paste
Commit: https://github.com/vim/vim/commit/78aed95c8d11a06590abb079014887a458b28b36
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Sep 24 15:36:35 2022 +0100
patch 9.0.0575: the getchar() function behaves strangely with bracketed paste
Problem: The getchar() function behaves strangely with bracketed paste.
Solution: Do not handle paste-start in getchar(). (issue https://github.com/vim/vim/issues/11172)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 24 Sep 2022 16:45:02 +0200 |
parents | 539fb427124d |
children | 101f08b49ed3 |
comparison
equal
deleted
inserted
replaced
30478:ecb85ad746ff | 30479:cabceac53ade |
---|---|
1718 | 1718 |
1719 for (;;) // this is done twice if there are modifiers | 1719 for (;;) // this is done twice if there are modifiers |
1720 { | 1720 { |
1721 int did_inc = FALSE; | 1721 int did_inc = FALSE; |
1722 | 1722 |
1723 // No mapping after modifier has been read, using an input method | |
1724 // and when a popup window has disabled mapping. | |
1723 if (mod_mask | 1725 if (mod_mask |
1724 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) | 1726 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
1725 || im_is_preediting() | 1727 || im_is_preediting() |
1726 #endif | 1728 #endif |
1727 #if defined(FEAT_PROP_POPUP) | 1729 #if defined(FEAT_PROP_POPUP) |
1728 || popup_no_mapping() | 1730 || popup_no_mapping() |
1729 #endif | 1731 #endif |
1730 ) | 1732 ) |
1731 { | 1733 { |
1732 // no mapping after modifier has been read | |
1733 ++no_mapping; | 1734 ++no_mapping; |
1734 ++allow_keys; | 1735 ++allow_keys; |
1735 did_inc = TRUE; // mod_mask may change value | 1736 // mod_mask value may change, remember we did the increment |
1737 did_inc = TRUE; | |
1736 } | 1738 } |
1737 c = vgetorpeek(TRUE); | 1739 c = vgetorpeek(TRUE); |
1738 if (did_inc) | 1740 if (did_inc) |
1739 { | 1741 { |
1740 --no_mapping; | 1742 --no_mapping; |
1986 } | 1988 } |
1987 | 1989 |
1988 /* | 1990 /* |
1989 * Like safe_vgetc(), but loop to handle K_IGNORE. | 1991 * Like safe_vgetc(), but loop to handle K_IGNORE. |
1990 * Also ignore scrollbar events. | 1992 * Also ignore scrollbar events. |
1991 */ | 1993 * Does not handle bracketed paste - do not use the result for commands. |
1992 int | 1994 */ |
1993 plain_vgetc(void) | 1995 static int |
1996 plain_vgetc_nopaste(void) | |
1994 { | 1997 { |
1995 int c; | 1998 int c; |
1996 | 1999 |
1997 do | 2000 do |
1998 c = safe_vgetc(); | 2001 c = safe_vgetc(); |
1999 while (c == K_IGNORE | 2002 while (c == K_IGNORE |
2000 || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR | 2003 || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR |
2001 || c == K_MOUSEMOVE); | 2004 || c == K_MOUSEMOVE); |
2005 return c; | |
2006 } | |
2007 | |
2008 /* | |
2009 * Like safe_vgetc(), but loop to handle K_IGNORE. | |
2010 * Also ignore scrollbar events. | |
2011 */ | |
2012 int | |
2013 plain_vgetc(void) | |
2014 { | |
2015 int c = plain_vgetc_nopaste(); | |
2002 | 2016 |
2003 if (c == K_PS) | 2017 if (c == K_PS) |
2004 // Only handle the first pasted character. Drop the rest, since we | 2018 // Only handle the first pasted character. Drop the rest, since we |
2005 // don't know what to do with it. | 2019 // don't know what to do with it. |
2006 c = bracketed_paste(PASTE_ONE_CHAR, FALSE, NULL); | 2020 c = bracketed_paste(PASTE_ONE_CHAR, FALSE, NULL); |
2105 ++allow_keys; | 2119 ++allow_keys; |
2106 for (;;) | 2120 for (;;) |
2107 { | 2121 { |
2108 if (argvars[0].v_type == VAR_UNKNOWN) | 2122 if (argvars[0].v_type == VAR_UNKNOWN) |
2109 // getchar(): blocking wait. | 2123 // getchar(): blocking wait. |
2110 n = plain_vgetc(); | 2124 n = plain_vgetc_nopaste(); |
2111 else if (tv_get_bool_chk(&argvars[0], &error)) | 2125 else if (tv_get_bool_chk(&argvars[0], &error)) |
2112 // getchar(1): only check if char avail | 2126 // getchar(1): only check if char avail |
2113 n = vpeekc_any(); | 2127 n = vpeekc_any(); |
2114 else if (error || vpeekc_any() == NUL) | 2128 else if (error || vpeekc_any() == NUL) |
2115 // illegal argument or getchar(0) and no char avail: return zero | 2129 // illegal argument or getchar(0) and no char avail: return zero |