Skip to content

Commit 863e85e

Browse files
hkimura-intersyschrisbra
authored andcommitted
patch 9.2.0287: filetype: not all ObjectScript routines are recognized
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 <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent aca677d commit 863e85e

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

runtime/autoload/dist/ft.vim

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ vim9script
33
# Vim functions for file type detection
44
#
55
# Maintainer: The Vim Project <https://github.com/vim/vim>
6-
# Last Change: 2026 Mar 24
6+
# Last Change: 2026 Apr 03
77
# Former Maintainer: Bram Moolenaar <[email protected]>
88

99
# These functions are moved here from runtime/filetype.vim to make startup
@@ -14,7 +14,13 @@ var prolog_pattern = '^\s*\(:-\|%\+\(\s\|$\)\|\/\*\)\|\.\s*$'
1414
def IsObjectScriptRoutine(): bool
1515
var line1 = getline(1)
1616
line1 = substitute(line1, '^\ufeff', '', '')
17-
return line1 =~? '^\s*routine\>\s\+[%A-Za-z][%A-Za-z0-9_.]*\%(\s*\[\|\s*;\|$\)'
17+
if line1 =~? '^\s*routine\>'
18+
return true
19+
endif
20+
if line1 =~? '\<iris\>'
21+
return true
22+
endif
23+
return join(getline(1, 3), '') =~# '%RO'
1824
enddef
1925

2026
export def Check_inp()
@@ -2669,6 +2675,8 @@ const ft_from_ext = {
26692675
"rst": "rst",
26702676
# RTF
26712677
"rtf": "rtf",
2678+
# ObjectScript Routine
2679+
"rtn": "objectscript_routine",
26722680
# Ruby
26732681
"rb": "ruby",
26742682
"rbw": "ruby",

src/testdir/test_filetype.vim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ def s:GetFilenameChecks(): dict<list<string>>
600600
numbat: ['file.nbt'],
601601
obj: ['file.obj'],
602602
objdump: ['file.objdump', 'file.cppobjdump'],
603+
objectscript_routine: ['file.rtn'],
603604
obse: ['file.obl', 'file.obse', 'file.oblivion', 'file.obscript'],
604605
ocaml: ['file.ml', 'file.mli', 'file.mll', 'file.mly', '.ocamlinit', 'file.mlt', 'file.mlp', 'file.mlip', 'file.mli.cppo', 'file.ml.cppo'],
605606
occam: ['file.occ'],
@@ -2885,6 +2886,24 @@ func Test_int_file()
28852886
call assert_equal('objectscript_routine', &filetype)
28862887
bwipe!
28872888

2889+
" ObjectScript routine by IRIS marker in first line
2890+
call writefile(['Exported from IRIS source control'], 'Xfile.int', 'D')
2891+
split Xfile.int
2892+
call assert_equal('objectscript_routine', &filetype)
2893+
bwipe!
2894+
2895+
" Not ObjectScript routine by partial IRIS match in first line
2896+
call writefile(['Exported from IRISation source control'], 'Xfile.int', 'D')
2897+
split Xfile.int
2898+
call assert_equal('hex', &filetype)
2899+
bwipe!
2900+
2901+
" ObjectScript routine by %RO marker in first three lines
2902+
call writefile(['; generated file', '%RO routine metadata'], 'Xfile.int', 'D')
2903+
split Xfile.int
2904+
call assert_equal('objectscript_routine', &filetype)
2905+
bwipe!
2906+
28882907
let g:filetype_int = 'foo'
28892908
split Xfile.int
28902909
call assert_equal('foo', &filetype)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
287,
737739
/**/
738740
286,
739741
/**/

0 commit comments

Comments
 (0)