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

Commit 9853b4c

Browse files
author
Sergio Benitez
committed
Warning output would remove user's print statements - this has been fixed.
1 parent a078835 commit 9853b4c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

js/editor.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ function runProgram(program, callback) {
9696

9797
// The callback to runProgram
9898
function handleResult(statusCode, message) {
99-
var message = message.replace(/<anon>/g, '');
10099
var message = message.replace(/(?:\r\n|\r|\n)/g, '<br />');
101100

102101
// Dispatch depending on result type
@@ -139,11 +138,15 @@ function handleProblem(message, problem) {
139138

140139
// Cleaning up the message: keeps only relevant problem output
141140
var cleanMessage = lines.map(function(line) {
142-
var errIndex = line.indexOf(problem + ": ");
143-
if (errIndex !== -1) {
144-
return line.slice(errIndex);
141+
if (line.startsWith("<anon>") || line.indexOf("^") !== -1) {
142+
var errIndex = line.indexOf(problem + ": ");
143+
if (errIndex !== -1) return line.slice(errIndex);
144+
return "";
145145
}
146-
return "";
146+
147+
// Discard playpen messages, keep the rest
148+
if (line.startsWith("playpen:")) return "";
149+
return line;
147150
}).filter(function(line) {
148151
return line !== "";
149152
}).join("<br />");
@@ -171,7 +174,7 @@ function parseProblems(lines) {
171174
var ranges = [];
172175
for (var i in lines) {
173176
var line = lines[i];
174-
if (line.startsWith(":") && line.indexOf(": ") !== -1) {
177+
if (line.startsWith("<anon>:") && line.indexOf(": ") !== -1) {
175178
var parts = line.split(/:\s?|\s+/, 5).slice(1, 5);
176179
var ip = parts.map(function(p) { return parseInt(p, 10) - 1; });
177180
// console.log("line:", line, parts, ip);

0 commit comments

Comments
 (0)