Skip to content

Commit

Permalink
Fix calculation of the wxStyledTextCtrl selection size.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vadz committed May 23, 2012
1 parent 28b715a commit 14a9a7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
12 changes: 3 additions & 9 deletions src/stc/stc.cpp
Expand Up @@ -4128,16 +4128,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;
Expand Down
12 changes: 3 additions & 9 deletions src/stc/stc.cpp.in
Expand Up @@ -628,16 +628,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;
Expand Down

0 comments on commit 14a9a7a

Please sign in to comment.