mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.1837: using "gn" after "gN" does not work
Problem: Using "gn" after "gN" does not work. Solution: Extend the other end of the Visual area. (closes vim/vim#7109)c07b7f701f
N/A patches for version.c: vim-patch:8.2.1834: PyEval_InitThreads() is deprecated in Python 3.9 Problem: PyEval_InitThreads() is deprecated in Python 3.9. Solution: Do not call PyEval_InitThreads in Python 3.9 and later. (Ken Takata, closes vim/vim#7113) Avoid warnings for functions.efc0d94afc
This commit is contained in:
parent
ac5af6051b
commit
aa930196a7
@ -4097,7 +4097,7 @@ abort_search:
|
|||||||
int
|
int
|
||||||
current_search(
|
current_search(
|
||||||
long count,
|
long count,
|
||||||
int forward // true for forward, false for backward
|
bool forward // true for forward, false for backward
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
bool old_p_ws = p_ws;
|
bool old_p_ws = p_ws;
|
||||||
@ -4112,6 +4112,11 @@ current_search(
|
|||||||
pos_T pos; // position after the pattern
|
pos_T pos; // position after the pattern
|
||||||
int result; // result of various function calls
|
int result; // result of various function calls
|
||||||
|
|
||||||
|
// When searching forward and the cursor is at the start of the Visual
|
||||||
|
// area, skip the first search backward, otherwise it doesn't move.
|
||||||
|
const bool skip_first_backward = forward && VIsual_active
|
||||||
|
&& lt(curwin->w_cursor, VIsual);
|
||||||
|
|
||||||
orig_pos = pos = curwin->w_cursor;
|
orig_pos = pos = curwin->w_cursor;
|
||||||
if (VIsual_active) {
|
if (VIsual_active) {
|
||||||
// Searching further will extend the match.
|
// Searching further will extend the match.
|
||||||
@ -4129,13 +4134,20 @@ current_search(
|
|||||||
return FAIL; // pattern not found
|
return FAIL; // pattern not found
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// The trick is to first search backwards and then search forward again,
|
||||||
* The trick is to first search backwards and then search forward again,
|
// so that a match at the current cursor position will be correctly
|
||||||
* so that a match at the current cursor position will be correctly
|
// captured. When "forward" is false do it the other way around.
|
||||||
* captured.
|
|
||||||
*/
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
int dir = forward ? i : !i;
|
int dir;
|
||||||
|
if (forward) {
|
||||||
|
if (i == 0 && skip_first_backward) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
dir = i;
|
||||||
|
} else {
|
||||||
|
dir = !i;
|
||||||
|
}
|
||||||
|
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
if (!dir && !zero_width) {
|
if (!dir && !zero_width) {
|
||||||
@ -4182,10 +4194,16 @@ current_search(
|
|||||||
VIsual = start_pos;
|
VIsual = start_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// put cursor on last character of match
|
// put the cursor after the match
|
||||||
curwin->w_cursor = end_pos;
|
curwin->w_cursor = end_pos;
|
||||||
if (lt(VIsual, end_pos) && forward) {
|
if (lt(VIsual, end_pos) && forward) {
|
||||||
dec_cursor();
|
if (skip_first_backward) {
|
||||||
|
// put the cursor on the start of the match
|
||||||
|
curwin->w_cursor = pos;
|
||||||
|
} else {
|
||||||
|
// put the cursor on last character of match
|
||||||
|
dec_cursor();
|
||||||
|
}
|
||||||
} else if (VIsual_active && lt(curwin->w_cursor, VIsual) && forward) {
|
} else if (VIsual_active && lt(curwin->w_cursor, VIsual) && forward) {
|
||||||
curwin->w_cursor = pos; // put the cursor on the start of the match
|
curwin->w_cursor = pos; // put the cursor on the start of the match
|
||||||
}
|
}
|
||||||
|
@ -169,6 +169,22 @@ func Test_gN_repeat()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_gN_then_gn()
|
||||||
|
new
|
||||||
|
|
||||||
|
call setline(1, 'this list is a list with a list of a last.')
|
||||||
|
/l.st
|
||||||
|
normal $gNgNgnx
|
||||||
|
call assert_equal('last', @")
|
||||||
|
|
||||||
|
call setline(1, 'this list is a list with a lust of a last.')
|
||||||
|
/l.st
|
||||||
|
normal $gNgNgNgnx
|
||||||
|
call assert_equal('lust of a last', @")
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_gn_multi_line()
|
func Test_gn_multi_line()
|
||||||
new
|
new
|
||||||
call setline(1, [
|
call setline(1, [
|
||||||
|
Loading…
Reference in New Issue
Block a user