Modified isWordSelected so that only boundary characters are checked. This allows non-word chars to appear inside, for example hyphenated words.