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:
ivanwonder
2020-06-09 17:42:42 +08:00
committed by Misko Hevery
parent adc9d5cdcb
commit e99bcbb4d4
2 changed files with 23 additions and 4 deletions

View File

@ -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(