diff options
-rw-r--r-- | runtime/lua/vim/filetype.lua | 2 | ||||
-rw-r--r-- | test/old/testdir/test_filetype.vim | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 86374b26e5..190071bbc7 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -2064,7 +2064,7 @@ local pattern = { ['%.?zsh.*'] = starsetf('zsh'), -- Ignored extension ['.*~'] = function(path, bufnr) - local short = path:gsub('~$', '', 1) + local short = path:gsub('~+$', '', 1) if path ~= short and short ~= '' then return M.match({ buf = bufnr, filename = fn.fnameescape(short) }) end diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 4f2980d1bb..a51cf4eef0 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -1,5 +1,16 @@ " Test :setfiletype +func Test_backup_strip() + filetype on + let fname = 'Xdetect.js~~~~~~~~~~~' + call writefile(['one', 'two', 'three'], fname, 'D') + exe 'edit ' .. fname + call assert_equal('javascript', &filetype) + + bwipe! + filetype off +endfunc + func Test_detection() filetype on augroup filetypedetect |