Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 3c0d6e0

Browse files
committed
fixed out of range exceptions
1 parent 880fdbf commit 3c0d6e0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Utils/BracketHighlightHelpers.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public bool CheckForCommentBlockForward(IDocument document, int offset)
119119
// not possible that we've been in a comment block
120120
// that's a nested comment compiling error
121121

122-
if (ch == '/' && document.GetCharAt(i + 1) == '*')
122+
if (ch == '/' && i + 1 < document.TextLength && document.GetCharAt(i + 1) == '*')
123123
{
124124
return false;
125125
}
@@ -139,7 +139,7 @@ public bool CheckForCommentBlockBackward(IDocument document, int offset)
139139
// therefore, we've been inside a code block this whole time:
140140
// this bracket should be ignored by the highlighter
141141

142-
if (ch == '*' && document.GetCharAt(i - 1) == '/')
142+
if (ch == '*' && i > 0 && document.GetCharAt(i - 1) == '/')
143143
{
144144
return true;
145145
}
@@ -166,7 +166,7 @@ public bool CheckForCommentLine(IDocument document, int offset)
166166
// If we find two ' // ' together as we scan backwards
167167
// we find we are in a comment line, and should ignore the bracket
168168

169-
if (i > 0 && ch == '/' && document.GetCharAt(i - 1) == '/')
169+
if (ch == '/' && i > 0 && document.GetCharAt(i - 1) == '/')
170170
{
171171
return true;
172172
}
@@ -224,7 +224,7 @@ public bool CheckForString(IDocument document, int offset)
224224
return true;
225225
}
226226

227-
if (ch == '\\' && document.GetCharAt(i + 1) == '\r')
227+
if (ch == '\\' && i + 1 < document.TextLength && document.GetCharAt(i + 1) == '\r')
228228
{
229229
continue;
230230
}

0 commit comments

Comments
 (0)