comparison src/search.c @ 18448:35e0ab1f2975 v8.1.2218

patch 8.1.2218: "gN" is off by one in Visual mode Commit: https://github.com/vim/vim/commit/453c19257f6d97904ec2e3823e88e63c983f2f9a Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 26 14:42:09 2019 +0200 patch 8.1.2218: "gN" is off by one in Visual mode Problem: "gN" is off by one in Visual mode. Solution: Check moving forward. (Christian Brabandt, https://github.com/vim/vim/issues/5075)
author Bram Moolenaar <Bram@vim.org>
date Sat, 26 Oct 2019 14:45:03 +0200
parents 3b80bdbdc832
children c0445cb7cfe0
comparison
equal deleted inserted replaced
18447:d978101d8bfd 18448:35e0ab1f2975
4675 } 4675 }
4676 4676
4677 #endif /* FEAT_TEXTOBJ */ 4677 #endif /* FEAT_TEXTOBJ */
4678 4678
4679 /* 4679 /*
4680 * Check if the pattern is one character long or zero-width. 4680 * Check if the pattern is zero-width.
4681 * If move is TRUE, check from the beginning of the buffer, else from position 4681 * If move is TRUE, check from the beginning of the buffer, else from position
4682 * "cur". 4682 * "cur".
4683 * "direction" is FORWARD or BACKWARD. 4683 * "direction" is FORWARD or BACKWARD.
4684 * Returns TRUE, FALSE or -1 for failure. 4684 * Returns TRUE, FALSE or -1 for failure.
4685 */ 4685 */
4849 if (!VIsual_active) 4849 if (!VIsual_active)
4850 VIsual = start_pos; 4850 VIsual = start_pos;
4851 4851
4852 // put cursor on last character of match 4852 // put cursor on last character of match
4853 curwin->w_cursor = end_pos; 4853 curwin->w_cursor = end_pos;
4854 if (LT_POS(VIsual, end_pos)) 4854 if (LT_POS(VIsual, end_pos) && forward)
4855 dec_cursor(); 4855 dec_cursor();
4856 else if (VIsual_active && LT_POS(curwin->w_cursor, VIsual)) 4856 else if (VIsual_active && LT_POS(curwin->w_cursor, VIsual))
4857 curwin->w_cursor = pos; // put the cursor on the start of the match 4857 curwin->w_cursor = pos; // put the cursor on the start of the match
4858 VIsual_active = TRUE; 4858 VIsual_active = TRUE;
4859 VIsual_mode = 'v'; 4859 VIsual_mode = 'v';