mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.1684: "gF" does not use line number after file in Visual mode
Problem: "gF" does not use line number after file in Visual mode.
Solution: Look for ":123" after the Visual area. (closes vim/vim#6952)
efd5d8a967
Cherry-pick test_gf_visual changes from patch 8.2.1040.
This commit is contained in:
parent
cc484928d5
commit
eb981a01e3
@ -1,3 +1,4 @@
|
|||||||
|
" Test for the gf and gF (goto file) commands
|
||||||
|
|
||||||
" This is a test if a URL is recognized by "gf", with the cursor before and
|
" This is a test if a URL is recognized by "gf", with the cursor before and
|
||||||
" after the "://". Also test ":\\".
|
" after the "://". Also test ":\\".
|
||||||
@ -109,7 +110,7 @@ func Test_gf()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_gf_visual()
|
func Test_gf_visual()
|
||||||
call writefile([], "Xtest_gf_visual")
|
call writefile(['one', 'two', 'three', 'four'], "Xtest_gf_visual")
|
||||||
new
|
new
|
||||||
call setline(1, 'XXXtest_gf_visualXXX')
|
call setline(1, 'XXXtest_gf_visualXXX')
|
||||||
set hidden
|
set hidden
|
||||||
@ -118,6 +119,30 @@ func Test_gf_visual()
|
|||||||
norm! ttvtXgf
|
norm! ttvtXgf
|
||||||
call assert_equal('Xtest_gf_visual', bufname('%'))
|
call assert_equal('Xtest_gf_visual', bufname('%'))
|
||||||
|
|
||||||
|
" if multiple lines are selected, then gf should fail
|
||||||
|
call setline(1, ["one", "two"])
|
||||||
|
normal VGgf
|
||||||
|
call assert_equal('Xtest_gf_visual', @%)
|
||||||
|
|
||||||
|
" following line number is used for gF
|
||||||
|
bwipe!
|
||||||
|
new
|
||||||
|
call setline(1, 'XXXtest_gf_visual:3XXX')
|
||||||
|
norm! 0ttvt:gF
|
||||||
|
call assert_equal('Xtest_gf_visual', bufname('%'))
|
||||||
|
call assert_equal(3, getcurpos()[1])
|
||||||
|
|
||||||
|
" line number in visual area is used for file name
|
||||||
|
if has('unix')
|
||||||
|
bwipe!
|
||||||
|
call writefile([], "Xtest_gf_visual:3")
|
||||||
|
new
|
||||||
|
call setline(1, 'XXXtest_gf_visual:3XXX')
|
||||||
|
norm! 0ttvtXgF
|
||||||
|
call assert_equal('Xtest_gf_visual:3', bufname('%'))
|
||||||
|
call delete('Xtest_gf_visual:3')
|
||||||
|
endif
|
||||||
|
|
||||||
bwipe!
|
bwipe!
|
||||||
call delete('Xtest_gf_visual')
|
call delete('Xtest_gf_visual')
|
||||||
set hidden&
|
set hidden&
|
||||||
|
@ -6019,6 +6019,12 @@ char_u *grab_file_name(long count, linenr_T *file_lnum)
|
|||||||
char_u *ptr;
|
char_u *ptr;
|
||||||
if (get_visual_text(NULL, &ptr, &len) == FAIL)
|
if (get_visual_text(NULL, &ptr, &len) == FAIL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
// Only recognize ":123" here
|
||||||
|
if (file_lnum != NULL && ptr[len] == ':' && isdigit(ptr[len + 1])) {
|
||||||
|
char_u *p = ptr + len + 1;
|
||||||
|
|
||||||
|
*file_lnum = getdigits_long(&p, false, 0);
|
||||||
|
}
|
||||||
return find_file_name_in_path(ptr, len, options, count, curbuf->b_ffname);
|
return find_file_name_in_path(ptr, len, options, count, curbuf->b_ffname);
|
||||||
}
|
}
|
||||||
return file_name_at_cursor(options | FNAME_HYP, count, file_lnum);
|
return file_name_at_cursor(options | FNAME_HYP, count, file_lnum);
|
||||||
|
Loading…
Reference in New Issue
Block a user