1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 11:18:00 +01:00

Fix using :command from the command line. Closes issue #67.

This commit is contained in:
Kris Maglione
2010-10-12 13:41:01 -04:00
parent 6907ae130e
commit 2e3f47b19e
4 changed files with 10 additions and 8 deletions

View File

@@ -426,6 +426,7 @@ const Commands = Module("commands", {
*/ */
execute: function (string, tokens, silent, args, sourcing) { execute: function (string, tokens, silent, args, sourcing) {
io.withSavedValues(["readHeredoc", "sourcing"], function () { io.withSavedValues(["readHeredoc", "sourcing"], function () {
sourcing = sourcing || { file: "[Command Line]", line: 1 };
this.sourcing = update({}, sourcing); this.sourcing = update({}, sourcing);
args = update({ setFrom: this.sourcing.file }, args || {}); args = update({ setFrom: this.sourcing.file }, args || {});
@@ -460,9 +461,13 @@ const Commands = Module("commands", {
dactyl.execute(line, args); dactyl.execute(line, args);
} }
catch (e) { catch (e) {
if (!silent) { if (!silent || silent === "loud") {
dactyl.echoerr("Error detected while processing " + this.sourcing.file); if (silent !== "loud")
dactyl.echomsg("line\t" + this.sourcing.line + ":"); e.message = this.sourcing.file + ":" + this.sourcing.line + ": " + e.message;
else {
dactyl.echoerr("Error detected while processing " + this.sourcing.file);
dactyl.echomsg("line\t" + this.sourcing.line + ":");
}
dactyl.reportError(e, true); dactyl.reportError(e, true);
} }
} }

View File

@@ -2013,7 +2013,7 @@ const Dactyl = Module("dactyl", {
if (options["exrc"] && !dactyl.commandLineOptions.rcFile) { if (options["exrc"] && !dactyl.commandLineOptions.rcFile) {
let localRCFile = io.getRCFile(io.cwd); let localRCFile = io.getRCFile(io.cwd);
if (localRCFile && !localRCFile.equals(rcFile)) if (localRCFile && !localRCFile.equals(rcFile))
io.source(localRCFile.path, true); io.source(localRCFile.path, false);
} }
} }

View File

@@ -741,8 +741,6 @@ const Events = Module("events", {
function isEscape(key) key == "<Esc>" || key == "<C-[>"; function isEscape(key) key == "<Esc>" || key == "<C-[>";
function killEvent() { function killEvent() {
if (/key|input/.test(event.type))
util.dumpStack();
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
} }
@@ -871,7 +869,6 @@ const Events = Module("events", {
// only follow a map if there isn't a longer possible mapping // only follow a map if there isn't a longer possible mapping
// (allows you to do :map z yy, when zz is a longer mapping than z) // (allows you to do :map z yy, when zz is a longer mapping than z)
else if (map && !event.skipmap && candidates.length == 0) { else if (map && !event.skipmap && candidates.length == 0) {
util.dump(map, this._input);
this._input.pendingMap = null; this._input.pendingMap = null;
this._input.count = parseInt(countStr, 10); this._input.count = parseInt(countStr, 10);
if (isNaN(this._input.count)) if (isNaN(this._input.count))

View File

@@ -353,7 +353,7 @@ lookup:
else if (/\.css$/.test(filename)) else if (/\.css$/.test(filename))
storage.styles.registerSheet(uri.spec, false, true); storage.styles.registerSheet(uri.spec, false, true);
else { else {
commands.execute(file.read(), null, silent, null, commands.execute(file.read(), null, silent || "loud", null,
{ file: file.path, line: 1 }); { file: file.path, line: 1 });
} }