File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,7 +22,23 @@ function M.setup(user_config)
2222end
2323
2424function M .init ()
25+ -- Fix the strange behavior that "<afile>" expands non-files
26+ -- as file name in some cases.
27+ --
28+ -- Ref:
29+ -- * sindrets/diffview.nvim#369
30+ -- * neovim/neovim#23943
31+ local function get_tabnr (state )
32+ if vim .fn .has (" nvim-0.9.2" ) ~= 1 then
33+ return tonumber (state .match )
34+ else
35+ return tonumber (state .file )
36+ end
37+ end
38+
2539 local au = api .nvim_create_autocmd
40+
41+ -- Set up highlighting
2642 hl .setup ()
2743
2844 -- Set up autocommands
@@ -45,7 +61,7 @@ function M.init()
4561 group = M .augroup ,
4662 pattern = " *" ,
4763 callback = function (state )
48- M .close (tonumber (state . file ))
64+ M .close (get_tabnr (state ))
4965 end ,
5066 })
5167 au (" BufWritePost" , {
@@ -59,7 +75,7 @@ function M.init()
5975 group = M .augroup ,
6076 pattern = " *" ,
6177 callback = function (state )
62- M .emit (" win_closed" , tonumber (state . file ))
78+ M .emit (" win_closed" , get_tabnr (state ))
6379 end ,
6480 })
6581 au (" ColorScheme" , {
You can’t perform that action at this time.
0 commit comments