Mercurial > vim
changeset 22270:d37e4a856246 v8.2.1684
patch 8.2.1684: "gF" does not use line number after file in Visual mode
Commit: https://github.com/vim/vim/commit/efd5d8a967ba80f9e2826c35be98344d8f00af77
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Sep 14 19:11:45 2020 +0200
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 https://github.com/vim/vim/issues/6952)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 14 Sep 2020 19:15:03 +0200 |
parents | 314411e1091e |
children | 0440d470ae70 |
files | src/findfile.c src/testdir/test_gf.vim src/version.c |
diffstat | 3 files changed, 29 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/findfile.c +++ b/src/findfile.c @@ -1934,6 +1934,13 @@ grab_file_name(long count, linenr_T *fil if (get_visual_text(NULL, &ptr, &len) == FAIL) 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(&p); + } return find_file_name_in_path(ptr, len, options, count, curbuf->b_ffname); }
--- a/src/testdir/test_gf.vim +++ b/src/testdir/test_gf.vim @@ -124,7 +124,7 @@ func Test_gf() endfunc func Test_gf_visual() - call writefile([], "Xtest_gf_visual") + call writefile(['one', 'two', 'three', 'four'], "Xtest_gf_visual") new call setline(1, 'XXXtest_gf_visualXXX') set hidden @@ -138,6 +138,25 @@ func Test_gf_visual() 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! call delete('Xtest_gf_visual') set hidden&