patch 9.0.1773: cannot distinguish Forth and Fortran *.f files
Problem: cannot distinguish Forth and Fortran *.f files
Solution: Add Filetype detection Code
Also add *.4th as a Forth filetype
closes: #12251
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Doug Kearns <dougkearns@gmail.com>
diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
index 778736b..a8ce88c 100644
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -246,7 +246,7 @@
fish: ['file.fish'],
focexec: ['file.fex', 'file.focexec'],
form: ['file.frm'],
- forth: ['file.ft', 'file.fth'],
+ forth: ['file.ft', 'file.fth', 'file.4th'],
fortran: ['file.f', 'file.for', 'file.fortran', 'file.fpp', 'file.ftn', 'file.f77', 'file.f90', 'file.f95', 'file.f03', 'file.f08'],
fpcmake: ['file.fpc'],
framescript: ['file.fsl'],
@@ -1265,6 +1265,54 @@
filetype off
endfunc
+func Test_f_file()
+ filetype on
+
+ call writefile(['looks like Fortran'], 'Xfile.f', 'D')
+ split Xfile.f
+ call assert_equal('fortran', &filetype)
+ bwipe!
+
+ let g:filetype_f = 'forth'
+ split Xfile.f
+ call assert_equal('forth', &filetype)
+ bwipe!
+ unlet g:filetype_f
+
+ " Test dist#ft#FTf()
+
+ " Forth
+
+ call writefile(['( Forth inline comment )'], 'Xfile.f')
+ split Xfile.f
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call writefile(['\ Forth line comment'], 'Xfile.f')
+ split Xfile.f
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call writefile([': squared ( n -- n^2 )', 'dup * ;'], 'Xfile.f')
+ split Xfile.f
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ " SwiftForth
+
+ call writefile(['{ ================', 'Header comment', '================ }'], 'Xfile.f')
+ split Xfile.f
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call writefile(['OPTIONAL Maybe Descriptive text'], 'Xfile.f')
+ split Xfile.f
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ filetype off
+endfunc
+
func Test_foam_file()
filetype on
call assert_true(mkdir('0', 'pR'))
@@ -1355,7 +1403,7 @@
" Test dist#ft#FTfs()
- " Forth (Gforth)
+ " Forth
call writefile(['( Forth inline comment )'], 'Xfile.fs')
split Xfile.fs
@@ -1372,6 +1420,18 @@
call assert_equal('forth', &filetype)
bwipe!
+ " SwiftForth
+
+ call writefile(['{ ================', 'Header comment', '================ }'], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call writefile(['OPTIONAL Maybe Descriptive text'], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+
filetype off
endfunc
diff --git a/src/version.c b/src/version.c
index 13d27f4..ffecee9 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1773,
+/**/
1772,
/**/
1771,