Add smart range replace

This commit is contained in:
Sergey Hayriyan 2025-03-20 13:24:58 +04:00
parent a95d1a9079
commit 4d3616c6d9

View file

@ -249,15 +249,15 @@ class MathTypeSuggest extends EditorSuggest<string> {
const editor = this.context.editor;
const lineContent = editor.getLine(this.context.start.line);
if (!lineContent.startsWith("$") && !lineContent.endsWith("$")) {
if (lineContent.startsWith("$") && lineContent.endsWith("$")) {
editor.replaceRange(
`$${value}$`,
value,
this.context.start,
this.context.end
);
} else {
editor.replaceRange(
value,
`$${value}$`,
this.context.start,
this.context.end
);