diff --git a/libjcore/code/JCoreLibVersion.h b/libjcore/code/JCoreLibVersion.h index 0e8eca5ca..cee113abc 100644 --- a/libjcore/code/JCoreLibVersion.h +++ b/libjcore/code/JCoreLibVersion.h @@ -39,6 +39,9 @@ static const char* kCurrentJCoreLibVersionStr = "4.2.0"; // JError: // Optimized to store JUtf8Byte* when possible. // *** Removed 2nd arg from ctor. Call SetMessage() instead. +// JTextEditor: +// Fixed bug in GetCharRight() to work for first character on line. +// Fixed bug so original selection is fully cleared after undo/redo. // version 4.1.0: // diff --git a/libjcore/code/JTextEditor.cpp b/libjcore/code/JTextEditor.cpp index 5e98f999a..28507ac8a 100644 --- a/libjcore/code/JTextEditor.cpp +++ b/libjcore/code/JTextEditor.cpp @@ -434,16 +434,23 @@ JTextEditor::Receive TextRange r = itsSelection; r.charRange += cd; r.byteRange += bd; + + itsSelection.charRange += cd; // redraw correct range + itsSelection.byteRange += bd; SetSelection(r, true, true); } else if (!itsSelection.IsEmpty() && r.charRange.first < itsSelection.charRange.first) { + itsSelection.charRange += cd; // redraw correct range + itsSelection.byteRange += bd; SetCaretLocation(CalcCaretLocation(r.GetFirst())); } else if (!itsSelection.IsEmpty() && r.charRange.first < itsSelection.charRange.last) { + itsSelection.charRange.last += cd; // redraw correct range + itsSelection.byteRange.last += bd; SetCaretLocation(CalcCaretLocation(itsSelection.GetFirst())); } @@ -2922,7 +2929,7 @@ JTextEditor::SetCaretLocation itsText->DeactivateCurrentUndo(); - const bool hadSelection = !itsSelection.IsEmpty(); + const bool hadSelection = !itsSelection.IsEmpty(); const CaretLocation origCaretLoc = itsCaret; if (hadSelection) @@ -3618,13 +3625,7 @@ JTextEditor::GetCharRight const { const TextIndex firstChar = GetLineStart(charLoc.lineIndex); - - JCoordinate x = 0; - if (charLoc.location.charIndex > firstChar.charIndex) - { - x = GetStringWidth(firstChar, charLoc.location, nullptr); - } - return x; + return GetStringWidth(firstChar, charLoc.location, nullptr); } /******************************************************************************