mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 11:58:00 +01:00
improve error messages given when sourcing files
This commit is contained in:
@@ -777,7 +777,7 @@ lookup:
|
|||||||
|
|
||||||
liberator.echomsg("sourcing \"" + filename + "\"", 2);
|
liberator.echomsg("sourcing \"" + filename + "\"", 2);
|
||||||
|
|
||||||
var str = ioManager.readFile(file);
|
let str = ioManager.readFile(file);
|
||||||
|
|
||||||
// handle pure javascript files specially
|
// handle pure javascript files specially
|
||||||
if (/\.js$/.test(filename))
|
if (/\.js$/.test(filename))
|
||||||
@@ -786,14 +786,12 @@ lookup:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var heredoc = "";
|
let heredoc = "";
|
||||||
var heredocEnd = null; // the string which ends the heredoc
|
let heredocEnd = null; // the string which ends the heredoc
|
||||||
var lines = str.split("\n");
|
let lines = str.split("\n");
|
||||||
|
|
||||||
for (let i = 0; i < lines.length; i++)
|
for (let [i, line] in Iterator(lines))
|
||||||
{
|
{
|
||||||
let line = lines[i];
|
|
||||||
|
|
||||||
if (heredocEnd) // we already are in a heredoc
|
if (heredocEnd) // we already are in a heredoc
|
||||||
{
|
{
|
||||||
if (heredocEnd.test(line))
|
if (heredocEnd.test(line))
|
||||||
@@ -809,33 +807,53 @@ lookup:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var [count, cmd, special, args] = liberator.commands.parseCommand(line);
|
// skip line comments and blank lines
|
||||||
var command = liberator.commands.get(cmd);
|
if (/^\s*(".*)?$/.test(line))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (command && command.name == "finish")
|
let [count, cmd, special, args] = liberator.commands.parseCommand(line);
|
||||||
{
|
let command = liberator.commands.get(cmd);
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (command && command.name == "javascript")
|
|
||||||
{
|
|
||||||
// check for a heredoc
|
|
||||||
var matches = args.match(/(.*)<<\s*([^\s]+)$/);
|
|
||||||
|
|
||||||
if (matches)
|
if (!command)
|
||||||
{
|
{
|
||||||
heredocEnd = new RegExp("^" + matches[2] + "$", "m");
|
let lineNumber = i + 1;
|
||||||
if (matches[1])
|
|
||||||
heredoc = matches[1] + "\n";
|
// FIXME: messages need to be able to specify
|
||||||
}
|
// whether they can be cleared/overwritten or
|
||||||
else
|
// should be appended to and the MOW opened
|
||||||
{
|
liberator.echoerr("Error detected while processing " + file.path,
|
||||||
command.execute(args, special, count);
|
liberator.commandline.FORCE_MULTILINE);
|
||||||
}
|
liberator.commandline.echo("line " + lineNumber + ":", liberator.commandline.HL_LINENR,
|
||||||
|
liberator.commandline.APPEND_TO_MESSAGES);
|
||||||
|
liberator.echoerr("E492: Not an editor command: " + line);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// execute a normal liberator command
|
if (command.name == "finish")
|
||||||
liberator.execute(line);
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (command.name == "javascript")
|
||||||
|
{
|
||||||
|
// check for a heredoc
|
||||||
|
let matches = args.match(/(.*)<<\s*([^\s]+)$/);
|
||||||
|
|
||||||
|
if (matches)
|
||||||
|
{
|
||||||
|
heredocEnd = new RegExp("^" + matches[2] + "$", "m");
|
||||||
|
if (matches[1])
|
||||||
|
heredoc = matches[1] + "\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
command.execute(args, special, count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// execute a normal liberator command
|
||||||
|
liberator.execute(line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -854,7 +872,7 @@ lookup:
|
|||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
var message = "Sourcing file: " + file.path + ": " + e;
|
let message = "Sourcing file: " + file.path + ": " + e;
|
||||||
Components.utils.reportError(message);
|
Components.utils.reportError(message);
|
||||||
if (!silent)
|
if (!silent)
|
||||||
liberator.echoerr(message);
|
liberator.echoerr(message);
|
||||||
|
|||||||
@@ -529,6 +529,7 @@ liberator.CommandLine = function () //{{{
|
|||||||
HL_QUESTION : "hl-Question",
|
HL_QUESTION : "hl-Question",
|
||||||
HL_INFOMSG : "hl-InfoMsg",
|
HL_INFOMSG : "hl-InfoMsg",
|
||||||
HL_WARNINGMSG : "hl-WarningMsg",
|
HL_WARNINGMSG : "hl-WarningMsg",
|
||||||
|
HL_LINENR : "hl-LineNr",
|
||||||
|
|
||||||
// not yet used
|
// not yet used
|
||||||
FORCE_MULTILINE : 1 << 0,
|
FORCE_MULTILINE : 1 << 0,
|
||||||
|
|||||||
@@ -127,6 +127,10 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
background-color: white;
|
background-color: white;
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
.hl-LineNr {
|
||||||
|
background-color: white;
|
||||||
|
color: orange;
|
||||||
|
}
|
||||||
.hl-MoreMsg {
|
.hl-MoreMsg {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
color: green;
|
color: green;
|
||||||
|
|||||||
Reference in New Issue
Block a user