aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2020-06-11 16:22:59 +1000
committerNeil <nyamatongwe@gmail.com>2020-06-11 16:22:59 +1000
commit5ebd653f630d2f37c696f7f6928de4fa133b8486 (patch)
treec847e71248933e357745ccae011b859d2b7c3dd1
parent87342a6cec6c3239e9891481f7774ffeef4fa71f (diff)
downloadscintilla-mirror-5ebd653f630d2f37c696f7f6928de4fa133b8486.tar.gz
Backport: Fix bug on Win32 where calling WM_GETTEXT for more text than in document could
return less text than in document. Backport of changeset 8302:2faf8ba9d1fb.
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--test/win32Tests.py13
-rw-r--r--win32/ScintillaWin.cxx2
3 files changed, 18 insertions, 1 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 1b0697810..ae942e58e 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -590,6 +590,10 @@
<a href="https://sourceforge.net/p/scintilla/bugs/2185/">Bug #2185</a>.
</li>
<li>
+ Fix bug on Win32 where calling WM_GETTEXT for more text than in document could return
+ less text than in document.
+ </li>
+ <li>
Fixed bug in Batch lexer where a single character line with a single character line end continued
state onto the next line.
</li>
diff --git a/test/win32Tests.py b/test/win32Tests.py
index 21a89dbed..6a1d27387 100644
--- a/test/win32Tests.py
+++ b/test/win32Tests.py
@@ -129,6 +129,19 @@ class TestWins(unittest.TestCase):
self.assertEquals(lenData, 2)
self.assertEquals(data.value, "ab")
+ def testGetTextLongNonASCII(self):
+ # With 1 multibyte character in document ask for 4 and ensure 1 character
+ # returned correctly.
+ self.ed.SetCodePage(65001)
+ t = "å"
+ tu8 = t.encode("UTF-8")
+ self.SetText(tu8)
+ data = ctypes.create_unicode_buffer(100)
+ lenData = self.GetText(4, data)
+ self.assertEquals(self.ed.GetStatus(), 0)
+ self.assertEquals(lenData, 1)
+ self.assertEquals(data.value, t)
+
def testGetTextShort(self):
self.assertEquals(self.ed.GetStatus(), 0)
self.SetText(b"ab")
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 668a450a8..83d83daae 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -1327,7 +1327,7 @@ sptr_t ScintillaWin::GetText(uptr_t wParam, sptr_t lParam) {
Sci::Position sizeRequestedRange = pdoc->GetRelativePositionUTF16(0, lengthWanted);
if (sizeRequestedRange < 0) {
// Requested more text than there is in the document.
- sizeRequestedRange = pdoc->CountUTF16(0, pdoc->Length());
+ sizeRequestedRange = pdoc->Length();
}
std::string docBytes(sizeRequestedRange, '\0');
pdoc->GetCharRange(&docBytes[0], 0, sizeRequestedRange);