changeset 31449:429bed14e24b v9.0.1057

patch 9.0.1057: conflict between supercollider and scala filetype detection Commit: https://github.com/vim/vim/commit/70ef3f546b6ef83e463e91b7e388d9c68ad58894 Author: Chris Kipp <ckipp@pm.me> Date: Wed Dec 14 16:42:15 2022 +0000 patch 9.0.1057: conflict between supercollider and scala filetype detection Problem: Conflict between supercollider and scala filetype detection. Solution: Do not check for "Class : Method", it can appear in both filetypes. (Chris Kipp, closes #11699)
author Bram Moolenaar <Bram@vim.org>
date Wed, 14 Dec 2022 17:45:03 +0100
parents fd808b005553
children 548b0a3e0c97
files runtime/autoload/dist/ft.vim src/testdir/test_filetype.vim src/version.c
diffstat 3 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -810,10 +810,13 @@ export def SQL()
 enddef
 
 # This function checks the first 25 lines of file extension "sc" to resolve
-# detection between scala and SuperCollider
+# detection between scala and SuperCollider.
+# NOTE: We don't check for 'Class : Method', as this can easily be confused
+# 	with valid Scala like `val x : Int = 3`. So we instead only rely on
+# 	checks that can't be confused.
 export def FTsc()
   for lnum in range(1, min([line("$"), 25]))
-    if getline(lnum) =~# '[A-Za-z0-9]*\s:\s[A-Za-z0-9]\|var\s<\|classvar\s<\|\^this.*\||\w*|\|+\s\w*\s{\|\*ar\s'
+    if getline(lnum) =~# 'var\s<\|classvar\s<\|\^this.*\||\w\+|\|+\s\w*\s{\|\*ar\s'
       setf supercollider
       return
     endif
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -1533,13 +1533,6 @@ endfunc
 func Test_sc_file()
   filetype on
 
-  " SC file methods are defined 'Class : Method'
-  call writefile(['SCNvimDocRenderer : SCDocHTMLRenderer {'], 'srcfile.sc')
-  split srcfile.sc
-  call assert_equal('supercollider', &filetype)
-  bwipe!
-  call delete('srcfile.sc')
-
   " SC classes are defined with '+ Class {}'
   call writefile(['+ SCNvim {', '*methodArgs {|method|'], 'srcfile.sc')
   split srcfile.sc
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1057,
+/**/
     1056,
 /**/
     1055,