mirror of
https://github.com/esm7/obsidian-vimrc-support.git
synced 2026-07-22 05:00:25 +00:00
Fix RangeError when executing surround command with backward selection (#234)
This commit is contained in:
parent
2a5fffa2d1
commit
10c2b613bf
1 changed files with 4 additions and 6 deletions
10
main.ts
10
main.ts
|
|
@ -494,12 +494,10 @@ export default class VimrcPlugin extends Plugin {
|
|||
chosenSelection = {anchor: wordAt.from, head: wordAt.to};
|
||||
}
|
||||
}
|
||||
let currText;
|
||||
if (editor.posToOffset(chosenSelection.anchor) > editor.posToOffset(chosenSelection.head)) {
|
||||
currText = editor.getRange(chosenSelection.head, chosenSelection.anchor);
|
||||
} else {
|
||||
currText = editor.getRange(chosenSelection.anchor, chosenSelection.head);
|
||||
}
|
||||
if (editor.posToOffset(chosenSelection.anchor) > editor.posToOffset(chosenSelection.head)) {
|
||||
[chosenSelection.anchor, chosenSelection.head] = [chosenSelection.head, chosenSelection.anchor];
|
||||
}
|
||||
let currText = editor.getRange(chosenSelection.anchor, chosenSelection.head);
|
||||
editor.replaceRange(beginning + currText + ending, chosenSelection.anchor, chosenSelection.head);
|
||||
// If no selection, place cursor between beginning and ending
|
||||
if (editor.posToOffset(chosenSelection.anchor) === editor.posToOffset(chosenSelection.head)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue