Skip to content

Commit

Permalink
fix: don't expand plugin method snippet before dot
Browse files Browse the repository at this point in the history
fix: fix native object literal expression for method snippets
  • Loading branch information
zardoy committed Sep 13, 2022
1 parent eb8de78 commit 57e4d0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const activate = async () => {
const editor = getActiveRegularEditor()!
const startPos = editor.selection.start
const nextSymbol = editor.document.getText(new vscode.Range(startPos, startPos.translate(0, 1)))
if (nextSymbol !== '(') {
if (!['(', '.'].includes(nextSymbol)) {
const snippet = new vscode.SnippetString('')
snippet.appendText('(')
const args = insertFuncArgs.split(',')
Expand Down
5 changes: 4 additions & 1 deletion typescript/src/completionsAtPosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ export const getCompletionsAtPosition = (

// prevent vscode-builtin wrong insertText with methods snippets enabled
if (!isGoodPositionBuiltinMethodCompletion(ts, sourceFile, position)) {
prior.entries = prior.entries.map(item => ({ ...item, insertText: (item.insertText ?? item.name).replace(/\$/g, '\\$'), isSnippet: true }))
prior.entries = prior.entries.map(item => {
if (item.isSnippet) return item
return { ...item, insertText: (item.insertText ?? item.name).replace(/\$/g, '\\$'), isSnippet: true }
})
}

if (c('correctSorting.enable')) prior.entries = prior.entries.map((entry, index) => ({ ...entry, sortText: `${entry.sortText ?? ''}${index}` }))
Expand Down

0 comments on commit 57e4d0b

Please sign in to comment.