1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-04 04:24:11 +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.
*/
replace: function replace(val) {
this.input.dactylKeyPress = undefined;
if (this.completions)
this.completions.previewClear();
this.input.value = val;
this.session.onHistory(val);
editor.withSavedValues(["skipSave"], function () {
editor.skipSave = true;
this.input.dactylKeyPress = undefined;
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.
*/
setCompletion: function setCompletion(offset, value) {
this.previewClear();
editor.withSavedValues(["skipSave"], function () {
editor.skipSave = true;
this.previewClear();
if (value == null)
var [input, caret] = [this.originalValue, this.originalCaret];
else {
input = this.getCompletion(offset, value);
caret = offset + value.length;
}
if (value == null)
var [input, caret] = [this.originalValue, this.originalCaret];
else {
input = this.getCompletion(offset, value);
caret = offset + value.length;
}
// Change the completion text.
// The second line is a hack to deal with some substring
// preview corner cases.
commandline.widgets.active.command.value = input;
this.editor.selection.focusNode.textContent = input;
// Change the completion text.
// The second line is a hack to deal with some substring
// preview corner cases.
commandline.widgets.active.command.value = input;
this.editor.selection.focusNode.textContent = input;
this.caret = caret;
this._caret = this.caret;
this.caret = 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 registerRing() storage.newArray("register-ring", { privateData: true, store: true }),
skipSave: false,
// Fixme: Move off this object.
currentRegister: null,
@@ -519,15 +521,15 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
// nsIEditActionListener:
WillDeleteNode: util.wrapCallback(function WillDeleteNode(node) {
if (node.textContent)
if (!editor.skipSave && node.textContent)
this.setRegister(0, node);
}),
WillDeleteSelection: util.wrapCallback(function WillDeleteSelection(selection) {
if (!selection.isCollapsed)
if (!editor.skipSave && !selection.isCollapsed)
this.setRegister(0, selection);
}),
WillDeleteText: util.wrapCallback(function WillDeleteText(node, start, length) {
if (length)
if (!editor.skipSave && length)
this.setRegister(0, node.textContent.substr(start, length));
})
}, {