Patch 8.2.4692
Problem: No test for what 8.2.4691 fixes.
Solution: Add a test. Use a more generic sotlution. (closes #10090)
Files: src/getchar.c, src/mouse.c, src/testdir/test_mapping.vim
*** ../vim-8.2.4691/src/getchar.c 2022-04-04 22:09:25.010642893 +0100
--- src/getchar.c 2022-04-05 13:14:13.629037087 +0100
***************
*** 1419,1424 ****
--- 1419,1432 ----
static int old_mod_mask; // mod_mask for ungotten character
static int old_mouse_row; // mouse_row related to old_char
static int old_mouse_col; // mouse_col related to old_char
+ static int old_KeyStuffed; // whether old_char was stuffed
+
+ static int can_get_old_char()
+ {
+ // If the old character was not stuffed and characters have been added to
+ // the stuff buffer, need to first get the stuffed characters instead.
+ return old_char != -1 && (old_KeyStuffed || stuff_empty());
+ }
/*
* Save all three kinds of typeahead, so that the user must type at a prompt.
***************
*** 1687,1693 ****
* If a character was put back with vungetc, it was already processed.
* Return it directly.
*/
! if (old_char != -1)
{
c = old_char;
old_char = -1;
--- 1695,1701 ----
* If a character was put back with vungetc, it was already processed.
* Return it directly.
*/
! if (can_get_old_char())
{
c = old_char;
old_char = -1;
***************
*** 1987,1993 ****
int
vpeekc(void)
{
! if (old_char != -1)
return old_char;
return vgetorpeek(FALSE);
}
--- 1995,2001 ----
int
vpeekc(void)
{
! if (can_get_old_char())
return old_char;
return vgetorpeek(FALSE);
}
***************
*** 2942,2947 ****
--- 2950,2957 ----
/*
* unget one character (can only be done once!)
+ * If the character was stuffed, vgetc() will get it next time it was called.
+ * Otherwise vgetc() will only get it when the stuff buffer is empty.
*/
void
vungetc(int c)
***************
*** 2950,2955 ****
--- 2960,2966 ----
old_mod_mask = mod_mask;
old_mouse_row = mouse_row;
old_mouse_col = mouse_col;
+ old_KeyStuffed = KeyStuffed;
}
/*
***************
*** 3755,3762 ****
int c2;
int cmod = 0;
int aborted = FALSE;
- int first = TRUE;
- int got_ctrl_o = FALSE;
ga_init2(&line_ga, 1, 32);
--- 3766,3771 ----
***************
*** 3784,3798 ****
// Get one character at a time.
c1 = vgetorpeek(TRUE);
- // do not use Ctrl_O at the start, stuff it back later
- if (first && c1 == Ctrl_O)
- {
- got_ctrl_o = TRUE;
- first = FALSE;
- continue;
- }
- first = FALSE;
-
// Get two extra bytes for special keys
if (c1 == K_SPECIAL)
{
--- 3793,3798 ----
***************
*** 3844,3851 ****
}
no_mapping--;
- if (got_ctrl_o)
- stuffcharReadbuff(Ctrl_O);
if (aborted)
ga_clear(&line_ga);
--- 3844,3849 ----
*** ../vim-8.2.4691/src/mouse.c 2022-04-03 18:01:39.655574461 +0100
--- src/mouse.c 2022-04-05 13:14:13.629037087 +0100
***************
*** 261,267 ****
{
// If the next character is the same mouse event then use that
// one. Speeds up dragging the status line.
! if (vpeekc() != NUL)
{
int nc;
int save_mouse_row = mouse_row;
--- 261,270 ----
{
// If the next character is the same mouse event then use that
// one. Speeds up dragging the status line.
! // Note: Since characters added to the stuff buffer in the code
! // below need to come before the next character, do not do this
! // when the current character was stuffed.
! if (!KeyStuffed && vpeekc() != NUL)
{
int nc;
int save_mouse_row = mouse_row;
*** ../vim-8.2.4691/src/testdir/test_mapping.vim 2022-03-03
13:55:34.159276047 +0000
--- src/testdir/test_mapping.vim 2022-04-05 13:14:13.629037087 +0100
***************
*** 1566,1569 ****
--- 1566,1602 ----
%bw!
endfunc
+ " Test for mapping <LeftDrag> in Insert mode
+ func Test_mouse_drag_insert_map()
+ set mouse=a
+ func ClickExpr()
+ call test_setmouse(1, 1)
+ return "\<LeftMouse>"
+ endfunc
+ func DragExpr()
+ call test_setmouse(1, 2)
+ return "\<LeftDrag>"
+ endfunc
+ inoremap <expr> <F2> ClickExpr()
+ imap <expr> <F3> DragExpr()
+
+ inoremap <LeftDrag> <LeftDrag><Cmd>let g:dragged = 1<CR>
+ exe "normal i\<F2>\<F3>"
+ call assert_equal(1, g:dragged)
+ call assert_equal('v', mode())
+ exe "normal! \<C-\>\<C-N>"
+ unlet g:dragged
+
+ inoremap <LeftDrag> <LeftDrag><C-\><C-N>
+ exe "normal i\<F2>\<F3>"
+ call assert_equal('n', mode())
+
+ iunmap <LeftDrag>
+ iunmap <F2>
+ iunmap <F3>
+ delfunc ClickExpr
+ delfunc DragExpr
+ set mouse&
+ endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.4691/src/version.c 2022-04-04 22:09:25.010642893 +0100
--- src/version.c 2022-04-05 13:15:47.609009497 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4692,
/**/
--
It is illegal to rob a bank and then shoot at the bank teller with a water
pistol.
[real standing law in Louisana, United States of America]
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220405121743.47E331C05DA%40moolenaar.net.