Smart replace

This commit is contained in:
Sergey Hayriyan 2025-03-02 23:03:39 +04:00
parent c5906ba701
commit ebb6e49862

19
main.ts
View file

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