Skip to content

Commit

Permalink
Merge pull request #257 from parca-dev/fix-autocomplete-space-exception
Browse files Browse the repository at this point in the history
ui: Fix autocomplete space after comma
  • Loading branch information
brancz authored Oct 7, 2021
2 parents a202c65 + 82eaf8a commit ea47d4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ui/packages/shared/parser/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,10 @@ test('SuggestNextLabelName', () => {
typeahead: ''
}])
})

test('SuggestNextLabelNameSpace', () => {
expect(Query.suggest('test{test="a", ')).toMatchObject([{
type: 'labelName',
typeahead: ''
}])
})
2 changes: 1 addition & 1 deletion ui/packages/shared/parser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class Query {

// Parser.table is not defined in the type definitions, so we need to do this unfortunately.
const parserTable = p.table as any[]
const column = parserTable.filter(c => c.states.find(s => s.data !== undefined && Object.prototype.hasOwnProperty.call(s.data, 'profileName')))[0]
const column = parserTable.filter(c => c.states.find(s => s.data !== undefined && s.data != null && Object.prototype.hasOwnProperty.call(s.data, 'profileName')))[0]
if (column !== undefined) {
const data = column.states.find(s => s.data !== undefined && Object.prototype.hasOwnProperty.call(s.data, 'profileName')).data
const rest = input.slice(column.lexerState.col - 2)
Expand Down

0 comments on commit ea47d4c

Please sign in to comment.