Skip to content

Commit

Permalink
fix(wql): add whitespace before closing grouping operator ) when usin…
Browse files Browse the repository at this point in the history
…g the suggestions
  • Loading branch information
Desvelao committed Aug 9, 2023
1 parent d15889a commit 9e121ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ describe('Query language - WQL', () => {
${'(field=value or field2>'} | ${{ type: { iconType: 'kqlOperand', color: 'tint1' }, label: '~' }} | ${'(field=value or field2~'}
${'(field=value or field2>'} | ${{ type: { iconType: 'kqlValue', color: 'tint0' }, label: 'value2' }} | ${'(field=value or field2>value2'}
${'(field=value or field2>value2'} | ${{ type: { iconType: 'kqlValue', color: 'tint0' }, label: 'value3' }} | ${'(field=value or field2>value3'}
${'(field=value or field2>value2'} | ${{ type: { iconType: 'tokenDenseVector', color: 'tint3' }, label: ')' }} | ${'(field=value or field2>value2)'}
${'(field=value or field2>value2'} | ${{ type: { iconType: 'tokenDenseVector', color: 'tint3' }, label: ')' }} | ${'(field=value or field2>value2 )'}
`(
'click suggestion - WQL $WQL => $changedInput',
async ({ WQL: currentInput, clikedSuggestion, changedInput }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1094,10 +1094,15 @@ export const WQL = {
: item.label;
} else {
// add a whitespace for conjunction <whitespace><conjunction>
// add a whitespace for grouping operator <whitespace>)
!/\s$/.test(input) &&
(item.type.iconType ===
suggestionMappingLanguageTokenType.conjunction.iconType ||
lastToken?.type === 'conjunction') &&
lastToken?.type === 'conjunction' ||
(item.type.iconType ===
suggestionMappingLanguageTokenType.operator_group
.iconType &&
item.label === ')')) &&
tokens.push({
type: 'whitespace',
value: ' ',
Expand Down

0 comments on commit 9e121ad

Please sign in to comment.