]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0287: filetype: not all ObjectScript routines are recognized v9.2.0287
authorHannah <hannah.kimura@intersystems.com>
Fri, 3 Apr 2026 09:10:09 +0000 (09:10 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 3 Apr 2026 09:14:43 +0000 (09:14 +0000)
Problem:  filetype: not all ObjectScript routines are recognized
Solution: Also detect "%RO" and "iris" patterns inside *.rtn files
          (Hannah Kimura)

closes: #19873

Signed-off-by: Hannah Kimura <hannah.kimura@intersystems.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/autoload/dist/ft.vim
src/testdir/test_filetype.vim
src/version.c

index 20495866b3d23977e3bd00267e1c2a6fe351e098..b1c209400ec7fa1347fd25569b56e7084fc08117 100644 (file)
@@ -3,7 +3,7 @@ vim9script
 # Vim functions for file type detection
 #
 # Maintainer:          The Vim Project <https://github.com/vim/vim>
-# Last Change:         2026 Mar 24
+# Last Change:         2026 Apr 03
 # Former Maintainer:   Bram Moolenaar <Bram@vim.org>
 
 # These functions are moved here from runtime/filetype.vim to make startup
@@ -14,7 +14,13 @@ var prolog_pattern = '^\s*\(:-\|%\+\(\s\|$\)\|\/\*\)\|\.\s*$'
 def IsObjectScriptRoutine(): bool
   var line1 = getline(1)
   line1 = substitute(line1, '^\ufeff', '', '')
-  return line1 =~? '^\s*routine\>\s\+[%A-Za-z][%A-Za-z0-9_.]*\%(\s*\[\|\s*;\|$\)'
+  if line1 =~? '^\s*routine\>'
+    return true
+  endif
+  if line1 =~? '\<iris\>'
+    return true
+  endif
+  return join(getline(1, 3), '') =~# '%RO'
 enddef
 
 export def Check_inp()
@@ -2669,6 +2675,8 @@ const ft_from_ext = {
   "rst": "rst",
   # RTF
   "rtf": "rtf",
+  # ObjectScript Routine
+  "rtn": "objectscript_routine",
   # Ruby
   "rb": "ruby",
   "rbw": "ruby",
index e24471b6f273b441400ee3037f27ef813b1cc130..6bd96aed3a19bfe00cfd99d721e2baf292932e9c 100644 (file)
@@ -600,6 +600,7 @@ def s:GetFilenameChecks(): dict<list<string>>
     numbat: ['file.nbt'],
     obj: ['file.obj'],
     objdump: ['file.objdump', 'file.cppobjdump'],
+    objectscript_routine: ['file.rtn'],
     obse: ['file.obl', 'file.obse', 'file.oblivion', 'file.obscript'],
     ocaml: ['file.ml', 'file.mli', 'file.mll', 'file.mly', '.ocamlinit', 'file.mlt', 'file.mlp', 'file.mlip', 'file.mli.cppo', 'file.ml.cppo'],
     occam: ['file.occ'],
@@ -2885,6 +2886,24 @@ func Test_int_file()
   call assert_equal('objectscript_routine', &filetype)
   bwipe!
 
+  " ObjectScript routine by IRIS marker in first line
+  call writefile(['Exported from IRIS source control'], 'Xfile.int', 'D')
+  split Xfile.int
+  call assert_equal('objectscript_routine', &filetype)
+  bwipe!
+
+  " Not ObjectScript routine by partial IRIS match in first line
+  call writefile(['Exported from IRISation source control'], 'Xfile.int', 'D')
+  split Xfile.int
+  call assert_equal('hex', &filetype)
+  bwipe!
+
+  " ObjectScript routine by %RO marker in first three lines
+  call writefile(['; generated file', '%RO routine metadata'], 'Xfile.int', 'D')
+  split Xfile.int
+  call assert_equal('objectscript_routine', &filetype)
+  bwipe!
+
   let g:filetype_int = 'foo'
   split Xfile.int
   call assert_equal('foo', &filetype)
index 65518999e52075214f03e6137b83994c61b16f7c..a3f4f24a9a9b7229e70434ae7c87411e6e228d2d 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    287,
 /**/
     286,
 /**/