From 309adaa75f685d4bbea68eee977fd31d1ead42a7 Mon Sep 17 00:00:00 2001 From: Layerex Date: Sun, 9 Jun 2024 23:21:48 +0300 Subject: [PATCH] Refactor getTextBeforeCursor function --- src/mathjax-suggest.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/mathjax-suggest.ts b/src/mathjax-suggest.ts index 4287751159..2bbd1787bd 100644 --- a/src/mathjax-suggest.ts +++ b/src/mathjax-suggest.ts @@ -151,13 +151,7 @@ export default class MathjaxSuggest extends EditorSuggest { } getTextBeforeCursor(pos: EditorPosition): string { - let text = ""; - for (let i = 0; i < pos.line; i++) { - text += this.editor.getLine(i) + " "; - } - - text += this.getCurrentLineBeforeCursor(pos); - return text; + return this.editor.getRange({ ch: 0, line: 0 }, pos); }