mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 06:58:00 +01:00
Fix a race.
--HG-- branch : groups
This commit is contained in:
@@ -36,6 +36,8 @@ var Editor = Module("editor", {
|
|||||||
let text = dactyl.clipboardRead(clipboard);
|
let text = dactyl.clipboardRead(clipboard);
|
||||||
if (!text)
|
if (!text)
|
||||||
return;
|
return;
|
||||||
|
if (isinstance(elem, [HTMLInputElement, XULTextBoxElement]))
|
||||||
|
text = text.replace(/\n+/g, "");
|
||||||
|
|
||||||
// This is a hacky fix - but it works.
|
// This is a hacky fix - but it works.
|
||||||
// <s-insert> in the bottom of a long textarea bounces up
|
// <s-insert> in the bottom of a long textarea bounces up
|
||||||
@@ -46,7 +48,9 @@ var Editor = Module("editor", {
|
|||||||
let end = elem.selectionEnd;
|
let end = elem.selectionEnd;
|
||||||
let value = elem.value.substring(0, start) + text + elem.value.substring(end);
|
let value = elem.value.substring(0, start) + text + elem.value.substring(end);
|
||||||
elem.value = value;
|
elem.value = value;
|
||||||
|
|
||||||
Editor.getEditor(elem).rootElement.firstChild.textContent = value;
|
Editor.getEditor(elem).rootElement.firstChild.textContent = value;
|
||||||
|
|
||||||
elem.selectionStart = Math.min(start + (toStart ? 0 : text.length), elem.value.length);
|
elem.selectionStart = Math.min(start + (toStart ? 0 : text.length), elem.value.length);
|
||||||
elem.selectionEnd = elem.selectionStart;
|
elem.selectionEnd = elem.selectionStart;
|
||||||
|
|
||||||
|
|||||||
@@ -245,6 +245,8 @@ var Modes = Module("modes", {
|
|||||||
|
|
||||||
getCharModes: function (chr) (this.modeChars[chr] || []).slice(),
|
getCharModes: function (chr) (this.modeChars[chr] || []).slice(),
|
||||||
|
|
||||||
|
have: function have(mode) this._modeStack.some(function (m) isinstance(m.main, mode)),
|
||||||
|
|
||||||
matchModes: function (obj)
|
matchModes: function (obj)
|
||||||
this._modes.filter(function (mode) Object.keys(obj)
|
this._modes.filter(function (mode) Object.keys(obj)
|
||||||
.every(function (k) obj[k] == (mode[k] || false))),
|
.every(function (k) obj[k] == (mode[k] || false))),
|
||||||
@@ -397,7 +399,7 @@ var Modes = Module("modes", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
isinstance: function (obj)
|
isinstance: function (obj)
|
||||||
this.allBases.indexOf(obj) >= 0 || callable(obj) && this instanceof obj,
|
this === obj || this.allBases.indexOf(obj) >= 0 || callable(obj) && this instanceof obj,
|
||||||
|
|
||||||
allBases: Class.memoize(function () {
|
allBases: Class.memoize(function () {
|
||||||
let seen = {}, res = [], queue = this.bases;
|
let seen = {}, res = [], queue = this.bases;
|
||||||
|
|||||||
@@ -10,13 +10,15 @@ var MOW = Module("mow", {
|
|||||||
init: function () {
|
init: function () {
|
||||||
|
|
||||||
this._resize = Timer(20, 400, function () {
|
this._resize = Timer(20, 400, function () {
|
||||||
if (this.visible) {
|
if (this.visible)
|
||||||
this.resize(false);
|
this.resize(false);
|
||||||
|
|
||||||
|
if (this.visible && isinstance(modes.main, modes.OUTPUT_MULTILINE))
|
||||||
this.updateMorePrompt();
|
this.updateMorePrompt();
|
||||||
}
|
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
this._timer = Timer(20, 400, function () {
|
this._timer = Timer(20, 400, function () {
|
||||||
|
if (modes.have(modes.OUTPUT_MULTILINE)) {
|
||||||
this.resize(true);
|
this.resize(true);
|
||||||
|
|
||||||
if (options["more"] && this.isScrollable(1)) {
|
if (options["more"] && this.isScrollable(1)) {
|
||||||
@@ -29,6 +31,7 @@ var MOW = Module("mow", {
|
|||||||
|
|
||||||
dactyl.focus(this.window);
|
dactyl.focus(this.window);
|
||||||
this.updateMorePrompt();
|
this.updateMorePrompt();
|
||||||
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
events.listen(window, this, "windowEvents");
|
events.listen(window, this, "windowEvents");
|
||||||
|
|||||||
@@ -440,25 +440,24 @@ function isinstance(object, interfaces) {
|
|||||||
if (object == null)
|
if (object == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
interfaces = Array.concat(interfaces);
|
return Array.concat(interfaces).some(function isinstance_some(iface) {
|
||||||
for (var i = 0; i < interfaces.length; i++) {
|
if (typeof iface === "string") {
|
||||||
if (typeof interfaces[i] === "string") {
|
if (objproto.toString.call(object) === "[object " + iface + "]")
|
||||||
if (objproto.toString.call(object) === "[object " + interfaces[i] + "]")
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (typeof object === "object" && "isinstance" in object && object.isinstance !== isinstance) {
|
else if (typeof object === "object" && "isinstance" in object && object.isinstance !== isinstance) {
|
||||||
if (object.isinstance(interfaces[i]))
|
if (object.isinstance(iface))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (object instanceof interfaces[i])
|
if (object instanceof iface)
|
||||||
return true;
|
return true;
|
||||||
var type = isinstance_types[typeof object];
|
var type = isinstance_types[typeof object];
|
||||||
if (type && isSubclass(interfaces[i], type))
|
if (type && isSubclass(iface, type))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user