summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author=?UTF-8?q?Teubel=20Gy=C3=B6rgy?= <tgyurci@gmail.com>2022-02-24 17:59:09 +0000
committerBram Moolenaar <Bram@vim.org>2022-02-24 17:59:09 +0000
commit4d56b971cbae01cc454eb09713326224993e38ed (patch)
treee8ad0386cf93d936903fe72b0e0443a7c79d9b5f
parent38b85cb4d7216705058708bacbc25ab90cd61595 (diff)
downloadvim-git-4d56b971cbae01cc454eb09713326224993e38ed.tar.gz
patch 8.2.4464: Dtrace files are recognized as filetype Dv8.2.4464
Problem: Dtrace files are recognized as filetype D. Solution: Add a pattern for Dtrace files. (Teubel György, closes #9841) Add some more testing.
-rw-r--r--runtime/autoload/dist/ft.vim4
-rw-r--r--runtime/filetype.vim1
-rw-r--r--src/testdir/test_filetype.vim38
-rw-r--r--src/version.c2
4 files changed, 45 insertions, 0 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 4f5b88a7f..9f9fef042 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -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.
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 3b7f92dff..77c736c18 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -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
diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
index 01978ef3f..9614f55fe 100644
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index 1491e81da..69be8cd05 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4464,
+/**/
4463,
/**/
4462,