CloudWatch/Logs: Fix suggestions of fields after comma (#24520)

This commit is contained in:
Andrej Ocenas
2020-05-11 16:10:49 +02:00
committed by GitHub
parent 9dd68dae36
commit 2d29997bda
2 changed files with 5 additions and 1 deletions
@@ -40,6 +40,10 @@ describe('CloudWatchLanguageProvider', () => {
await runSuggestionTest('fields field1, \\', [fields, FUNCTIONS.map(v => v.label)]);
});
it('should suggest fields and functions after comma with prefix', async () => {
await runSuggestionTest('fields field1, @mess\\', [fields, FUNCTIONS.map(v => v.label)]);
});
it('should suggest fields and functions after display command', async () => {
await runSuggestionTest('display \\', [fields, FUNCTIONS.map(v => v.label)]);
});
@@ -165,7 +165,7 @@ export class CloudWatchLanguageProvider extends LanguageProvider {
const currentTokenIsComma = curToken.content === ',' && curToken.types.includes('punctuation');
const currentTokenIsCommaOrAfterComma =
currentTokenIsComma || (curToken.prev?.content === ',' && curToken.prev.types.includes('punctuation'));
currentTokenIsComma || (prevToken?.content === ',' && prevToken?.types.includes('punctuation'));
// We only show suggestions if we are after a command or after a comma which is a field separator
if (!(currentTokenIsAfterCommand || currentTokenIsCommaOrAfterComma)) {