Walt Farrell - 2014-07-28

Both the Search/Replace dialog and the Spellcheck dialog use the same Tk subroutine (FindAndReplaceAll) to do the replacement. However, Search/Replace has code that handles the "full word only" case by converting the search term into a regex that matches only full words, and telling Tk to do a regex search instead of a normal search.

The Spellcheck dialog does not have that code, so when it calls Tk the search is not limited to full words only. It would be fairly simple to copy that code into the Spellcheck dialog, and it seems reasonable to do so.

I made the following change (copied, with minor modifications, from the code in SearchReplaceMenu.pm) to subroutine spellreplaceall in my copy of lib\Guituts\Spellcheck.pm which seems to resolve the problem:

Original lines:
$textwindow->FindAndReplaceAll( '-exact', '-nocase',
$misspelled, $replacement );

Replacement:
$misspelled = ::escape_regexmetacharacters($misspelled)
; # this is a whole word search
$misspelled = '(?<!\p{Alnum})' . $misspelled . '(?!\p{Alnum})';
$textwindow->FindAndReplaceAll( '-regexp', '-nocase',
$misspelled, $replacement);