changeset 28483:62a0dd56466c v8.2.4766

patch 8.2.4766: KRL files using "deffct" not recognized Commit: https://github.com/vim/vim/commit/93c7a45e86934a92ec513b437fe9b8cc343c53e3 Author: KnoP-01 <knosowski@graeffrobotics.de> Date: Sat Apr 16 21:14:04 2022 +0100 patch 8.2.4766: KRL files using "deffct" not recognized Problem: KRL files using "deffct" not recognized. Solution: Adjust the pattern used for matching. (Patrick Meiser-Knosowski, closes #10200)
author Bram Moolenaar <Bram@vim.org>
date Sat, 16 Apr 2022 22:15:03 +0200
parents b5ac0d0ae268
children 5af8342103c4
files runtime/autoload/dist/ft.vim src/testdir/test_filetype.vim src/version.c
diffstat 3 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -989,20 +989,23 @@ export def FTtf()
   setf tf
 enddef
 
+var ft_krl_header = '\&\w+'
 # Determine if a *.src file is Kuka Robot Language
 export def FTsrc()
+  var ft_krl_def_or_deffct = '%(global\s+)?def%(fct)?>'
   if exists("g:filetype_src")
     exe "setf " .. g:filetype_src
-  elseif getline(nextnonblank(1)) =~? '^\s*\%(&\w\+\|\%(global\s\+\)\?def\>\)'
+  elseif getline(nextnonblank(1)) =~? '\v^\s*%(' .. ft_krl_header .. '|' .. ft_krl_def_or_deffct .. ')'
     setf krl
   endif
 enddef
 
 # Determine if a *.dat file is Kuka Robot Language
 export def FTdat()
+  var ft_krl_defdat = 'defdat>'
   if exists("g:filetype_dat")
     exe "setf " .. g:filetype_dat
-  elseif getline(nextnonblank(1)) =~? '^\s*\%(&\w\+\|defdat\>\)'
+  elseif getline(nextnonblank(1)) =~? '\v^\s*%(' .. ft_krl_header .. '|' .. ft_krl_defdat .. ')'
     setf krl
   endif
 enddef
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -768,7 +768,7 @@ func Test_filetype_indent_off()
 endfunc
 
 """""""""""""""""""""""""""""""""""""""""""""""""
-" Tests for specific extentions and filetypes.
+" Tests for specific extensions and filetypes.
 " Keep sorted.
 """""""""""""""""""""""""""""""""""""""""""""""""
 
@@ -1562,11 +1562,13 @@ func Test_src_file()
   bwipe!
   call delete('srcfile.Src')
 
-  " KRL global def with embedded spaces, file starts with empty line(s).
-  call writefile(['', 'global  def  srcfile()'], 'srcfile.SRC')
-  split srcfile.SRC
-  call assert_equal('krl', &filetype)
-  bwipe!
+  " KRL global deffct with embedded spaces, file starts with empty line(s).
+  for text in ['global  def  srcfile()', 'global  deffct  srcfile()']
+    call writefile(['', text], 'srcfile.SRC')
+    split srcfile.SRC
+    call assert_equal('krl', &filetype, text)
+    bwipe!
+  endfor
 
   " User may overrule file inspection
   let g:filetype_src = 'src'
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    4766,
+/**/
     4765,
 /**/
     4764,