diff --git a/plugins/grazie/src/test/testData/ide/language/markdown/Example.md b/plugins/grazie/src/test/testData/ide/language/markdown/Example.md index d11115592148..2bb688ec1405 100644 --- a/plugins/grazie/src/test/testData/ide/language/markdown/Example.md +++ b/plugins/grazie/src/test/testData/ide/language/markdown/Example.md @@ -61,4 +61,6 @@ das daert geschätzt fünf up to date product. \ No newline at end of file +This is an up to date product. + +Spellcheck doesn’t mind right single quotation mark. diff --git a/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java b/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java index a7d16f07f7d3..28cf3acbf5f5 100644 --- a/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java +++ b/spellchecker/src/com/intellij/spellchecker/inspections/IdentifierSplitter.java @@ -102,7 +102,8 @@ public class IdentifierSplitter extends BaseSplitter { type == Character.OTHER_LETTER || type == Character.MODIFIER_LETTER || type == Character.NON_SPACING_MARK || - type == Character.OTHER_PUNCTUATION + type == Character.OTHER_PUNCTUATION || + ch == '\u2019' // right single quotation mark ) { //letter if (s < 0) { diff --git a/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java b/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java index b81f45ca4e51..c671f2022ad9 100644 --- a/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java +++ b/spellchecker/src/com/intellij/spellchecker/inspections/TextSplitter.java @@ -21,13 +21,15 @@ public class TextSplitter extends BaseSplitter { private static final String letter = "(\\p{L}\\p{Mn}*)"; private static final String xmlEntity = "(&.+?;)"; + private static final String rightSingleQuotationMark = "\\u2019"; + // using possessive quantifiers ++ and *+ to avoid SOE on large inputs // see https://blog.sonarsource.com/crafting-regexes-to-avoid-stack-overflows/ private static final Pattern EXTENDED_WORD_AND_SPECIAL = Pattern.compile( xmlEntity + "|" + "(#|0x\\d*)?" + // an optional prefix letter + "++" + // some letters - "('" + letter + ")?" + // if there's an apostrophe, it should be followed by a letter + "(['" + rightSingleQuotationMark + "]" + letter + ")?" + // if there's an apostrophe, it should be followed by a letter "(_|" + letter + ")*+" // more letters and underscores ); @Override