mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.0.1643: filetype detection fails if file name ends in many '~' (#28141)
Problem: Filetype detection fails if file name ends in many '~'.
Solution: Strip multiple '~' at the same time. (closes vim/vim#12553)
c12e4eecbb
In Nvim this already works as Lua filetype detection isn't subject to
such a small recursion limit as autocommands, but it still makes sense
to avoid unnecessary recursion.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
2e97ae2664
commit
381806729d
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user