From f3bb21e71da09a357c0b05e53b4e11afdceb6621 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 19 May 2026 08:42:05 +0800 Subject: [PATCH] vim-patch:9.2.0500: filetype: some html files wrongly recognized as htmlangular (#39880) Problem: filetype: some html files are wrongly recognized as htmlangular Solution: Use the \< atom to anchor ng-template and ng-content to start of word (truffle) Prevent false-positive htmlangular detection on words containing 'ng-template' or 'ng-content' as a substring (e.g. 'song-template', 'sing-content'). Anchor both branches with \< to require a word start, matching the \ --- runtime/lua/vim/filetype/detect.lua | 2 +- test/old/testdir/test_filetype.vim | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 24a5ca799e..79cc6651c4 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -848,7 +848,7 @@ function M.html(_, bufnr) if matchregex( line, - [[@\(if\|for\|defer\|switch\)\|\*\(ngIf\|ngFor\|ngSwitch\|ngTemplateOutlet\)\|ng-template\|ng-content]] + [[@\(if\|for\|defer\|switch\)\|\*\(ngIf\|ngFor\|ngSwitch\|ngTemplateOutlet\)\|\{{ foo }}'] + call writefile(content, 'Xfile.html', 'D') + split Xfile.html + call assert_equal('htmlangular', &filetype) + bwipe! + + " HTML Angular ng-content element + let content = ['
'] + call writefile(content, 'Xfile.html', 'D') + split Xfile.html + call assert_equal('htmlangular', &filetype) + bwipe! + + " Word containing 'ng-template' as a suffix must not trigger htmlangular + let content = ['
', '

Not Angular

', '
'] + call writefile(content, 'Xfile.html', 'D') + split Xfile.html + call assert_equal('html', &filetype) + bwipe! + " Django Template let content = ['{% if foobar %}', \ '
    ',