1
0
forked from aniani/vim

patch 8.2.4464: Dtrace files are recognized as filetype D

Problem:    Dtrace files are recognized as filetype D.
Solution:   Add a pattern for Dtrace files. (Teubel György, closes #9841)
            Add some more testing.
This commit is contained in:
=?UTF-8?q?Teubel=20Gy=C3=B6rgy?=
2022-02-24 17:59:09 +00:00
committed by Bram Moolenaar
parent 38b85cb4d7
commit 4d56b971cb
4 changed files with 45 additions and 0 deletions

View File

@@ -206,6 +206,10 @@ export def EuphoriaCheck()
enddef
export def DtraceCheck()
if did_filetype()
# Filetype was already detected
return
endif
var lines = getline(1, min([line("$"), 100]))
if match(lines, '^module\>\|^import\>') > -1
# D files often start with a module and/or import statement.

View File

@@ -484,6 +484,7 @@ au BufNewFile,BufRead */etc/dnsmasq.conf setf dnsmasq
au BufNewFile,BufRead *.desc setf desc
" the D language or dtrace
au BufNewFile,BufRead */dtrace/*.d setf dtrace
au BufNewFile,BufRead *.d call dist#ft#DtraceCheck()
" Desktop files

View File

@@ -132,6 +132,7 @@ let s:filename_checks = {
\ 'cvs': ['cvs123'],
\ 'cvsrc': ['.cvsrc'],
\ 'cynpp': ['file.cyn'],
\ 'd': ['file.d'],
\ 'dart': ['file.dart', 'file.drt'],
\ 'datascript': ['file.ds'],
\ 'dcd': ['file.dcd'],
@@ -154,6 +155,7 @@ let s:filename_checks = {
\ 'dot': ['file.dot', 'file.gv'],
\ 'dracula': ['file.drac', 'file.drc', 'filelvs', 'filelpe', 'drac.file', 'lpe', 'lvs', 'some-lpe', 'some-lvs'],
\ 'dtd': ['file.dtd'],
\ 'dtrace': ['/usr/lib/dtrace/io.d'],
\ 'dts': ['file.dts', 'file.dtsi'],
\ 'dune': ['jbuild', 'dune', 'dune-project', 'dune-workspace'],
\ 'dylan': ['file.dylan'],
@@ -827,6 +829,42 @@ func Test_bas_file()
filetype off
endfunc
func Test_d_file()
filetype on
call writefile(['looks like D'], 'Xfile.d')
split Xfile.d
call assert_equal('d', &filetype)
bwipe!
call writefile(['#!/some/bin/dtrace'], 'Xfile.d')
split Xfile.d
call assert_equal('dtrace', &filetype)
bwipe!
call writefile(['#pragma D option'], 'Xfile.d')
split Xfile.d
call assert_equal('dtrace', &filetype)
bwipe!
call writefile([':some:thing:'], 'Xfile.d')
split Xfile.d
call assert_equal('dtrace', &filetype)
bwipe!
call writefile(['module this', '#pragma D option'], 'Xfile.d')
split Xfile.d
call assert_equal('d', &filetype)
bwipe!
call writefile(['import that', '#pragma D option'], 'Xfile.d')
split Xfile.d
call assert_equal('d', &filetype)
bwipe!
filetype off
endfunc
func Test_dep3patch_file()
filetype on

View File

@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4464,
/**/
4463,
/**/