fix(language-service): incorrect autocomplete results on unknown symbol (#37518)
This commit fixes a bug whereby the language service would incorrectly return HTML elements if autocomplete is requested for an unknown symbol. This is because we walk through every possible scenario, and fallback to element autocomplete if none of the scenarios match. The fix here is to return results from interpolation if we know for sure we are in a bound text. This means we will now return an empty results if there is no suggestions. This commit also refactors the code a little to make it easier to understand. PR Close #37518
This commit is contained in:

committed by
Andrew Kushnir

parent
8fd8143ab8
commit
ae5257cda6
@ -841,6 +841,13 @@ describe('completions', () => {
|
||||
'trim',
|
||||
]);
|
||||
});
|
||||
|
||||
it('should not return any results for unknown symbol', () => {
|
||||
mockHost.override(TEST_TEMPLATE, '{{ doesnotexist.~{cursor} }}');
|
||||
const marker = mockHost.getLocationMarkerFor(TEST_TEMPLATE, 'cursor');
|
||||
const completions = ngLS.getCompletionsAtPosition(TEST_TEMPLATE, marker.start);
|
||||
expect(completions).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
function expectContain(
|
||||
|
Reference in New Issue
Block a user