mirror of
https://github.com/neovim/neovim.git
synced 2026-11-02 09:49:02 -06:00
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:
1 parent
781c43ea05
commit
c8e0af85e0
2 files changed
+22
-1
No files matched your search
@@ -842,7 +842,7 @@ function M.html(_, bufnr)
|
|||||||
if
|
if
|
||||||
matchregex(
|
matchregex(
|
||||||
line,
|
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
|
then
|
||||||
return 'htmlangular'
|
return 'htmlangular'
|
||||||
|
|||||||
@@ -1869,6 +1869,27 @@ func Test_html_file()
|
|||||||
call assert_equal('htmlangular', &filetype)
|
call assert_equal('htmlangular', &filetype)
|
||||||
bwipe!
|
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
|
" Django Template
|
||||||
let content = ['{% if foobar %}',
|
let content = ['{% if foobar %}',
|
||||||
\ ' <ul>',
|
\ ' <ul>',
|
||||||
|
|||||||
Reference in new issue
Block a user