diff --git a/public/app/plugins/datasource/cloudwatch/language_provider.test.ts b/public/app/plugins/datasource/cloudwatch/language_provider.test.ts index f711498774a..5168b8990b8 100644 --- a/public/app/plugins/datasource/cloudwatch/language_provider.test.ts +++ b/public/app/plugins/datasource/cloudwatch/language_provider.test.ts @@ -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)]); }); diff --git a/public/app/plugins/datasource/cloudwatch/language_provider.ts b/public/app/plugins/datasource/cloudwatch/language_provider.ts index 125bbdbee81..7683d46efb6 100644 --- a/public/app/plugins/datasource/cloudwatch/language_provider.ts +++ b/public/app/plugins/datasource/cloudwatch/language_provider.ts @@ -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)) {