runtime(filetype): fix incorrect pattern and break early Commit: https://github.com/vim/vim/commit/41ee98c3c5342867cb99dfcddbe8d53caeda22db Author: zeertzjq <zeert...@outlook.com> Date: Wed Jul 9 18:23:14 2025 +0200
runtime(filetype): fix incorrect pattern and break early - Using ` ` is incorrect, as result of getline() does not contain line breaks and only uses ` ` for NUL bytes. - Return when b:asmsyntax is set, like many other filetypes. closes: #17706 Signed-off-by: zeertzjq <zeert...@outlook.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index ff1dc037d..380b97bf4 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 Jul 08 +# Last Change: 2025 Jul 09 # Former Maintainer: Bram Moolenaar <b...@vim.org> # These functions are moved here from runtime/filetype.vim to make startup @@ -61,27 +61,30 @@ export def FTasmsyntax() var match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s') if match != '' b:asmsyntax = match - else - # Use heuristics - var is_slash_star_encountered = false - var i = 1 - const n = min([50, line("$")]) - while i <= n - const line = getline(i) - if line =~ '\%(^\| \)/\*' - is_slash_star_encountered = true - endif - if line =~# '^; Listing generated by Microsoft' || line =~? '\%(^\| \)\%(\%(CONST\|_BSS\|_DATA\|_TEXT\)\s\+SEGMENT\>\)\|\s*\.[2-6]86P\?\>\|\s*\.XMM\>' - b:asmsyntax = "masm" - elseif line =~ 'Texas Instruments Incorporated' || (line =~ '\%(^\| \)\*' && !is_slash_star_encountered) - # tiasm uses `* commment`, but detection is unreliable if '/*' is seen - b:asmsyntax = "tiasm" - elseif ((line =~? '\.title\>\|\.ident\>\|\.macro\>\|\.subtitle\>\|\.library\>')) - b:asmsyntax = "vmasm" - endif - i += 1 - endwhile + return endif + # Use heuristics + var is_slash_star_encountered = false + var i = 1 + const n = min([50, line("$")]) + while i <= n + const line = getline(i) + if line =~ '^/\*' + is_slash_star_encountered = true + endif + if line =~# '^; Listing generated by Microsoft' || line =~? '^\%(\%(CONST\|_BSS\|_DATA\|_TEXT\)\s\+SEGMENT\>\)\|\s*\.[2-6]86P\?\>\|\s*\.XMM\>' + b:asmsyntax = "masm" + return + elseif line =~ 'Texas Instruments Incorporated' || (line =~ '^\*' && !is_slash_star_encountered) + # tiasm uses `* commment`, but detection is unreliable if '/*' is seen + b:asmsyntax = "tiasm" + return + elseif ((line =~? '\.title\>\|\.ident\>\|\.macro\>\|\.subtitle\>\|\.library\>')) + b:asmsyntax = "vmasm" + return + endif + i += 1 + endwhile enddef var ft_visual_basic_content = ' -- -- 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/E1uZXgO-00CzsU-0v%40256bit.org.