From 66086920fd7a1d983190f83ba1e06dfc15a815e3 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 11 Apr 2019 15:52:08 +1000 Subject: Backport: Bug [#2094]. Avoid exceptions by treating text as one-byte per character in accessibility if UTF32 index not available. Backport of changeset 7421:2c8b52af4ae5. --- gtk/ScintillaGTKAccessible.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gtk/ScintillaGTKAccessible.h b/gtk/ScintillaGTKAccessible.h index b9d94b0e2..264bbae1c 100644 --- a/gtk/ScintillaGTKAccessible.h +++ b/gtk/ScintillaGTKAccessible.h @@ -32,6 +32,9 @@ private: } Sci::Position ByteOffsetFromCharacterOffset(Sci::Position startByte, int characterOffset) { + if (!(sci->pdoc->LineCharacterIndex() & SC_LINECHARACTERINDEX_UTF32)) { + return startByte + characterOffset; + } if (characterOffset > 0) { // Try and reduce the range by reverse-looking into the character offset cache Sci::Line lineStart = sci->pdoc->LineFromPosition(startByte); @@ -59,6 +62,9 @@ private: } Sci::Position CharacterOffsetFromByteOffset(Sci::Position byteOffset) { + if (!(sci->pdoc->LineCharacterIndex() & SC_LINECHARACTERINDEX_UTF32)) { + return byteOffset; + } const Sci::Line line = sci->pdoc->LineFromPosition(byteOffset); const Sci::Position lineStart = sci->pdoc->LineStart(line); return sci->pdoc->IndexLineStart(line, SC_LINECHARACTERINDEX_UTF32) + sci->pdoc->CountCharacters(lineStart, byteOffset); -- cgit v1.2.3