diff --git a/public/app/plugins/datasource/loki/language_provider.test.ts b/public/app/plugins/datasource/loki/language_provider.test.ts index 7def3786888..9eb3c234390 100644 --- a/public/app/plugins/datasource/loki/language_provider.test.ts +++ b/public/app/plugins/datasource/loki/language_provider.test.ts @@ -167,6 +167,25 @@ describe('Language completion provider', () => { }, ]); }); + it('returns label values suggestions from Loki when re-editing', async () => { + const datasource = makeMockLokiDatasource({ label1: ['label1_val1', 'label1_val2'], label2: [] }); + const provider = await getLanguageProvider(datasource); + const input = createTypeaheadInput('{label1="label1_v"}', 'label1_v', 'label1', 17, [ + 'attr-value', + 'context-labels', + ]); + let result = await provider.provideCompletionItems(input); + expect(result.context).toBe('context-label-values'); + expect(result.suggestions).toEqual([ + { + items: [ + { label: 'label1_val1', filterText: '"label1_val1"' }, + { label: 'label1_val2', filterText: '"label1_val2"' }, + ], + label: 'Label values for "label1"', + }, + ]); + }); }); describe('label values', () => { diff --git a/public/app/plugins/datasource/loki/language_provider.ts b/public/app/plugins/datasource/loki/language_provider.ts index 57f516a7b11..fc2e720ccd6 100644 --- a/public/app/plugins/datasource/loki/language_provider.ts +++ b/public/app/plugins/datasource/loki/language_provider.ts @@ -280,7 +280,7 @@ export default class LokiLanguageProvider extends LanguageProvider { selector = EMPTY_SELECTOR; } - if (!isValueStart && selector === EMPTY_SELECTOR) { + if (!labelKey && selector === EMPTY_SELECTOR) { // start task gets all labels await this.start(); const allLabels = this.getLabelKeys();