Menu

#133 Replace all should save position of first occurence

v1.1.x
fixed
critical (96)
v1.1.0
Bug Fix
2017-02-15
2017-01-26
Erik Hänel
No

Replace all should save the position of the first occurence of the found string, because otherwise replace all could result in an endless loop if combined with wrap around and a replace string containing the search string.

Analysis:
Some additional logic has to be implemented in NumeReWindow::ReplaceAllStrings(), e.g. going to Position 0 and removing the wxFR_WRAPAROUND flag locally, if this flag was set.

Implementation:
The following lines were added to the function ReplaceAllStrings():

if (flags & wxFR_WRAPAROUND)
{
    m_currentEd->GotoPos(0);
    flags &= flags & ~wxFR_WRAPAROUND;
}

This prevents NumeRe from looping.

Additionally the following issues were processed:

  • The replace dialog was locked even if one entered a find string.
  • The replace button was set to match case even if the dialog explicitely was not

Documentation:
Not needed - Bug fix.

Tests:
Repeated tests of the replace all functionality with replace strings containing the search string were passed without any deviation. Search and replace dialogs working as expected. Bug fix accepted.

Discussion

  • Erik Hänel

    Erik Hänel - 2017-01-26
    • labels: --> critical
    • status: open --> accepted
     
  • Erik Hänel

    Erik Hänel - 2017-01-26
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1 +1,9 @@
     Replace all should save the position of the first occurence of the found string, because otherwise replace all could result in an endless loop if combined with wrap around and a replace string containing the search string.
    +
    +**Analysis:**
    +
    +**Implementation:**
    +
    +**Documentation:**
    +
    +**Tests:**
    
    • status: accepted --> analyzing
     
  • Erik Hänel

    Erik Hänel - 2017-01-26
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,6 +1,7 @@
     Replace all should save the position of the first occurence of the found string, because otherwise replace all could result in an endless loop if combined with wrap around and a replace string containing the search string.
    
     **Analysis:**
    +Some additional logic has to be implemented in `NumeReWindow::ReplaceAllStrings()`, e.g. going to Position 0 and removing the `wxFR_WRAPAROUND` flag locally, if this flag was set.
    
     **Implementation:**
    
    • status: analyzing --> implementing
     
  • Erik Hänel

    Erik Hänel - 2017-01-26
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -4,7 +4,22 @@
     Some additional logic has to be implemented in `NumeReWindow::ReplaceAllStrings()`, e.g. going to Position 0 and removing the `wxFR_WRAPAROUND` flag locally, if this flag was set.
    
     **Implementation:**
    +The following lines were added to the function `ReplaceAllStrings()`:
    +~~~C
    +if (flags & wxFR_WRAPAROUND)
    +{
    
    +    m_currentEd->GotoPos(0);
    +    flags &= flags & ~wxFR_WRAPAROUND;
    +}
    +~~~
    +This prevents NumeRe from looping.
    +
    +Additionally the following issues were processed:
    +
    +- The replace dialog was locked even if one entered a find string.
    +- The replace button was set to match case even if the dialog explicitely was not
    
     **Documentation:**
    +Not needed - Bug fix.
    
     **Tests:**
    
    • status: implementing --> testing
     
  • Erik Hänel

    Erik Hänel - 2017-02-15
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -23,3 +23,4 @@
     Not needed - Bug fix.
    
     **Tests:**
    +Repeated tests of the replace all functionality with replace strings containing the search string were passed without any deviation. Search and replace dialogs working as expected. Bug fix accepted.
    
    • status: testing --> fixed
     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB