]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0155: filetype: ObjectScript are not recognized v9.2.0155
authorHannah <hannah.kimura@intersystems.com>
Fri, 13 Mar 2026 21:04:26 +0000 (21:04 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 13 Mar 2026 21:08:42 +0000 (21:08 +0000)
Problem:  filetype: ObjectScript are not recognized
Solution: Add ObjectScript filetype detection for *.cls files
          (Hannah Kimura)).

Reference:
https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GCOS_intro

closes: #19668

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

index 6cfcd350d777485cb23947648910052160ea4389..a90655febc3630e0ffc466f4c0e68a87f8a88749 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 Feb 24
+# Last Change:         2026 Mar 13
 # Former Maintainer:   Bram Moolenaar <Bram@vim.org>
 
 # These functions are moved here from runtime/filetype.vim to make startup
@@ -195,6 +195,7 @@ export def FTcl()
   endif
 enddef
 
+# Determines whether a *.cls file is ObjectScript, TeX, Rexx, Visual Basic, or Smalltalk.
 export def FTcls()
   if exists("g:filetype_cls")
     exe "setf " .. g:filetype_cls
@@ -211,7 +212,20 @@ export def FTcls()
   endif
 
   var nonblank1 = getline(nextnonblank(1))
-  if nonblank1 =~ '^\v%(\%|\\)'
+  var lnum = nextnonblank(1)
+  while lnum > 0 && lnum <= line("$")
+    var line = getline(lnum)
+    if line =~? '^\s*\%(import\|include\|includegenerator\)\>'
+      lnum = nextnonblank(lnum + 1)
+    else
+      nonblank1 = line
+      break
+    endif
+  endwhile
+
+  if nonblank1 =~? '^\s*class\>\s\+[%A-Za-z][%A-Za-z0-9_.]*\%(\s\+extends\>\|\s*\[\|\s*{\|$\)'
+    setf objectscript
+  elseif nonblank1 =~ '^\v%(\%|\\)'
     setf tex
   elseif nonblank1 =~ '^\s*\%(/\*\|::\w\)'
     setf rexx
index 4bdecfc7c3189076e73bdf1e8982253981b76e28..3031afdd66e9c00b3f567225d9253d4e26a85c84 100644 (file)
@@ -1054,7 +1054,7 @@ au BufNewFile,BufRead *.scm,*.ss,*.sld,*.stsg,*/supertux2/config,.lips_repl_hist
 " SiSU
 au BufNewFile,BufRead *.sst.meta,*.-sst.meta,*._sst.meta setf sisu
 
-" Smalltalk (and Rexx, TeX, and Visual Basic)
+" Smalltalk (and ObjectScript, Rexx, TeX, and Visual Basic)
 au BufNewFile,BufRead *.cls                    call dist#ft#FTcls()
 
 " SMIL or XML
index 5ffc11802a9453f9796edb2d17935e69a7fc2aa1..125833cb93bb175f236cb7f96752ebd96a019926 100644 (file)
@@ -2564,6 +2564,39 @@ func Test_cls_file()
   bwipe!
   unlet g:filetype_cls
 
+  let g:filetype_cls = 'objectscript'
+  split Xfile.cls
+  call assert_equal('objectscript', &filetype)
+  bwipe!
+  unlet g:filetype_cls
+
+  " ObjectScript
+
+  call writefile(['Class User.Person Extends (%Persistent, %Populate)'], 'Xfile.cls')
+  split Xfile.cls
+  call assert_equal('objectscript', &filetype)
+  bwipe!
+
+  call writefile(['Import MyApp.Utils', 'Class User.Person Extends %Persistent'], 'Xfile.cls')
+  split Xfile.cls
+  call assert_equal('objectscript', &filetype)
+  bwipe!
+
+  call writefile(['Include MyMacros', 'Class User.Person Extends %Persistent'], 'Xfile.cls')
+  split Xfile.cls
+  call assert_equal('objectscript', &filetype)
+  bwipe!
+
+  call writefile(['IncludeGenerator MyGen', 'Class User.Person Extends %Persistent'], 'Xfile.cls')
+  split Xfile.cls
+  call assert_equal('objectscript', &filetype)
+  bwipe!
+
+  call writefile(['Import MyApp.Utils', 'Include MyMacros', 'IncludeGenerator MyGen', 'Class User.Person Extends %Persistent'], 'Xfile.cls')
+  split Xfile.cls
+  call assert_equal('objectscript', &filetype)
+  bwipe!
+
   " TeX
 
   call writefile(['%'], 'Xfile.cls')
index ae999c903b858f96ebba40f12e13b97ca7822c31..c9de55cdec026124bfe9150b317830ffc7f8b02c 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    155,
 /**/
     154,
 /**/