diff --git a/internal/check/definition.go b/internal/check/definition.go index 6f5d299e..e22fae93 100755 --- a/internal/check/definition.go +++ b/internal/check/definition.go @@ -329,6 +329,15 @@ func updateExceptions(previous []string, current map[string]struct{}) (*regexp2. return len(previous[p]) > len(previous[q]) }) + // NOTE: We need to add `(?-i)` to each term that doesn't already have it, + // otherwise any instance of the `(?i)` flag will be set for the entire + // expression. + for i, term := range previous { + if !strings.HasPrefix(term, "(?i)") { + previous[i] = fmt.Sprintf("(?-i)%s", term) + } + } + regex := makeRegexp( "", false, diff --git a/testdata/features/misc.feature b/testdata/features/misc.feature index 408baaa3..248786a1 100755 --- a/testdata/features/misc.feature +++ b/testdata/features/misc.feature @@ -10,6 +10,7 @@ Feature: Misc test.md:17:11:Vale.Terms:Use 'Log4j' instead of 'log4j'. test.md:19:1:Vale.Terms:Use 'ABCDEF' instead of 'ABCDEf'. test.md:21:1:Vale.Terms:Use 'ABC-DEF' instead of 'ABC-DEf'. + test.md:23:1:Vale.Terms:Use 'PLuG' instead of 'plug'. """ Scenario: Multiple Vocabs diff --git a/testdata/fixtures/vocab/Basic/test.md b/testdata/fixtures/vocab/Basic/test.md index 25c9f9ce..97ad5f5c 100755 --- a/testdata/fixtures/vocab/Basic/test.md +++ b/testdata/fixtures/vocab/Basic/test.md @@ -18,4 +18,8 @@ I use the log4j library. ABCDEf -ABC-DEf \ No newline at end of file +ABC-DEf + +plug + +Github \ No newline at end of file diff --git a/testdata/fixtures/vocab/styles/Vocab/Basic/accept.txt b/testdata/fixtures/vocab/styles/Vocab/Basic/accept.txt index b5a8a3b0..f2672456 100755 --- a/testdata/fixtures/vocab/styles/Vocab/Basic/accept.txt +++ b/testdata/fixtures/vocab/styles/Vocab/Basic/accept.txt @@ -5,3 +5,5 @@ Documentarians Log4j ABCDEF ABC-DEF +PLuG +(?i)GitHub \ No newline at end of file