patch 9.1.1466: filetype: not all lex files are recognized

Commit: 
https://github.com/vim/vim/commit/48295111e578e2158c6234510f12081de4757c52
Author: Eisuke Kawashima <e-k...@users.noreply.github.com>
Date:   Tue Jun 17 20:30:52 2025 +0200

    patch 9.1.1466: filetype: not all lex files are recognized
    
    Problem:  filetype: not all lex files are recognized
    Solution: detect *.ll as lex, llvm or lifelines filetype, depending on
              the content (Eisuke Kawashima)
    
    closes: #17560
    
    Signed-off-by: Eisuke Kawashima <e-k...@users.noreply.github.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 95135c8b8..5014e7544 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -3,7 +3,7 @@ vim9script
 # Vim functions for file type detection
 #
 # Maintainer:          The Vim Project <https://github.com/vim/vim>
-# Last Change:         2025 Apr 21
+# Last Change:         2025 Jun 17
 # Former Maintainer:   Bram Moolenaar <b...@vim.org>
 
 # These functions are moved here from runtime/filetype.vim to make startup
@@ -184,9 +184,18 @@ enddef
 export def FTll()
   if getline(1) =~ ';\|\<source_filename\>\|\<target\>'
     setf llvm
-  else
-    setf lifelines
+    return
   endif
+  var n = 1
+  while n < 100 && n <= line("$")
+    var line = getline(n)
+    if line =~ '^\s*%'
+      setf lex
+      return
+    endif
+    n += 1
+  endwhile
+  setf lifelines
 enddef
 
 export def FTlpc()
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 76229edde..f90c6f87b 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1420,7 +1420,7 @@ au BufNewFile,BufRead 
*/etc/sensors.conf,*/etc/sensors3.conf      setf sensors
 " LFTP
 au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc       setf lftp
 
-" Lifelines (or Lex for C++!)
+" Lifelines, LLVM, or Lex for C++
 au BufNewFile,BufRead *.ll                     call dist#ft#FTll()
 
 " Lilo: Linux loader
diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
index c2ea8f1ee..3ae16e418 100644
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -2634,6 +2634,12 @@ func Test_ll_file()
   call assert_equal('llvm', &filetype)
   bwipe!
 
+  " lex (C++)
+  call writefile(['%{', '#include <iostream>', '%}'], 'Xfile.ll', 'D')
+  split Xfile.ll
+  call assert_equal('lex', &filetype)
+  bwipe!
+
   " lifelines
   call writefile(['proc main() {}'], 'Xfile.ll', 'D')
   split Xfile.ll
diff --git a/src/version.c b/src/version.c
index fc2abd85e..0b6a3b028 100644
--- a/src/version.c
+++ b/src/version.c
@@ -709,6 +709,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1466,
 /**/
     1465,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1uRbIy-004WO7-IT%40256bit.org.

Raspunde prin e-mail lui