Skip to content

Commit 1c6d4e4

Browse files
committed
feat: trigger suggest on jsx attribute string snippet completion
1 parent 95cf14d commit 1c6d4e4

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/onCompletionAccepted.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ export default (tsApi: { onCompletionAccepted }) => {
2222
return
2323
}
2424

25-
// todo: use cleaner detection
26-
if (typeof insertText === 'object' && typeof label === 'object' && label.detail && [': [],', ': {},', ': "",', ": '',"].includes(label.detail)) {
25+
const isJsxAttributeStringCompletion = typeof insertText === 'object' && insertText.value.endsWith("='$1'")
26+
const isOurObjectLiteralCompletion =
27+
typeof insertText === 'object' && typeof label === 'object' && label.detail && [': [],', ': {},', ': "",', ": '',"].includes(label.detail)
28+
if (isJsxAttributeStringCompletion || isOurObjectLiteralCompletion) {
29+
// todo most probably should be controlled by quickSuggestions setting
2730
void vscode.commands.executeCommand('editor.action.triggerSuggest')
2831
return
2932
}

0 commit comments

Comments
 (0)