fix(language-service): wrong completions in conditional operator (#37505)
In `a ? b.~{cursor}`, the LS will provide the symbols in the scope of the current template, because the `path.tail` is `falseExp` whose value is `EmptyExpr`, and the span of `falseExp` is wider than the `trueExp`, so the value of `path` should be narrowed. PR Close #37505
This commit is contained in:
@ -832,6 +832,15 @@ describe('completions', () => {
|
||||
// should resolve to transform(value: number, prefix: number): number
|
||||
expectContain(c2, CompletionKind.METHOD, ['toFixed', 'toExponential']);
|
||||
});
|
||||
|
||||
it('should work in the conditional operator', () => {
|
||||
mockHost.override(TEST_TEMPLATE, '{{ title ? title.~{cursor} }}');
|
||||
const marker = mockHost.getLocationMarkerFor(TEST_TEMPLATE, 'cursor');
|
||||
const completions = ngLS.getCompletionsAtPosition(TEST_TEMPLATE, marker.start);
|
||||
expectContain(completions, CompletionKind.METHOD, [
|
||||
'trim',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
function expectContain(
|
||||
|
Reference in New Issue
Block a user