aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2019-04-11 15:52:08 +1000
committerNeil <nyamatongwe@gmail.com>2019-04-11 15:52:08 +1000
commit18b0e610929260475c81baab1c0a52d88f5dc11a (patch)
treec2f5badae83393f241e76f9ef2397f57b19c9b29
parent6bce537d68c0f3c3fd8f02310b41e7e24de3ed16 (diff)
downloadscintilla-mirror-18b0e610929260475c81baab1c0a52d88f5dc11a.tar.gz
Bug [#2094]. Avoid exceptions by treating text as one-byte per character in
accessibility if UTF32 index not available.
-rw-r--r--gtk/ScintillaGTKAccessible.h6
1 files changed, 6 insertions, 0 deletions
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);