From 49ebac7102851d2c9d0e8e29404fda43b679383b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 25 Aug 2017 01:12:17 +0200 Subject: [PATCH] Revert "Simplify wxTextCtrl::GetLastPosition" This reverts commit c4e1fb4ef939a8297eb017f89df06f5f6f72c539. Last position is not necessarily the number of characters in the buffer, rich edit controls still store the text using CR LF between lines, but GetLastPosition() should return the position as if they used only LF to be consistent with all the other positions in these controls and changing this broke existing code passing GetLastPosition() to other functions taking position. --- src/msw/textctrl.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 842a08b364..028d9709c0 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -1334,7 +1334,12 @@ wxTextPos wxTextCtrl::GetLastPosition() const { if ( IsMultiLine() ) { - return ::GetWindowTextLength(GetHwnd()); + int numLines = GetNumberOfLines(); + long posStartLastLine = XYToPosition(0, numLines - 1); + + long lenLastLine = GetLengthOfLineContainingPos(posStartLastLine); + + return posStartLastLine + lenLastLine; } return wxTextEntry::GetLastPosition();