Patch 9.0.1643
Problem: Filetype detection fails if file name ends in many '~'.
Solution: Strip multiple '~' at the same time. (closes #12553)
Files: runtime/filetype.vim, src/testdir/test_filetype.vim
*** ../vim-9.0.1642/runtime/filetype.vim 2023-06-14 19:45:39.534903626 +0100
--- runtime/filetype.vim 2023-06-22 12:09:00.993020216 +0100
***************
*** 21,27 ****
\ exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r"))
au BufNewFile,BufRead *~
\ let s:name = expand("<afile>") |
! \ let s:short = substitute(s:name, '\~$', '', '') |
\ if s:name != s:short && s:short != "" |
\ exe "doau filetypedetect BufRead " . fnameescape(s:short) |
\ endif |
--- 21,27 ----
\ exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r"))
au BufNewFile,BufRead *~
\ let s:name = expand("<afile>") |
! \ let s:short = substitute(s:name, '\~\+$', '', '') |
\ if s:name != s:short && s:short != "" |
\ exe "doau filetypedetect BufRead " . fnameescape(s:short) |
\ endif |
*** ../vim-9.0.1642/src/testdir/test_filetype.vim 2023-06-14 19:45:39.534903626 +0100
--- src/testdir/test_filetype.vim 2023-06-22 12:14:33.692618543 +0100
***************
*** 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
*** ../vim-9.0.1642/src/version.c 2023-06-21 15:51:43.278744288 +0100
--- src/version.c 2023-06-22 12:16:52.676468207 +0100
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1643,
/**/
--
$ echo pizza > /dev/oven
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///