1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-05 08:14:11 +01:00

Prompt before running :sanitize all.

--HG--
extra : rebase_source : 7a66e541ba326e72416bff85085003f97d607454
This commit is contained in:
Doug Kearns
2011-06-27 14:51:59 +10:00
parent e4c388ff9b
commit 495dd8d9d9
2 changed files with 30 additions and 12 deletions

View File

@@ -93,6 +93,8 @@ command.let.undefinedVar-1 = E121: Undefined variable: %S
command.let.unexpectedChar = E18: Unexpected characters in :let
command.run.noPrevious = E34: No previous command
command.sanitize.privateMode = Cannot sanitize items in private mode
command.sanitize.allDeleted = All items sanitized
command.sanitize.noneDeleted = No items sanitized
command.scriptnames.none = No sourced scripts found
command.set.errorParsing-1 = Error parsing :set command: %S
command.set.numberRequired-2 = E521: Number required after =: %S=%S
@@ -274,6 +276,8 @@ quickmark.notSet = QuickMark not set
quickmark.invalid = Argument must be an ASCII letter or digit
quickmark.added-2 = Added Quick Mark '%S': %S
sanitize.prompt.deleteAll = This will sanitize all items. Would you like to continue? (yes/[no]):
save.invalidDestination-1 = Invalid destination: %S
sort.ascending = ascending

View File

@@ -427,20 +427,34 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
else
dactyl.assert(modules.options.get("sanitizeitems").validator(items), _("error.invalidArgument"));
if (items.indexOf("all") >= 0)
items = Object.keys(sanitizer.itemMap).filter(function (k) items.indexOf(k) === -1);
sanitizer.range = range.native;
sanitizer.ignoreTimespan = range.min == null;
sanitizer.sanitizing = true;
if (args["-host"]) {
args["-host"].forEach(function (host) {
sanitizer.sanitizing = true;
sanitizer.sanitizeItems(items, range, host);
});
function sanitize(items) {
sanitizer.range = range.native;
sanitizer.ignoreTimespan = range.min == null;
sanitizer.sanitizing = true;
if (args["-host"]) {
args["-host"].forEach(function (host) {
sanitizer.sanitizing = true;
sanitizer.sanitizeItems(items, range, host);
});
}
else
sanitizer.sanitize(items, range);
}
if (items.indexOf("all") >= 0)
modules.commandline.input(_("sanitize.prompt.deleteAll") + " ",
function (resp) {
if (resp.match(/^y(es)?$/i)) {
items = Object.keys(sanitizer.itemMap).filter(function (k) items.indexOf(k) === -1);
sanitize(items);
dactyl.echo(_("command.sanitize.allDeleted"));
}
else
dactyl.echo(_("command.sanitize.noneDeleted"));
});
else
sanitizer.sanitize(items, range);
sanitize(items);
},
{
argCount: "*", // FIXME: should be + and 0