diff --git a/runtime/filetype.vim b/runtime/filetype.vim index c93ce5eaeb..9daf5a3cbb 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -21,7 +21,7 @@ au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.dpkg-dist,?\+.dpkg-ol \ exe "doau filetypedetect BufRead " . fnameescape(expand(":r")) au BufNewFile,BufRead *~ \ let s:name = expand("") | - \ let s:short = substitute(s:name, '\~$', '', '') | + \ let s:short = substitute(s:name, '\~\+$', '', '') | \ if s:name != s:short && s:short != "" | \ exe "doau filetypedetect BufRead " . fnameescape(s:short) | \ endif | diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim index 41b9106136..9c1b11d2a0 100644 --- a/src/testdir/test_filetype.vim +++ b/src/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 diff --git a/src/version.c b/src/version.c index 1d29427018..c5aa47af60 100644 --- a/src/version.c +++ b/src/version.c @@ -695,6 +695,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1643, /**/ 1642, /**/