Render errors from other files correctly.

pull/1/head
chriseth 9 years ago
parent 929cbdbfd5
commit ef674daa28
  1. 33
      index.html

@ -655,7 +655,7 @@
var detailsOpen = {}; var detailsOpen = {};
function errortype(message) { function errortype(message) {
return message.match(/^[0-9:]* Warning: /) ? 'warning' : 'error'; return message.match(/^.*:[0-9]*:[0-9]* Warning: /) ? 'warning' : 'error';
} }
var renderError = function(message) { var renderError = function(message) {
@ -663,18 +663,27 @@
var $pre = $("<pre />").text(message); var $pre = $("<pre />").text(message);
var $error = $('<div class="sol ' + type + '"><div class="close"><i class="fa fa-close"></i></div></div>').prepend($pre); var $error = $('<div class="sol ' + type + '"><div class="close"><i class="fa fa-close"></i></div></div>').prepend($pre);
$('#output').append( $error ); $('#output').append( $error );
var err = message.match(/^:([0-9]*):([0-9]*)/); var err = message.match(/^([^:]*):([0-9]*):(([0-9]*):)? /);
if (err && err.length) { if (err) {
var errLine = parseInt(err[1], 10) - 1; var errFile = err[1];
var errCol = err[2] ? parseInt(err[2], 10) : 0; var errLine = parseInt(err[2], 10) - 1;
sourceAnnotations[sourceAnnotations.length] = { var errCol = err[4] ? parseInt(err[4], 10) : 0;
row: errLine, if (errFile == '' || errFile == fileNameFromKey(SOL_CACHE_FILE)) {
column: errCol, sourceAnnotations[sourceAnnotations.length] = {
text: message, row: errLine,
type: type column: errCol,
}; text: message,
editor.getSession().setAnnotations(sourceAnnotations); type: type
};
editor.getSession().setAnnotations(sourceAnnotations);
}
$error.click(function(ev){ $error.click(function(ev){
if (errFile != '' && errFile != fileNameFromKey(SOL_CACHE_FILE) && getFiles().indexOf(fileKey(errFile)) !== -1) {
// Switch to file
SOL_CACHE_FILE = fileKey(errFile);
updateFiles();
//@TODO could show some error icon in files with errors
}
editor.focus(); editor.focus();
editor.gotoLine(errLine + 1, errCol - 1, true); editor.gotoLine(errLine + 1, errCol - 1, true);
}); });

Loading…
Cancel
Save