Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Binding syntax outside of an attribute still highlighted as a binding rather than plain text #1725

Closed
1 of 2 tasks
Cdrew92 opened this issue Jul 15, 2022 · 7 comments
Closed
1 of 2 tasks
Labels

Comments

@Cdrew92
Copy link

Cdrew92 commented Jul 15, 2022

🐞 bug report

Is this a regression?

N/A

Description

A clear and concise description of the problem...

If the bug is caused or experienced by a particular source code, please provide a minimal
reproduction of that source code.

Bug Type

What does this bug affect

  • Angular Language Service VSCode extension

  • Angular Language Service server

Reproduction

Steps to reproduce the behavior:

  1. in a component.html file add the following:
    <app-image-img>
        [filesArray]="event.Event_Files" //this line of text is blue!
    </app-image-img>

Expected behavior

  • Because the filesArray property is defined outside the closing arrow of the opening <app-image-img> element, I would expect the text to turn white as it does when a property without an array is added outside the opening arrow:
    <app-image-img>
        [filesArray]="event.Event_Files" //this line of  text is blue, indicating no error!
        files="test" //this line of text is white, denoting an error!
    </app-image-img>

Logs

N/A - No errors in Angular Server Log or Browser Console

Screenshots

Incorrectly added property tag outside of closing arrow: (unexpected behavior, text is blue.)
image

Shows white text when non-bracketed property is added: (expected behavior, showing white text)
image

Correct implementation of property binding: (working properly)
image

🌍 Your Environment

Angular Version:


Angular CLI: 13.3.7
Node: 16.13.2
Package Manager: npm 8.1.2
OS: win32 x64

Extension Version:


Angular Language Service v14.01

VSCode Version:


Version: 16.9.0 (user setup)

Operating System:


Edition	Windows 10 Pro
Version	21H2
Installed on	‎5/‎28/‎2021
OS build	19044.1766
Experience	Windows Feature Experience Pack 120.2212.4180.0

Extension options:


{
    "angular.log": "verbose"
}

Anything else relevant?
N/A

@Cdrew92 Cdrew92 added the bug label Jul 15, 2022
@atscott
Copy link
Collaborator

atscott commented Jul 15, 2022

This is not a syntax error. Syntactically, this is just a text literal.

The blue and white highlighting is the syntax highlighting, which is regex-based. White is a text literal and blue is an attribute.

There won't ever be an error for this, but we could investigate how feasible it is to ensure the syntax highlighting gets fixed here.

@atscott atscott changed the title Component Property Does Not Throw Error When Outside Of Closing Tag Binding syntax outside of an attribute still highlighted as a binding rather than plan text Jul 15, 2022
@Cdrew92 Cdrew92 changed the title Binding syntax outside of an attribute still highlighted as a binding rather than plan text Binding syntax outside of an attribute still highlighted as a binding rather than plain text Jul 15, 2022
@Cdrew92
Copy link
Author

Cdrew92 commented Jul 15, 2022

Thanks, Andrew!

@atscott
Copy link
Collaborator

atscott commented Apr 14, 2023

Closing in favor of angular/angular#49842

edit: reopening. This one deals with the binding text while the angular/angular issue is for adding a warning/error

@atscott atscott closed this as not planned Won't fix, can't repro, duplicate, stale Apr 14, 2023
JeanMeche added a commit to JeanMeche/vscode-ng-language-service that referenced this issue Apr 14, 2023
With a negative lookbehind we can exclude binding like text (ie `<div>[myInput]=myvar</div>`) from the synthax coloring of bindings

Fixes angular#1725 and angular/angular#49842
@atscott atscott reopened this Apr 14, 2023
JeanMeche added a commit to JeanMeche/vscode-ng-language-service that referenced this issue Apr 14, 2023
With a negative lookbehind we can exclude binding like text (ie `<div>[myInput]=myvar</div>`) from the synthax coloring of bindings

Fixes angular#1725 and angular/angular#49842
JeanMeche added a commit to JeanMeche/vscode-ng-language-service that referenced this issue Apr 14, 2023
With a negative lookbehind we can exclude binding like text (ie `<div>[myInput]=myvar</div>`) from the synthax coloring of bindings

Fixes angular#1725
@a-stewart
Copy link
Contributor

I've just come across the same issue. The challenge is that the language is injected into L:text.html -comment which means it applies the logic at the root element.

There are a few patterns which are inserted:

    {
      "include": "#interpolation"
    },
    {
      "include": "#propertyBinding"
    },
    {
      "include": "#eventBinding"
    },
    {
      "include": "#twoWayBinding"
    },
    {
      "include": "#templateBinding"
    }

If we remove #propertyBinding and #eventBinding, the default html language extension seems to be fine highlighting the contents anyway.

image

image

image

What do you reckon to removing the bindings and letting the default html extension handle these?

An alternative option could be to have a second injected grammar which injects into something like L:text.html meta.tag -comment. This would allow for defining certain grammars which are only matched in tags, such as these bindings, whilst also allowing for things like interpolation to be defined on source.html.

@atscott
Copy link
Collaborator

atscott commented Aug 9, 2023

Hi @a-stewart, that seems reasonable. Would you like to send a PR out for this?

@a-stewart
Copy link
Contributor

Sorry for the delay - created #1992 for this.

atscott pushed a commit to a-stewart/vscode-ng-language-service that referenced this issue Jan 31, 2024
Currently we inject all the syntaxes into text.html, causing angular#1725

Rather than doing this, we should separate this into two injects, one injecting interpolation into the base html, and another which injects bindings, but only into meta.tag.

fixes angular#1725
atscott pushed a commit to a-stewart/vscode-ng-language-service that referenced this issue Feb 2, 2024
Currently we inject all the syntaxes into text.html, causing angular#1725

Rather than doing this, we should separate this into two injects, one injecting interpolation into the base html, and another which injects bindings, but only into meta.tag.

fixes angular#1725
@atscott atscott closed this as completed in 28739e4 Feb 2, 2024
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 4, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
3 participants