Skip to content

Commit

Permalink
fix(expressions): autocompletion in parentheses (#1868)
Browse files Browse the repository at this point in the history
  • Loading branch information
sumimakito authored Dec 20, 2024
1 parent ee216f2 commit 9e66bbf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/core/expressions/src/monaco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ export const registerLanguage = (schema: Schema) => {
'@default': 'variable',
},
}],
[/[()]/, 'delimiter.parenthesis'],
[/==|!=|~|\^=|=\^|>=?|<=?|&&|\|\|/, 'operators'],
[/[()]/, 'brackets'],
[/".*?"/, 'string'],
[/\d+/, 'number'],
],
},
brackets: [{ open: '(', close: ')', token: 'delimiter.parenthesis' }],
} as MonarchLanguage)

monaco.languages.registerCompletionItemProvider(languageId, {
Expand Down Expand Up @@ -130,7 +131,9 @@ export const registerLanguage = (schema: Schema) => {
})

const words = lastChars.replace('\t', '').split(' ')
const activeTyping = words[words.length - 1] // what the user is currently typing (everything after the last space)
let activeTyping = words[words.length - 1] // what the user is currently typing (everything after the last space)
// Here, we will start counting the characters after the last open parenthesis
activeTyping = activeTyping.slice(activeTyping.lastIndexOf('(') + 1)

const inputTokens = activeTyping.split('.').slice(0, -1)
let token: Token = tokenTree
Expand Down

0 comments on commit 9e66bbf

Please sign in to comment.