Skip to content

Commit

Permalink
fix nim-lang#13528 nimgrep --word now works better with operators
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Mar 2, 2020
1 parent 653de5f commit 8f2bc71
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/nimgrep.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8f2bc71

Please sign in to comment.