Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Commit

Permalink
fix(diagnostics): fix null pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
KiaraGrouwstra authored and danbucholtz committed Dec 12, 2016
1 parent b6c12f5 commit 72adc86
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/highlight/highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function compileLanguage(language: any) {


export function highlightError(htmlInput: string, errorCharStart: number, errorLength: number) {
if (errorCharStart < 0 || errorLength < 1) return htmlInput;
if (errorCharStart < 0 || errorLength < 1 || htmlInput == undefined) return htmlInput;

const chars = htmlInput.split('');
let inTag = false;
Expand Down
2 changes: 1 addition & 1 deletion src/logger/logger-diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ function eachLineHasLeadingWhitespace(lines: PrintLine[], code: 'text'|'html') {
return false;
}
for (var i = 0; i < lines.length; i++) {
if ((<any>lines[i])[code].length < 1) {
if (lines[i][code] == undefined || (<any>lines[i])[code].length < 1) {
return false;
}
var firstChar = (<any>lines[i])[code].charAt(0);
Expand Down
6 changes: 3 additions & 3 deletions src/logger/logger-typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function loadDiagnostic(context: BuildContext, tsDiagnostic: ts.Diagnostic) {
errorLength: Math.max(tsDiagnostic.length, 1)
};

if (errorLine.html.indexOf('class="hljs') === -1) {
if (errorLine.html && errorLine.html.indexOf('class="hljs') === -1) {
try {
errorLine.html = highlight(d.language, errorLine.text, true).value;
} catch (e) {}
Expand All @@ -78,7 +78,7 @@ function loadDiagnostic(context: BuildContext, tsDiagnostic: ts.Diagnostic) {
errorLength: -1
};

if (previousLine.html.indexOf('class="hljs') === -1) {
if (previousLine.html && previousLine.html.indexOf('class="hljs') === -1) {
try {
previousLine.html = highlight(d.language, previousLine.text, true).value;
} catch (e) {}
Expand All @@ -97,7 +97,7 @@ function loadDiagnostic(context: BuildContext, tsDiagnostic: ts.Diagnostic) {
errorLength: -1
};

if (nextLine.html.indexOf('class="hljs') === -1) {
if (nextLine.html && nextLine.html.indexOf('class="hljs') === -1) {
try {
nextLine.html = highlight(d.language, nextLine.text, true).value;
} catch (e) {}
Expand Down

0 comments on commit 72adc86

Please sign in to comment.