mirror of
https://github.com/esm7/obsidian-vimrc-support.git
synced 2026-07-22 05:00:25 +00:00
Added more escape characters to surround
This commit is contained in:
parent
9ccf52a590
commit
a97be9aa29
1 changed files with 14 additions and 2 deletions
16
main.ts
16
main.ts
|
|
@ -51,6 +51,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));
|
||||
}
|
||||
|
|
@ -443,8 +455,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(/\\(.)/g, function(str, char) { return escapeCodes[char]; }); // Get the beginning surround text
|
||||
let ending = newArgs[1].replace(/\\(.)/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()};
|
||||
|
|
|
|||
Loading…
Reference in a new issue