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
parent 05e9473f80
commit 27241fda23

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)