fix(events): don't expand args.file for Lua callback (#31473)

Problem:  In an autocommand Lua callback whether `args.file` is expanded
          depends on whether `expand('<afile>')` has been called.
Solution: Always use the unexpanded file name for `args.file`.

Related to #31306 and vim/vim#16106. This doesn't provide `sfname`, but
at least makes `args.file` have a consistent value.
This commit is contained in:
zeertzjq
2024-12-06 20:01:28 +08:00
parent 650dcbbafe
commit 71faa2be88
6 changed files with 49 additions and 26 deletions

View File

@@ -956,9 +956,9 @@ function vim.api.nvim_create_augroup(name, opts) end
--- • event: (string) name of the triggered event
--- `autocmd-events`
--- • group: (number|nil) autocommand group id, if any
--- • match: (string) expanded value of <amatch>
--- • buf: (number) expanded value of <abuf>
--- • file: (string) expanded value of <afile>
--- • file: (string) <afile> (not expanded to a full path)
--- • match: (string) <amatch> (expanded to a full path)
--- • buf: (number) <abuf>
--- • data: (any) arbitrary data passed from
--- `nvim_exec_autocmds()` *event-data*
--- • command (string) optional: Vim command to execute on event.