From 354ab1a69efbe5f84cd7225bc3945db3f2cec5c4 Mon Sep 17 00:00:00 2001 From: truffle Date: Mon, 18 May 2026 20:46:24 +0000 Subject: [PATCH] patch 9.2.0500: filetype: some html files wrongly recognized as htmlangular 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 \ Signed-off-by: Christian Brabandt --- runtime/autoload/dist/ft.vim | 4 ++-- src/testdir/test_filetype.vim | 21 +++++++++++++++++++++ src/version.c | 2 ++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 3085f3575c..c2f3e2afd0 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 -# Last Change: 2026 May 16 +# Last Change: 2026 May 18 # Former Maintainer: Bram Moolenaar # These functions are moved here from runtime/filetype.vim to make startup @@ -547,7 +547,7 @@ export def FThtml() while n < 40 && n <= line("$") # Check for Angular - if getline(n) =~ '@\(if\|for\|defer\|switch\)\|\*\(ngIf\|ngFor\|ngSwitch\|ngTemplateOutlet\)\|ng-template\|ng-content' + if getline(n) =~ '@\(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 %}', \ '
    ', diff --git a/src/version.c b/src/version.c index 4ce6175650..bb0b3d4f53 100644 --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 500, /**/ 499, /**/