Fix calculation of the wxStyledTextCtrl selection size.
Use SCI_GETSELTEXT to compute the size of the buffer instead of doing it ourselves, especially as we do it incorrectly in case of rectangular selection. Closes #14331. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71540 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -4128,16 +4128,10 @@ wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line)
|
|||||||
|
|
||||||
wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
|
wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
|
||||||
{
|
{
|
||||||
long start;
|
// Calculate the length needed first.
|
||||||
long end;
|
const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0);
|
||||||
|
|
||||||
GetSelection(&start, &end);
|
|
||||||
int len = end - start;
|
|
||||||
if (!len) {
|
|
||||||
wxCharBuffer empty;
|
|
||||||
return empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// And then really get the data.
|
||||||
wxCharBuffer buf(len);
|
wxCharBuffer buf(len);
|
||||||
SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data());
|
SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data());
|
||||||
return buf;
|
return buf;
|
||||||
|
@@ -628,16 +628,10 @@ wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line)
|
|||||||
|
|
||||||
wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
|
wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
|
||||||
{
|
{
|
||||||
long start;
|
// Calculate the length needed first.
|
||||||
long end;
|
const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0);
|
||||||
|
|
||||||
GetSelection(&start, &end);
|
|
||||||
int len = end - start;
|
|
||||||
if (!len) {
|
|
||||||
wxCharBuffer empty;
|
|
||||||
return empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// And then really get the data.
|
||||||
wxCharBuffer buf(len);
|
wxCharBuffer buf(len);
|
||||||
SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data());
|
SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data());
|
||||||
return buf;
|
return buf;
|
||||||
|
Reference in New Issue
Block a user