diff --git a/uppsrc/CtrlLib/DocEdit.cpp b/uppsrc/CtrlLib/DocEdit.cpp index fd7cbf5a7..13d2fea2a 100644 --- a/uppsrc/CtrlLib/DocEdit.cpp +++ b/uppsrc/CtrlLib/DocEdit.cpp @@ -240,9 +240,8 @@ void DocEdit::PlaceCaret(int64 newpos, bool select) { newpos = GetLength32(); int z = GetLine(newpos); if(select) { - if(anchor < 0) { + if(anchor < 0) anchor = cursor; - } RefreshLines(z, GetLine(cursor)); } else diff --git a/uppsrc/CtrlLib/Text.cpp b/uppsrc/CtrlLib/Text.cpp index 5690e0dab..082dfcf1b 100644 --- a/uppsrc/CtrlLib/Text.cpp +++ b/uppsrc/CtrlLib/Text.cpp @@ -810,6 +810,7 @@ int TextCtrl::Insert0(int pos, const WString& txt) { // TODO: Do this with utf8 total += size; SetSb(); Update(); + ClearSelection(); PostInsert(inspos, txt); return size; } @@ -851,6 +852,7 @@ void TextCtrl::Remove0(int pos, int size) { Refresh(); } Update(); + ClearSelection(); PostRemove(rmpos, rmsize); SetSb(); } @@ -1010,10 +1012,12 @@ void TextCtrl::Redo() { } void TextCtrl::ClearSelection() { - anchor = -1; - Refresh(); - SelectionChanged(); - WhenSel(); + if(anchor >= 0) { + anchor = -1; + Refresh(); + SelectionChanged(); + WhenSel(); + } } void TextCtrl::SetSelection(int64 l, int64 h) {