From cbff48de5a7aa64c5901aeeebadeb44b930cbc24 Mon Sep 17 00:00:00 2001 From: kotaindah55 Date: Mon, 17 Mar 2025 23:17:58 +0200 Subject: [PATCH] fix: non-tidier format acts like the tidier one This was fixed by not using wrap() to wrap with delimiters. --- src/editor-mode/formatting/Formatter.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/editor-mode/formatting/Formatter.ts b/src/editor-mode/formatting/Formatter.ts index c53296f..5704b0f 100644 --- a/src/editor-mode/formatting/Formatter.ts +++ b/src/editor-mode/formatting/Formatter.ts @@ -234,8 +234,9 @@ export class Formatter { this.state.pushChange({ from: curRange.to, insert: delimStr }); } } + /** Run only when tidier formatting is switched off. */ toggleDelim() { - let { curRange, delimStr } = this.state, + let { curRange, delimStr, tagStr } = this.state, delimLen = delimStr.length, selectedStrWithOverlappedEdge = this.doc.sliceString(curRange.from - delimLen, curRange.to + delimLen), selectedStr = selectedStrWithOverlappedEdge.slice(delimLen, -delimLen); @@ -250,7 +251,10 @@ export class Formatter { { from: curRange.to, to: curRange.to + delimLen } ]); } else { - this.wrap(); + this.state.pushChange([ + { from: curRange.from, insert: delimStr + (tagStr ?? "") }, + { from: curRange.to, insert: delimStr } + ]); } } addBlockTag(block: { start: number, end: number }) {