From b51e2fa0dac0767ce70df7c7ac8895b5402a939b Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Mon, 11 Dec 2017 09:11:13 -0800 Subject: [PATCH] Fix potential NPE. --- .../commons/yaml/structure/YamlDocument.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/structure/YamlDocument.java b/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/structure/YamlDocument.java index 756162f47..cf01d4412 100644 --- a/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/structure/YamlDocument.java +++ b/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/structure/YamlDocument.java @@ -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; }