X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2ed48ef81e612403f8af51374e1e705989a60e0f..0a434b1015342838eb38e95a5040cc50ce03911a:/src/stc/stc.cpp diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index cc580a1ff3..20aff095a3 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -1504,11 +1504,7 @@ bool wxStyledTextCtrl::GetModify() const // Retrieve the selected text. wxString wxStyledTextCtrl::GetSelectedText() { - long start; - long end; - - GetSelection(&start, &end); - int len = end - start; + const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0); if (!len) return wxEmptyString; wxMemoryBuffer mbuf(len+2); @@ -4128,16 +4124,10 @@ wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line) wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw() { - long start; - long end; - - GetSelection(&start, &end); - int len = end - start; - if (!len) { - wxCharBuffer empty; - return empty; - } + // Calculate the length needed first. + const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0); + // And then really get the data. wxCharBuffer buf(len); SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data()); return buf;