Ticket #1828: 1828.patch

File 1828.patch, 3.7 KB (added by Martin Kou, 16 years ago)
  • _whatsnew.html

     
    9090                        the type of an existing button.</li>
    9191                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1854">#1854</a>] Indentation now works inside
    9292                        table cells.</li>
     93                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1828">#1828</a>] The Find/Replace dialog
     94                        will no longer display wrong starting positions for the match when there are multiple and identical
     95                        characters preceding the character at the real starting point of the match.</li>
    9396        </ul>
    9497        <p>
    9598                <a href="_whatsnew_history.html">See previous versions history</a>
  • editor/dialog/fck_replace.html

     
    9797
    9898function btnStat(frm)
    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
    106106function GetSearchString()
    107107{
    108         return document.getElementById(idMap['FindText']).value ;
     108        return GetE(idMap['FindText']).value ;
    109109}
    110110
    111111function GetReplaceString()
    112112{
    113         return document.getElementById("txtReplace").value ;
     113        return GetE("txtReplace").value ;
    114114}
    115115
    116116function GetCheckCase()
    117117{
    118         return !! ( document.getElementById(idMap['CheckCase']).checked ) ;
     118        return !! ( GetE(idMap['CheckCase']).checked ) ;
    119119}
    120120
    121121function GetMatchWord()
    122122{
    123         return !! ( document.getElementById(idMap['CheckWord']).checked ) ;
     123        return !! ( GetE(idMap['CheckWord']).checked ) ;
    124124}
    125125
    126126// Get the data pointed to by a bookmark.
     
    221221
    222222// Knuth-Morris-Pratt Algorithm for stream input
    223223KMP_NOMATCH = 0 ;
    224 KMP_ADVANCED = 1 ;
    225 KMP_MATCHED = 2 ;
     224KMP_STARTED = 1 ;
     225KMP_ADVANCED = 2 ;
     226KMP_MATCHED = 3 ;
    226227function KmpMatch( pattern, ignoreCase )
    227228{
    228229        var overlap = [ -1 ] ;
     
    257258                                        this._State = 0;
    258259                                        return KMP_MATCHED;
    259260                                }
    260                                 return KMP_ADVANCED;
     261                                return this._State > 1 ? KMP_ADVANCED : KMP_STARTED ;
    261262                        }
    262263                        else if ( this._State == 0 )
    263264                                return KMP_NOMATCH;
     
    301302                        {
    302303                                matchState = matcher.FeedCharacter(data) ;
    303304
     305                                // No possible match of any useful substring in the pattern for the currently scanned character.
     306                                // So delete any positional information.
    304307                                if ( matchState == KMP_NOMATCH )
    305308                                        matchBookmark = null ;
    306                                 else if ( matchState == KMP_ADVANCED && matchBookmark == null )
     309                                // The currently scanned character is a possible start, so mark down the starting position.
     310                                else if ( matchState == KMP_STARTED )
    307311                                        matchBookmark = { Start : cursor.concat( [] ) } ;
     312                                // Found a complete match! Mark down the ending position as well.
    308313                                else if ( matchState == KMP_MATCHED )
    309314                                {
     315                                        // It is possible to get a KMP_MATCHED without KMP_STARTED when the match pattern is only 1 character.
     316                                        // So need to check and mark down the starting position as well.
    310317                                        if ( matchBookmark == null )
    311318                                                matchBookmark = { Start : cursor.concat( [] ) } ;
     319
    312320                                        matchBookmark.End = cursor.concat( [] ) ;
    313321                                        matchBookmark.End[ matchBookmark.End.length - 1 ]++;
    314322
    315323                                        // Wait, do we have to match a whole word?
     324                                        // If yes, carry out additional checks on what we've got.
    316325                                        if ( GetMatchWord() )
    317326                                        {
    318327                                                var startOk = false ;
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy