aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2009-07-15 07:19:22 +0000
committernyamatongwe <unknown>2009-07-15 07:19:22 +0000
commitb9cb2eb38f6dc23b2b6a46d59de2436b2b9824da (patch)
tree0d6fe37475ffd795b10511f3b510fd39c4c9948c
parent7ef9b27e87eb98ae11811bab4e78550b27941aaf (diff)
downloadscintilla-mirror-b9cb2eb38f6dc23b2b6a46d59de2436b2b9824da.tar.gz
Fixed bug where wrong length was returned for SCI_GETSELTEXT with NULL
lParam when there are multiple selections.
-rw-r--r--src/Editor.cxx34
1 files changed, 11 insertions, 23 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 71c8965fb..17076a373 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -6441,33 +6441,21 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_GETSELTEXT: {
- if (lParam == 0) {
- if (sel.selType == Selection::selStream) {
- return 1 + SelectionEnd().Position() - SelectionStart().Position();
- } else {
- // TODO: why is selLines handled the slow way?
- int size = 0;
- int extraCharsPerLine = 0;
- if (sel.selType != Selection::selLines)
- extraCharsPerLine = (pdoc->eolMode == SC_EOL_CRLF) ? 2 : 1;
- for (size_t r=0; r<sel.Count(); r++) {
- size += sel.Range(r).Length() + extraCharsPerLine;
- }
-
- return 1 + size;
- }
- }
SelectionText selectedText;
CopySelectionRange(&selectedText);
- char *ptr = CharPtrFromSPtr(lParam);
- int iChar = 0;
- if (selectedText.len) {
- for (; iChar < selectedText.len; iChar++)
- ptr[iChar] = selectedText.s[iChar];
+ if (lParam == 0) {
+ return selectedText.len;
} else {
- ptr[0] = '\0';
+ char *ptr = CharPtrFromSPtr(lParam);
+ int iChar = 0;
+ if (selectedText.len) {
+ for (; iChar < selectedText.len; iChar++)
+ ptr[iChar] = selectedText.s[iChar];
+ } else {
+ ptr[0] = '\0';
+ }
+ return iChar;
}
- return iChar;
}
case SCI_LINEFROMPOSITION: