fix #13528 nimgrep --word now works better with operators (#13537)

This commit is contained in:
Timothee Cour 2020-03-02 08:55:17 -08:00 • committed by GitHub
commit 27241fda23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -649,7 +649,8 @@ else:
if optIgnoreStyle in options:
pattern = styleInsensitive(pattern)
if optWord in options:
pattern = r"\b(:?" & pattern & r")\b"
# see https://github.com/nim-lang/Nim/issues/13528#issuecomment-592786443
pattern = r"(^|\W)(:?" & pattern & r")($|\W)"
if {optIgnoreCase, optIgnoreStyle} * options != {}:
reflags.incl reIgnoreCase
let rep = if optRex in options: rex(pattern, reflags)