{
// Stop searching if we're beyond the range of interest
if (para->GetRange().GetStart() > range.GetEnd())
- return foundCount == matchingCount;
+ return foundCount == matchingCount && foundCount != 0;
if (!para->GetRange().IsOutside(range))
{
while (node2)
{
wxRichTextObject* child = node2->GetData();
- if (!child->GetRange().IsOutside(range) && child->IsKindOf(CLASSINFO(wxRichTextPlainText)))
+ // Allow for empty string if no buffer
+ wxRichTextRange childRange = child->GetRange();
+ if (childRange.GetLength() == 0 && GetRange().GetLength() == 1)
+ childRange.SetEnd(childRange.GetEnd()+1);
+
+ if (!childRange.IsOutside(range) && child->IsKindOf(CLASSINFO(wxRichTextPlainText)))
{
foundCount ++;
wxTextAttr textAttr = para->GetCombinedAttributes(child->GetAttributes());
{
// Stop searching if we're beyond the range of interest
if (para->GetRange().GetStart() > range.GetEnd())
- return foundCount == matchingCount;
+ return foundCount == matchingCount && foundCount != 0;
if (!para->GetRange().IsOutside(range))
{
// Detect last line in the buffer
else if (!node2->GetNext() && para->GetRange().Contains(m_buffer->GetRange().GetEnd()))
{
- foundEnd = true;
- lastY = pt.y + line->GetSize().y;
+ // If deleting text, make sure we refresh below as well as above
+ if (positionOffset >= 0)
+ {
+ foundEnd = true;
+ lastY = pt.y + line->GetSize().y;
+ }
node2 = wxRichTextLineList::compatibility_iterator();
node = wxRichTextObjectList::compatibility_iterator();
if (HasSelection())
{
long pos = m_selectionRange.GetStart();
- GetBuffer().DeleteRangeWithUndo(m_selectionRange, this);
+ wxRichTextRange range = m_selectionRange;
+
+ // SelectAll causes more to be selected than doing it interactively,
+ // and causes a new paragraph to be inserted. So for multiline buffers,
+ // don't delete the final position.
+ if (range.GetEnd() == GetLastPosition() && GetNumberOfLines() > 0)
+ range.SetEnd(range.GetEnd()-1);
+
+ GetBuffer().DeleteRangeWithUndo(range, this);
m_selectionRange.SetRange(-2, -2);
if (newPos)
return;
// Don't set scrollbars if there were none before, and there will be none now.
- if (oldPPUY != 0 && (oldVirtualSizeY < clientSize.y) && (unitsY*pixelsPerUnit < clientSize.y))
+ if (oldPPUY != 0 && (oldVirtualSizeY*oldPPUY < clientSize.y) && (unitsY*pixelsPerUnit < clientSize.y))
return;
// Move to previous scroll position if
else
{
wxRichTextRange oldSelection = m_selectionRange;
- m_selectionAnchor = from;
+ m_selectionAnchor = from-1;
m_selectionRange.SetRange(from, to-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);
void wxRichTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event)
{
- event.Enable(GetLastPosition() > 0);
+ event.Enable(GetLastPosition() >= 0);
}
void wxRichTextCtrl::OnContextMenu(wxContextMenuEvent& event)