From b0e79c18694fd69a13f62f6cb318a460298883b4 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 28 Dec 2023 18:14:19 +0100 Subject: [PATCH] Fix bug in bidi isolate handling FIX: Fix a bug that broke some bidi isolates not on the first line of the document. --- src/extension.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 03f323f..72e037c 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -260,12 +260,13 @@ export function getIsolatedRanges(view: EditorView, line: Line): readonly Isolat let result: Isolate[] = [] RangeSet.spans(sets, line.from, line.to, { point() {}, - span(from, to, active, open) { + span(fromDoc, toDoc, active, open) { + let from = fromDoc - line.from, to = toDoc - line.from let level = result for (let i = active.length - 1; i >= 0; i--, open--) { let direction = active[i].spec.bidiIsolate, update if (direction == null) - direction = autoDirection(line.text, from - line.from, to - line.from) + direction = autoDirection(line.text, from, to) if (open > 0 && level.length && (update = level[level.length - 1]).to == from && update.direction == direction) { update.to = to