New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(language-service): two-way binding completion should not remove t… #45582
fix(language-service): two-way binding completion should not remove t… #45582
Conversation
56720da
to
bbfce2d
Compare
This is a regression caused by db6cf7e which is creating an inaccurate source span for the synthetic bound event used for the completion. @JoostK Can we change the implementation to just remove the trailing i.e.
|
Oh, interesting; that is definitely an unexpected side-effect of db6cf7e!
I am a bit wary of doing that, as it would again be susceptible to unexpected parses in combination with the Overall the current parsing approach is awful and would benefit from an overhaul, also to fix the source span issues. |
In that case, I would propose updating the template visitor logic to not create this situation in the first place rather than filtering things out after the fact. This bit of code could be added to the
There should also be a test in the @JoostK Had some feelings about changing the implementation of the visitor to "extend the return type of |
The angular/packages/language-service/src/definitions.ts Lines 288 to 310 in a6ab3f7
|
Only for the case where the previous value in the path is a |
Oh, I got it, but I think this is easy to understand for me const length = this.path.length;
this.visitAll(element.inputs);
const noMatchedInputs = this.path.length === length;
const matchedBoundAttribute =
this.path.length - length === 1 && this.path[length] instanceof t.BoundAttribute;
if (noMatchedInputs || matchedBoundAttribute) {
this.visitAll(element.outputs);
} visit the event only when there are no matched inputs or there only has one |
@ivanwonder Right, that's pretty close to the same thing. The issue I have is that it really can be an early exit from the rest of the Edit: I think the distinction might really not matter too much in the end. The rest of the visitor logic would just exit immediately since the position would be outside the spans. But I do think it's easier to understand |
…he trailing quote We allow the path to contain both the `t.BoundAttribute` and `t.BoundEvent` for two-way bindings but do not want the path to contain both the `t.BoundAttribute` with its children when the position is in the value span because we would then logically create a path that also contains the `PropertyWrite` from the `t.BoundEvent`. This early return condition ensures we target just `t.BoundAttribute` for this case and exclude `t.BoundEvent` children. Fixes angular/vscode-ng-language-service#1626
bbfce2d
to
af58ff8
Compare
merge assistance: the failing test is unrelated |
This PR was merged into the repository by commit f57e46c. |
…he trailing quote (#45582) We allow the path to contain both the `t.BoundAttribute` and `t.BoundEvent` for two-way bindings but do not want the path to contain both the `t.BoundAttribute` with its children when the position is in the value span because we would then logically create a path that also contains the `PropertyWrite` from the `t.BoundEvent`. This early return condition ensures we target just `t.BoundAttribute` for this case and exclude `t.BoundEvent` children. Fixes angular/vscode-ng-language-service#1626 PR Close #45582
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@angular/animations](https://github.com/angular/angular) | dependencies | patch | [`13.3.3` -> `13.3.4`](https://renovatebot.com/diffs/npm/@angular%2fanimations/13.3.3/13.3.4) | | [@angular/common](https://github.com/angular/angular) | dependencies | patch | [`13.3.3` -> `13.3.4`](https://renovatebot.com/diffs/npm/@angular%2fcommon/13.3.3/13.3.4) | | [@angular/compiler](https://github.com/angular/angular) | dependencies | patch | [`13.3.3` -> `13.3.4`](https://renovatebot.com/diffs/npm/@angular%2fcompiler/13.3.3/13.3.4) | | [@angular/compiler-cli](https://github.com/angular/angular) | devDependencies | patch | [`13.3.3` -> `13.3.4`](https://renovatebot.com/diffs/npm/@angular%2fcompiler-cli/13.3.3/13.3.4) | | [@angular/core](https://github.com/angular/angular) | dependencies | patch | [`13.3.3` -> `13.3.4`](https://renovatebot.com/diffs/npm/@angular%2fcore/13.3.3/13.3.4) | | [@angular/forms](https://github.com/angular/angular) | dependencies | patch | [`13.3.3` -> `13.3.4`](https://renovatebot.com/diffs/npm/@angular%2fforms/13.3.3/13.3.4) | | [@angular/platform-browser](https://github.com/angular/angular) | dependencies | patch | [`13.3.3` -> `13.3.4`](https://renovatebot.com/diffs/npm/@angular%2fplatform-browser/13.3.3/13.3.4) | | [@angular/platform-browser-dynamic](https://github.com/angular/angular) | dependencies | patch | [`13.3.3` -> `13.3.4`](https://renovatebot.com/diffs/npm/@angular%2fplatform-browser-dynamic/13.3.3/13.3.4) | --- ### Release Notes <details> <summary>angular/angular</summary> ### [`v13.3.4`](https://github.com/angular/angular/blob/HEAD/CHANGELOG.md#​1334-2022-04-20) [Compare Source](angular/angular@13.3.3...13.3.4) ##### core | Commit | Type | Description | | -- | -- | -- | | [9317f513d5](angular/angular@9317f51) | fix | better error message when directive extends a component ([#​45658](angular/angular#45658)) | | [4766817f02](angular/angular@4766817) | fix | improve multiple components match error ([#​45645](angular/angular#45645)) | ##### language-service | Commit | Type | Description | | -- | -- | -- | | [d68333e508](angular/angular@d68333e) | fix | two-way binding completion should not remove the trailing quote ([#​45582](angular/angular#45582)) | #### Special Thanks Andrew Kushnir, Andrew Scott, George Kalpakas, Ilya Marchik, Jeremy Elbourn, Kristiyan Kostadinov, Louis Gombert, Mangalraj, Marko Kaznovac, Paul Gschwendtner, Saurabh Kamble, dario-piotrowicz and ivanwonder <!-- CHANGELOG SPLIT MARKER --> </details> --- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Co-authored-by: cabr2-bot <cabr2.help@gmail.com> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1316 Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org> Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org> Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
…he trailing quote
For two-way binding syntax, the Angular compiler will append the
=$event
to the expression ofBoundEvent
.angular/packages/compiler/src/render3/r3_template_transform.ts
Line 493 in e0ac614
For example, the
[(model)]="title.¦"
, the expression ofBoundEvent
will be converted totitle.¦ =$event
.--------^------ this blank will be included in the
replacementSpan
of completion item.When the user selects an item, the trailing quote will be removed.
Now the paths include
BoundAttribute
andBoundEvent
for the two-way binding syntax. So theBoundEvent
should be removed from the paths and use theBoundAttribute
instead.Fixes angular/vscode-ng-language-service#1626
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information