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 \<DTD\s\+XHTML\s idiom used five lines below.

related: neovim/neovim#39778.
closes:  vim/vim#20246

https://github.com/vim/vim/commit/354ab1a69efbe5f84cd7225bc3945db3f2cec5c4

Co-authored-by: truffle <truffleagent@gmail.com>
(cherry picked from commit f3bb21e71d)
This commit is contained in:
zeertzjq authored and github-actions[bot] committed 2026-05-19 01:08:18 +00:00
1 parent 781c43ea05
commit c8e0af85e0
2 files changed
+22 -1

No files matched your search

+1 -1
View File
@@ -842,7 +842,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\)\|\<ng-template\|\<ng-content]]
)
then
return 'htmlangular'
+21
View File
@@ -1869,6 +1869,27 @@ func Test_html_file()
call assert_equal('htmlangular', &filetype)
bwipe!
" HTML Angular ng-template element
let content = ['<ng-template let-foo>{{ foo }}</ng-template>']
call writefile(content, 'Xfile.html', 'D')
split Xfile.html
call assert_equal('htmlangular', &filetype)
bwipe!
" HTML Angular ng-content element
let content = ['<div><ng-content select="[item]"></ng-content></div>']
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 = ['<div class="song-template">', ' <h1>Not Angular</h1>', '</div>']
call writefile(content, 'Xfile.html', 'D')
split Xfile.html
call assert_equal('html', &filetype)
bwipe!
" Django Template
let content = ['{% if foobar %}',
\ ' <ul>',