patch 9.2.0500: filetype: some html files wrongly recognized as htmlangular
Commit: https://github.com/vim/vim/commit/354ab1a69efbe5f84cd7225bc3945db3f2cec5c4 Author: truffle <[email protected]> Date: Mon May 18 20:46:24 2026 +0000 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 \<DTD\s\+XHTML\s idiom used five lines below. related: neovim/neovim#39778. closes: #20246 Signed-off-by: truffle <[email protected]> Signed-off-by: Christian Brabandt <[email protected]> diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 3085f3575..c2f3e2afd 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: 2026 May 16 +# Last Change: 2026 May 18 # Former Maintainer: Bram Moolenaar <[email protected]> # 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\)\|\<ng-template\|\<ng-content' setf htmlangular return endif diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim index 70ac40106..47df92d0b 100644 --- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -1888,6 +1888,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>', diff --git a/src/version.c b/src/version.c index 4ce617565..bb0b3d4f5 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, /**/ -- -- 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 [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wP54G-00BqBt-BM%40256bit.org.
