Ticket #8141: ReplaceAll3.patch

File ReplaceAll3.patch, 3.7 KB (added by x-ist, 12 years ago)

Now hopefully correctly generated patch.

  • src/apps/deskbar/ExpandoMenuBar.cpp

    From 93b76059ee9a4716dae3c0424c1d5e7841a9b469 Mon Sep 17 00:00:00 2001
    From: Yourself <user@shredder.(none)>
    Date: Sun, 22 Jul 2012 10:46:40 +0000
    Subject: [PATCH] Fixes non-terminating ReplaceAll in cases such as when in
     text "A B", "B" is replaced by "A B" again.
    
    ---
     src/apps/deskbar/ExpandoMenuBar.cpp      |    5 +++++
     src/apps/deskbar/ExpandoMenuBar.h        |    2 ++
     src/apps/stylededit/StyledEditWindow.cpp |   23 ++++++++++++++++++-----
     src/apps/stylededit/StyledEditWindow.h   |    3 ++-
     4 files changed, 27 insertions(+), 6 deletions(-)
    
    diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp
    index 997c0d1..4ee0b04 100644
    a b TExpandoMenuBar::TExpandoMenuBar(TBarView* bar, BRect frame, const char* name,  
    104104    }
    105105}
    106106
     107TExpandoMenuBar::~TExpandoMenuBar()
     108{
     109    int breakHere = 88;
     110    breakHere = breakHere -1;
     111}
    107112
    108113int
    109114TExpandoMenuBar::CompareByName(const void* first, const void* second)
  • src/apps/deskbar/ExpandoMenuBar.h

    diff --git a/src/apps/deskbar/ExpandoMenuBar.h b/src/apps/deskbar/ExpandoMenuBar.h
    index 4eabc96..de0190a 100644
    a b class TExpandoMenuBar : public BMenuBar {  
    6363    public:
    6464        TExpandoMenuBar(TBarView* bar, BRect frame, const char* name,
    6565            bool vertical, bool drawLabel = true);
     66       
     67        ~TExpandoMenuBar();
    6668
    6769        virtual void AttachedToWindow();
    6870        virtual void DetachedFromWindow();
  • src/apps/stylededit/StyledEditWindow.cpp

    diff --git a/src/apps/stylededit/StyledEditWindow.cpp b/src/apps/stylededit/StyledEditWindow.cpp
    index 3ac8541..37fa6ac 100644
    a b StyledEditWindow::_RevertToSaved()  
    14081408
    14091409bool
    14101410StyledEditWindow::_Search(BString string, bool caseSensitive, bool wrap,
    1411     bool backSearch)
     1411    bool backSearch, bool scrollToOccurence)
    14121412{
    14131413    int32 start;
    14141414    int32 finish;
    StyledEditWindow::_Search(BString string, bool caseSensitive, bool wrap,  
    14501450    if (start != B_ERROR) {
    14511451        finish = start + length;
    14521452        fTextView->Select(start, finish);
    1453         fTextView->ScrollToSelection();
     1453       
     1454        if (scrollToOccurence)
     1455            fTextView->ScrollToSelection();
    14541456        return true;
    14551457    }
    14561458
    StyledEditWindow::_ReplaceAll(BString findThis, BString replaceWith,  
    15011503{
    15021504    bool first = true;
    15031505    fTextView->SetSuppressChanges(true);
    1504     while (_Search(findThis, caseSensitive, true, false)) {
     1506   
     1507    // start from the beginning of text
     1508    fTextView->Select(0,0);
     1509       
     1510    int32 start, finish;
     1511
     1512    // iterate occurences of findThis without wrapping around
     1513    while (_Search(findThis, caseSensitive, false, false, false)) {
    15051514        if (first) {
    15061515            _UpdateCleanUndoRedoSaveRevert();
    15071516            first = false;
    15081517        }
    1509         int32 start, finish;
     1518       
    15101519        fTextView->GetSelection(&start, &finish);
    1511 
    15121520        fTextView->Delete(start, start + findThis.Length());
    15131521        fTextView->Insert(start, replaceWith.String(), replaceWith.Length());
     1522       
     1523        // advance the caret behind the inserted text
     1524        start += replaceWith.Length();
     1525        fTextView->Select(start, start);
    15141526    }
     1527    fTextView->ScrollToSelection();
    15151528    fTextView->SetSuppressChanges(false);
    15161529}
    15171530
  • src/apps/stylededit/StyledEditWindow.h

    diff --git a/src/apps/stylededit/StyledEditWindow.h b/src/apps/stylededit/StyledEditWindow.h
    index 241de30..d107917 100644
    a b private:  
    5757            status_t            _LoadFile(entry_ref* ref);
    5858            void                _RevertToSaved();
    5959            bool                _Search(BString searchFor, bool caseSensitive,
    60                                     bool wrap, bool backSearch);
     60                                    bool wrap, bool backSearch,
     61                                    bool scrollToOccurence = true);
    6162            void                _FindSelection();
    6263            bool                _Replace(BString findThis, BString replaceWith,
    6364                                    bool caseSensitive, bool wrap,