1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-22 21:53:31 +01:00

Don't save history and completion changes in kill ring.

This commit is contained in:
Kris Maglione
2011-10-07 02:03:16 -04:00
parent bf4a5940d9
commit 7028b8b84e
2 changed files with 32 additions and 23 deletions

View File

@@ -966,11 +966,15 @@ var CommandLine = Module("commandline", {
* @param {string} val The new value. * @param {string} val The new value.
*/ */
replace: function replace(val) { replace: function replace(val) {
this.input.dactylKeyPress = undefined; editor.withSavedValues(["skipSave"], function () {
if (this.completions) editor.skipSave = true;
this.completions.previewClear();
this.input.value = val; this.input.dactylKeyPress = undefined;
this.session.onHistory(val); if (this.completions)
this.completions.previewClear();
this.input.value = val;
this.session.onHistory(val);
}, this);
}, },
/** /**
@@ -1116,25 +1120,28 @@ var CommandLine = Module("commandline", {
* @param {string} value The value to insert. * @param {string} value The value to insert.
*/ */
setCompletion: function setCompletion(offset, value) { setCompletion: function setCompletion(offset, value) {
this.previewClear(); editor.withSavedValues(["skipSave"], function () {
editor.skipSave = true;
this.previewClear();
if (value == null) if (value == null)
var [input, caret] = [this.originalValue, this.originalCaret]; var [input, caret] = [this.originalValue, this.originalCaret];
else { else {
input = this.getCompletion(offset, value); input = this.getCompletion(offset, value);
caret = offset + value.length; caret = offset + value.length;
} }
// Change the completion text. // Change the completion text.
// The second line is a hack to deal with some substring // The second line is a hack to deal with some substring
// preview corner cases. // preview corner cases.
commandline.widgets.active.command.value = input; commandline.widgets.active.command.value = input;
this.editor.selection.focusNode.textContent = input; this.editor.selection.focusNode.textContent = input;
this.caret = caret; this.caret = caret;
this._caret = this.caret; this._caret = this.caret;
this.input.dactylKeyPress = undefined; this.input.dactylKeyPress = undefined;
}, this);
}, },
/** /**

View File

@@ -45,6 +45,8 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
get registers() storage.newMap("registers", { privateData: true, store: true }), get registers() storage.newMap("registers", { privateData: true, store: true }),
get registerRing() storage.newArray("register-ring", { privateData: true, store: true }), get registerRing() storage.newArray("register-ring", { privateData: true, store: true }),
skipSave: false,
// Fixme: Move off this object. // Fixme: Move off this object.
currentRegister: null, currentRegister: null,
@@ -519,15 +521,15 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
// nsIEditActionListener: // nsIEditActionListener:
WillDeleteNode: util.wrapCallback(function WillDeleteNode(node) { WillDeleteNode: util.wrapCallback(function WillDeleteNode(node) {
if (node.textContent) if (!editor.skipSave && node.textContent)
this.setRegister(0, node); this.setRegister(0, node);
}), }),
WillDeleteSelection: util.wrapCallback(function WillDeleteSelection(selection) { WillDeleteSelection: util.wrapCallback(function WillDeleteSelection(selection) {
if (!selection.isCollapsed) if (!editor.skipSave && !selection.isCollapsed)
this.setRegister(0, selection); this.setRegister(0, selection);
}), }),
WillDeleteText: util.wrapCallback(function WillDeleteText(node, start, length) { WillDeleteText: util.wrapCallback(function WillDeleteText(node, start, length) {
if (length) if (!editor.skipSave && length)
this.setRegister(0, node.textContent.substr(start, length)); this.setRegister(0, node.textContent.substr(start, length));
}) })
}, { }, {