diff options
-rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
-rw-r--r-- | test/win32Tests.py | 13 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 2 |
3 files changed, 18 insertions, 1 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index f27c4c1cb..c6d5b0539 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -586,6 +586,10 @@ Fix printing on Windows to use correct text size. <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> </ul> <h3> <a href="https://www.scintilla.org/scite443.zip">Release 4.4.3</a> diff --git a/test/win32Tests.py b/test/win32Tests.py index 6032e8955..d47ed66db 100644 --- a/test/win32Tests.py +++ b/test/win32Tests.py @@ -130,6 +130,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 5d0020d30..a0d1c024b 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -1342,7 +1342,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); |