diff --git a/src/Unused/TermSearch/Internal.hs b/src/Unused/TermSearch/Internal.hs index 60a5844..fa394c4 100644 --- a/src/Unused/TermSearch/Internal.hs +++ b/src/Unused/TermSearch/Internal.hs @@ -7,7 +7,7 @@ import Unused.Regex commandLineOptions :: String -> [String] commandLineOptions t = case regexSafeTerm t of - True -> ["\\W" ++ t ++ "\\W", ".", "-c", "--ackmate"] + True -> ["(\\W|^)" ++ t ++ "(\\W|$)", ".", "-c", "--ackmate"] False -> [t, ".", "-c", "-Q", "--ackmate"] regexSafeTerm :: String -> Bool diff --git a/test/Unused/TermSearch/InternalSpec.hs b/test/Unused/TermSearch/InternalSpec.hs index 83ffb8a..c632d89 100644 --- a/test/Unused/TermSearch/InternalSpec.hs +++ b/test/Unused/TermSearch/InternalSpec.hs @@ -19,4 +19,4 @@ spec = parallel $ commandLineOptions "window.globalOverride" `shouldBe` ["window.globalOverride", ".", "-c", "-Q", "--ackmate"] it "uses regular expression match with surrounding non-word matches for accuracy" $ - commandLineOptions "awesome_method" `shouldBe` ["\\Wawesome_method\\W", ".", "-c", "--ackmate"] + commandLineOptions "awesome_method" `shouldBe` ["(\\W|^)awesome_method(\\W|$)", ".", "-c", "--ackmate"]