From 9d549ecf5e05d688b0fd662af1a6ff8350acb524 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 52b2bc8cf6..e3c6b4e1e5 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, }; }