Changeset 1541

Show
Ignore:
Timestamp:
2008-02-18 04:14:39 (17 months ago)
Author:
martinkou
Message:

Fixed #1828 : The Find/Replace dialog will no longer display wrong starting positions for the match when there are multiple and identical characters preceding the character at the real starting point of the match.

Location:
FCKeditor/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/dialog/fck_replace.html

    r1521 r1541  
    9898function btnStat() 
    9999{ 
    100         document.getElementById('btnReplace').disabled = 
    101                 document.getElementById('btnReplaceAll').disabled = 
    102                         document.getElementById('btnFind').disabled = 
    103                                 ( document.getElementById(idMap["FindText"]).value.length == 0 ) ; 
     100        GetE('btnReplace').disabled = 
     101                GetE('btnReplaceAll').disabled = 
     102                        GetE('btnFind').disabled = 
     103                                ( GetE(idMap["FindText"]).value.length == 0 ) ; 
    104104} 
    105105 
     
    111111function GetSearchString() 
    112112{ 
    113         return document.getElementById(idMap['FindText']).value ; 
     113        return GetE(idMap['FindText']).value ; 
    114114} 
    115115 
    116116function GetReplaceString() 
    117117{ 
    118         return document.getElementById("txtReplace").value ; 
     118        return GetE("txtReplace").value ; 
    119119} 
    120120 
    121121function GetCheckCase() 
    122122{ 
    123         return !! ( document.getElementById(idMap['CheckCase']).checked ) ; 
     123        return !! ( GetE(idMap['CheckCase']).checked ) ; 
    124124} 
    125125 
    126126function GetMatchWord() 
    127127{ 
    128         return !! ( document.getElementById(idMap['CheckWord']).checked ) ; 
     128        return !! ( GetE(idMap['CheckWord']).checked ) ; 
    129129} 
    130130 
     
    227227// Knuth-Morris-Pratt Algorithm for stream input 
    228228KMP_NOMATCH = 0 ; 
    229 KMP_ADVANCED = 1 ; 
    230 KMP_MATCHED = 2 ; 
     229KMP_STARTED = 1 ; 
     230KMP_ADVANCED = 2 ; 
     231KMP_MATCHED = 3 ; 
    231232function KmpMatch( pattern, ignoreCase ) 
    232233{ 
     
    263264                                        return KMP_MATCHED; 
    264265                                } 
    265                                 return KMP_ADVANCED; 
     266                                return this._State > 1 ? KMP_ADVANCED : KMP_STARTED ; 
    266267                        } 
    267268                        else if ( this._State == 0 ) 
     
    307308                                matchState = matcher.FeedCharacter(data) ; 
    308309 
     310                                // No possible match of any useful substring in the pattern for the currently scanned character. 
     311                                // So delete any positional information. 
    309312                                if ( matchState == KMP_NOMATCH ) 
    310313                                        matchBookmark = null ; 
    311                                 else if ( matchState == KMP_ADVANCED && matchBookmark == null ) 
     314                                // The currently scanned character is a possible start, so mark down the starting position. 
     315                                else if ( matchState == KMP_STARTED ) 
    312316                                        matchBookmark = { Start : cursor.concat( [] ) } ; 
     317                                // Found a complete match! Mark down the ending position as well. 
    313318                                else if ( matchState == KMP_MATCHED ) 
    314319                                { 
     320                                        // It is possible to get a KMP_MATCHED without KMP_STARTED when the match pattern is only 1 character. 
     321                                        // So need to check and mark down the starting position as well. 
    315322                                        if ( matchBookmark == null ) 
    316323                                                matchBookmark = { Start : cursor.concat( [] ) } ; 
     324 
    317325                                        matchBookmark.End = cursor.concat( [] ) ; 
    318326                                        matchBookmark.End[ matchBookmark.End.length - 1 ]++; 
    319327 
    320328                                        // Wait, do we have to match a whole word? 
     329                                        // If yes, carry out additional checks on what we've got. 
    321330                                        if ( GetMatchWord() ) 
    322331                                        { 
  • FCKeditor/trunk/_whatsnew.html

    r1521 r1541  
    9797                        "Find what" fields in the Find and Replace dialog would now activate the find and replace  
    9898                        buttons.</li> 
     99                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1828">#1828</a>] The Find/Replace dialog 
     100                        will no longer display wrong starting positions for the match when there are multiple and identical 
     101                        characters preceding the character at the real starting point of the match.</li> 
    99102        </ul> 
    100103        <p>