Fix potential NPE.

This commit is contained in:
Kris De Volder
2017-12-11 09:11:13 -08:00
parent 6d71fa49b8
commit b51e2fa0da

View File

@@ -104,13 +104,15 @@ public class YamlDocument {
//So comments never span multiple lines of text and we only have scan back
//from offset upto the start of the current line.
IRegion lineInfo = doc.getLineInformationOfOffset(offset);
int startOfLine = lineInfo.getOffset();
while (offset>=startOfLine) {
char c = getChar(offset);
if (c=='#') {
return true;
if (lineInfo!=null) {
int startOfLine = lineInfo.getOffset();
while (offset>=startOfLine) {
char c = getChar(offset);
if (c=='#') {
return true;
}
offset--;
}
offset--;
}
return false;
}