Skip to content

Commit 57e4d0b

Browse files
committed
fix: don't expand plugin method snippet before dot
fix: fix native object literal expression for method snippets
1 parent eb8de78 commit 57e4d0b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const activate = async () => {
3434
const editor = getActiveRegularEditor()!
3535
const startPos = editor.selection.start
3636
const nextSymbol = editor.document.getText(new vscode.Range(startPos, startPos.translate(0, 1)))
37-
if (nextSymbol !== '(') {
37+
if (!['(', '.'].includes(nextSymbol)) {
3838
const snippet = new vscode.SnippetString('')
3939
snippet.appendText('(')
4040
const args = insertFuncArgs.split(',')

typescript/src/completionsAtPosition.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,10 @@ export const getCompletionsAtPosition = (
228228

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

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

0 commit comments

Comments
 (0)