This commit is contained in:
Lox 2025-08-24 08:29:40 +00:00 committed by GitHub
commit 10883ba6f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

16
main.ts
View file

@ -58,6 +58,18 @@ const mappingCommands: String[] = [
"vunmap",
]
const escapeCodes: { [key: string]: string } = {
'\\': '\\',
'r': '\r',
'n': '\n',
't': '\t',
's': ' ',
'b': '\b',
'&': '\&',
' ': ' '
};
function sleep(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}
@ -480,8 +492,8 @@ export default class VimrcPlugin extends Plugin {
throw new Error("surround requires exactly 2 parameters: prefix and postfix text.");
}
let beginning = newArgs[0].replace("\\\\", "\\").replace("\\ ", " "); // Get the beginning surround text
let ending = newArgs[1].replace("\\\\", "\\").replace("\\ ", " "); // Get the ending surround text
let beginning = newArgs[0].replace(/\\([\\rntsb &])/g, function(str, char) { return escapeCodes[char]; }); // Get the beginning surround text
let ending = newArgs[1].replace(/\\([\\rntsb &])/g, function(str, char) { return escapeCodes[char]; }); // Get the ending surround text
let currentSelections = this.currentSelection;
var chosenSelection = currentSelections?.[0] ? currentSelections[0] : {anchor: editor.getCursor(), head: editor.getCursor()};