mirror of
https://github.com/slateblua/mathtype.git
synced 2026-07-22 05:43:32 +00:00
Smart replace
This commit is contained in:
parent
c5906ba701
commit
ebb6e49862
1 changed files with 14 additions and 5 deletions
19
main.ts
19
main.ts
|
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue