Neil:
I think I found a small issue with GetTextRange in 3.6.6. When the provided buffer is not initialized with \0 and the requested range is outside of the document range, the returned len is reported based on provided cpMax and cpMin numbers, even though GetCharRange returns unmodified buffer, which is causing the caller to assume everything went well and get garbage in the buffer. The following patch fixes this for me:
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -6000,6 +6000,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
if (lParam == 0)
return 0;
Sci_TextRange *tr = reinterpret_cast<Sci_TextRange *>(lParam);
+ tr->lpstrText[0] = '\0';
int cpMax = static_cast<int>(tr->chrg.cpMax);
if (cpMax == -1)
cpMax = pdoc->Length();
Paul.