Commit: runtime(vimgoto): Fix gf in Vim script

0 views
Skip to first unread message

Christian Brabandt

unread,
Feb 10, 2026, 5:01:39 PM (17 hours ago) Feb 10
to vim...@googlegroups.com
runtime(vimgoto): Fix gf in Vim script

Commit: https://github.com/vim/vim/commit/92053449d42b4e5c0cea44d343947a01516fcc63
Author: thinca <thi...@gmail.com>
Date: Tue Feb 10 22:52:58 2026 +0100

runtime(vimgoto): Fix gf in Vim script

Problem: `gf` in Vim script fails if multiple target files exist.
Solution: Use globpath() which returns an array.

In a Vim script, `gf` on `some#func()` will jump to `autoload/some.vim`.
In this case, if there are multiple `autoload/foo.vim`s in
'runtimepath', `globpath(&runtimepath, path)` will return multiple
paths, separated by newlines.
As a result, the second and subsequent paths will be executed as
commands in `autoload/vimgoto.vim:195`, causing an error.
This change fixes this issue by making the result of `globpath()` an
array.

closes: #19379

Signed-off-by: thinca <thi...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/autoload/vimgoto.vim b/runtime/autoload/vimgoto.vim
index cb41cc7de..32756e07d 100644
--- a/runtime/autoload/vimgoto.vim
+++ b/runtime/autoload/vimgoto.vim
@@ -4,7 +4,8 @@ vim9script
# Contributers: @lacygoill
# Shane-XB-Qian
# Andrew Radev
-# Last Change: 2025 Oct 17
+# thinca
+# Last Change: 2026 Feb 10
#
# Vim script to handle jumping to the targets of several types of Vim commands
# (:import, :packadd, :runtime, :colorscheme), and to autoloaded functions of
@@ -41,9 +42,9 @@ export def Find(editcmd: string) #{{{2
if stridx(curfunc, '#') >= 0
var parts = split(curfunc, '#')
var path = $"autoload/{join(parts[0 : -2], '/')}.vim"
- var resolved_path = globpath(&runtimepath, path)
+ var resolved_path = globpath(&runtimepath, path, 1, 1)

- if resolved_path != ''
+ if !resolved_path->empty()
var function_pattern: string = $'^\s*\%(:\s*\)\=fun\%[ction]!\=\s\+\zs{curfunc}('
resolved_path->Open(editcmd, function_pattern)
endif
Reply all
Reply to author
Forward
0 new messages