mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
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 #12553)
This commit is contained in:
parent
545c8a506e
commit
c12e4eecbb
@ -21,7 +21,7 @@ au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.dpkg-dist,?\+.dpkg-ol
|
||||
\ 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 |
|
||||
|
@ -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
|
||||
|
@ -695,6 +695,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1643,
|
||||
/**/
|
||||
1642,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user