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

fix: Exclude binding like text in templates #1888

Closed
wants to merge 1 commit into from

Conversation

JeanMeche
Copy link
Member

I wanted to give a try to improve the behaviour reported in the 2 tickets below. Let me know what you think of it !

With a negative lookbehind we can exclude binding like text (ie <div>[myInput]=myvar</div>) from the synthax coloring of bindings

Fixes #1725 and angular/angular#49842

@JeanMeche JeanMeche force-pushed the fix/synthax-binding branch from 9819579 to fbed11d Compare April 14, 2023 16:57
@atscott
Copy link
Collaborator

atscott commented Apr 14, 2023

@JeanMeche Can you remove the note about this fixing angular/angular#49842? That issue is requesting an actual error or warning if binding syntax is used in text interpolation while this one is only about incorrectly highlighting

@@ -149,6 +149,8 @@
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ template.ng
><div [invalidProperty)="val"></div>
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ template.ng
><div>[my-property]="val"</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for multiline? i.e.

<div>
  [my-property]="val"
</div>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried to make it work with a multiple-line element with no success.

I've got a working regex here : https://regex101.com/r/56TkVf/2 so I guess it a limitation of the textmate grammars.

Do you still want a test showing that this case isn't covered ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should have an incomplete solution to the problem. If this isn't working for multiline, then we should come up with a different way to address it. I expect the most common case will be a binding on a different line anyways. There's probably some way to make it work by only applying the property binding when in a given scope.

Closing this PR since it's not quite what we really need.

With a negative lookbehind we can exclude binding like text (ie `<div>[myInput]=myvar</div>`) from the synthax coloring of bindings

Fixes angular#1725
@JeanMeche JeanMeche force-pushed the fix/synthax-binding branch from fbed11d to 4a47a7e Compare April 14, 2023 17:57
@atscott atscott closed this Apr 14, 2023
@JeanMeche JeanMeche deleted the fix/synthax-binding branch April 14, 2023 21:35
@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 May 15, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Binding syntax outside of an attribute still highlighted as a binding rather than plain text
2 participants