Skip to content

Commit

Permalink
Fix #4430 Escape $ when surround macros
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Oct 13, 2024
1 parent f940943 commit 1a46978
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/completion/completer/macro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ function surround(cmdItems?: CompletionItem[]) {
}
void editor.edit( editBuilder => {
for (const selection of editor.selections) {
const selectedContent = editor.document.getText(selection)
const selectedContent = editor.document.getText(selection).replaceAll('$', '$$$$')
const selectedMacro = '\\' + selected.macro
editBuilder.replace(new vscode.Range(selection.start, selection.end),
selectedMacro.replace(/(.*)(\${\d.*?})/, `$1${selectedContent}`) // Replace text
.replace(/\${\d:?(.*?)}/g, '$1') // Remove snippet placeholders
.replace(/\$\d/, '')) // Remove $2 etc
selectedMacro.replace(/\$\d/g, '') // Remove $2 etc
.replace(/(.*)(\${\d.*?})/g, `$1${selectedContent}`) // Replace text
.replace(/\${\d:?(.*?)}/g, '$1')) // Remove snippet placeholders
}
})
})
Expand Down

0 comments on commit 1a46978

Please sign in to comment.