From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Fri, 25 May 2012 09:48:12 +0000 (+0000)
Subject: Fix calculation of wxStyledTextCtrl selection size in GetSelectedText().
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/6094165c4ed039b573b11d405a18de07692b1bdf

Fix calculation of wxStyledTextCtrl selection size in GetSelectedText().

Do the same changes as were done in r71540 to GetSelectedTextRaw() in
GetSelectedText() itself by modifying the code in gen_iface.py that generates
it.

Closes #14331.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71556 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py
index 55eaa895b1..831cf85fe4 100755
--- a/src/stc/gen_iface.py
+++ b/src/stc/gen_iface.py
@@ -509,11 +509,7 @@ methodOverrideMap = {
      'wxString %s();',
 
      '''wxString %s() {
-         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);
diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp
index b5d71eebbe..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);