node = node->GetNext();
}
- return foundCount == matchingCount;
+ return foundCount == matchingCount && foundCount != 0;
}
/// Test if this whole range has paragraph attributes of the specified kind. If any
node = node->GetNext();
}
- return foundCount == matchingCount;
+ return foundCount == matchingCount && foundCount != 0;
}
void wxRichTextParagraphLayoutBox::Clear()
void wxRichTextCtrl::SelectAll()
{
- SetSelection(0, GetLastPosition()+1);
- m_selectionAnchor = -1;
+ SetSelection(-1, -1);
}
/// Select none
wxRichTextRange oldSelection = m_selectionRange;
m_selectionAnchor = from;
m_selectionRange.SetRange(from, to-1);
- if (from > -2)
- m_caretPosition = from-1;
+
+ // Have to subtract 2, one because of endPos+1 rule (SetSelection docs) and another to turn into caret position.
+ m_caretPosition = wxMax(-1, to-2);
RefreshForSelectionChange(oldSelection, m_selectionRange);
PositionCaret();
void wxRichTextCtrl::SetSelectionRange(const wxRichTextRange& range)
{
- wxRichTextRange range1(range);
- if (range1 != wxRichTextRange(-2,-2) && range1 != wxRichTextRange(-1,-1) )
- range1.SetEnd(range1.GetEnd() - 1);
-
- wxASSERT( range1.GetStart() > range1.GetEnd() );
-
- SetInternalSelectionRange(range1);
+ SetSelection(range.GetStart(), range.GetEnd());
}
/// Set list style