Skip to content

Commit

Permalink
Merge pull request #10796 from ckeditor/ck/10719
Browse files Browse the repository at this point in the history
Fix (find-and-replace): Fixed adjacent whole words being missed by find and replace. Closes #10719.
  • Loading branch information
pomek authored Nov 4, 2021
2 parents 1bb29c9 + 62e8293 commit 5d466b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ckeditor5-find-and-replace/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export function findByTextCallback( searchTerm, options ) {
}

if ( !new RegExp( nonLetterGroup + '$' ).test( searchTerm ) ) {
regExpQuery = `${ regExpQuery }(?:_|${ nonLetterGroup }|$)`;
regExpQuery = `${ regExpQuery }(?=_|${ nonLetterGroup }|$)`;
}
}

Expand Down
8 changes: 8 additions & 0 deletions packages/ckeditor5-find-and-replace/tests/findcommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ describe( 'FindCommand', () => {
expect( results.length ).to.equal( 0 );
} );

it( 'set to true matches words separated by a single space', () => {
editor.setData( '<p>bar bar</p>' );

const { results } = command.execute( 'bar', { wholeWords: true } );

expect( results.length ).to.equal( 2 );
} );

it( 'is disabled by default', () => {
editor.setData( '<p>foo aabaraa</p>' );

Expand Down

0 comments on commit 5d466b5

Please sign in to comment.