mirror of
https://github.com/vim/vim
synced 2025-07-15 16:51:57 +00:00
runtime(filetype): fix incorrect pattern and break early
- Using `\n` is incorrect, as result of getline() does not contain line breaks and only uses `\n` for NUL bytes. - Return when b:asmsyntax is set, like many other filetypes. closes: #17706 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
bda55df3b8
commit
41ee98c3c5
15
runtime/autoload/dist/ft.vim
vendored
15
runtime/autoload/dist/ft.vim
vendored
@ -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 <Bram@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
|
||||
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 =~ '\%(^\|\n\)/\*'
|
||||
if line =~ '^/\*'
|
||||
is_slash_star_encountered = true
|
||||
endif
|
||||
if line =~# '^; Listing generated by Microsoft' || line =~? '\%(^\|\n\)\%(\%(CONST\|_BSS\|_DATA\|_TEXT\)\s\+SEGMENT\>\)\|\s*\.[2-6]86P\?\>\|\s*\.XMM\>'
|
||||
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 =~ '\%(^\|\n\)\*' && !is_slash_star_encountered)
|
||||
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
|
||||
endif
|
||||
enddef
|
||||
|
||||
var ft_visual_basic_content = '\c^\s*\%(Attribute\s\+VB_Name\|Begin\s\+\%(VB\.\|{\%(\x\+-\)\+\x\+}\)\)'
|
||||
|
Reference in New Issue
Block a user