Mercurial > vim
changeset 32623:2cd120c9daba v9.0.1643
patch 9.0.1643: filetype detection fails if file name ends in many '~'
Commit: https://github.com/vim/vim/commit/c12e4eecbb26cedca96e0810d3501043356eebaa
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 22 12:18:57 2023 +0100
patch 9.0.1643: filetype detection fails if file name ends in many '~'
Problem: Filetype detection fails if file name ends in many '~'.
Solution: Strip multiple '~' at the same time. (closes https://github.com/vim/vim/issues/12553)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 22 Jun 2023 13:30:05 +0200 |
parents | dfe2a1a0824c |
children | d1de2966b84f |
files | runtime/filetype.vim src/testdir/test_filetype.vim src/version.c |
diffstat | 3 files changed, 14 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -21,7 +21,7 @@ au BufNewFile,BufRead ?\+.orig,?\+.bak,? \ exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r")) au BufNewFile,BufRead *~ \ let s:name = expand("<afile>") | - \ 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 |
--- 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