From 57f7cdd447f45a212735f984d660ceb2064c496f Mon Sep 17 00:00:00 2001 From: Kuuuube <61125188+Kuuuube@users.noreply.github.com> Date: Wed, 2 Oct 2024 23:13:18 -0400 Subject: [PATCH] Fix UTF32 characters breaking sentence parser due directly accessing string array indexes (#1452) --- ext/js/dom/text-source-generator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/js/dom/text-source-generator.js b/ext/js/dom/text-source-generator.js index ca14204921..a02a426d12 100644 --- a/ext/js/dom/text-source-generator.js +++ b/ext/js/dom/text-source-generator.js @@ -66,7 +66,7 @@ export class TextSourceGenerator { source = source.clone(); const startLength = source.setStartOffset(extent, layoutAwareScan); const endLength = source.setEndOffset(extent * 2 - startLength, true, layoutAwareScan); - const text = source.text(); + const text = [...source.text()]; const textLength = text.length; const textEndAnchor = textLength - endLength; @@ -173,7 +173,7 @@ export class TextSourceGenerator { // Result return { - text: text.substring(cursorStart, cursorEnd), + text: text.slice(cursorStart, cursorEnd).join(''), offset: startLength - cursorStart, }; }