diff --git a/plugins/textmate/src/org/jetbrains/plugins/textmate/regex/RegexUtil.java b/plugins/textmate/src/org/jetbrains/plugins/textmate/regex/RegexUtil.java index e99a03d4e12f1..cef9040d39280 100644 --- a/plugins/textmate/src/org/jetbrains/plugins/textmate/regex/RegexUtil.java +++ b/plugins/textmate/src/org/jetbrains/plugins/textmate/regex/RegexUtil.java @@ -2,6 +2,7 @@ import com.google.common.base.Preconditions; import com.intellij.openapi.util.TextRange; +import org.jcodings.specific.NonStrictUTF8Encoding; import org.jcodings.specific.UTF8Encoding; import org.jetbrains.annotations.NotNull; @@ -14,7 +15,7 @@ public static int charOffsetByByteOffset(byte[] stringBytes, int byteOffset) { return 0; } Preconditions.checkPositionIndex(byteOffset, stringBytes.length); - return UTF8Encoding.INSTANCE.strLength(stringBytes, 0, byteOffset); + return NonStrictUTF8Encoding.INSTANCE.strLength(stringBytes, 0, byteOffset); } public static int byteOffsetByCharOffset(@NotNull CharSequence charSequence, int charOffset) { diff --git a/plugins/textmate/testData/lexer/markdown/unknown_utf.md b/plugins/textmate/testData/lexer/markdown/unknown_utf.md new file mode 100644 index 0000000000000..cff1f62deee8a --- /dev/null +++ b/plugins/textmate/testData/lexer/markdown/unknown_utf.md @@ -0,0 +1 @@ +## 🚧🚧🚧 UNDER CONSTRUCTION 🚧🚧🚧 \ No newline at end of file diff --git a/plugins/textmate/testData/lexer/markdown/unknown_utf_after.md b/plugins/textmate/testData/lexer/markdown/unknown_utf_after.md new file mode 100644 index 0000000000000..17a293c189256 --- /dev/null +++ b/plugins/textmate/testData/lexer/markdown/unknown_utf_after.md @@ -0,0 +1,4 @@ +text.html.markdown markup.heading.${1/(#)(#)?(#)?(#)?(#)?(#)?/${6:?6:${5:?5:${4:?4:${3:?3:${2:?2:1}}}}}/}.markdown punctuation.definition.heading.markdown: [0, 2], {##} +text.html.markdown markup.heading.${1/(#)(#)?(#)?(#)?(#)?(#)?/${6:?6:${5:?5:${4:?4:${3:?3:${2:?2:1}}}}}/}.markdown: [2, 3], { } +text.html.markdown markup.heading.${1/(#)(#)?(#)?(#)?(#)?(#)?/${6:?6:${5:?5:${4:?4:${3:?3:${2:?2:1}}}}}/}.markdown entity.name.section.markdown: [3, 29], {🚧🚧🚧 UNDER CONSTRUCTION } +text.html.markdown meta.paragraph.markdown: [29, 35], {🚧🚧🚧} \ No newline at end of file