mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 19:32:27 +01:00
Fix <fast-typing><Tab> problems caused by substring preview.
This commit is contained in:
@@ -158,6 +158,7 @@ CompletionContext.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
get caret() this._caret - this.offset,
|
get caret() this._caret - this.offset,
|
||||||
|
set caret(val) this._caret = val + this.offset,
|
||||||
|
|
||||||
get compare() this._compare || function () 0,
|
get compare() this._compare || function () 0,
|
||||||
set compare(val) this._compare = val,
|
set compare(val) this._compare = val,
|
||||||
@@ -452,8 +453,8 @@ CompletionContext.prototype = {
|
|||||||
this.updateAsync = false;
|
this.updateAsync = false;
|
||||||
if (this.editor)
|
if (this.editor)
|
||||||
{
|
{
|
||||||
this.value = this.editor.rootElement.textContent;
|
this.value = this.editor.selection.focusNode.textContent;
|
||||||
this._caret = this.editor.selection.getRangeAt(0).startOffset;
|
this._caret = this.editor.selection.focusOffset;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -880,11 +881,11 @@ function Completion() //{{{
|
|||||||
// Constants are unsorted, and appear before other non-null strings.
|
// Constants are unsorted, and appear before other non-null strings.
|
||||||
// Other strings are sorted in the default manner.
|
// Other strings are sorted in the default manner.
|
||||||
let compare = context.compare;
|
let compare = context.compare;
|
||||||
context.compare = function ({ item: { key: a } }, { item: { key: b } })
|
context.compare = function (a, b)
|
||||||
{
|
{
|
||||||
if (!isNaN(a) && !isNaN(b))
|
if (!isNaN(a.key) && !isNaN(b.key))
|
||||||
return a - b;
|
return a.key - b.key;
|
||||||
return isNaN(b) - isNaN(a) || compare(a, b);
|
return isNaN(b.key) - isNaN(a.key) || compare(a, b);
|
||||||
}
|
}
|
||||||
if (!context.anchored) // We've already listed anchored matches, so don't list them again here.
|
if (!context.anchored) // We've already listed anchored matches, so don't list them again here.
|
||||||
context.filters.push(function (item) util.compareIgnoreCase(item.text.substr(0, this.filter.length), this.filter));
|
context.filters.push(function (item) util.compareIgnoreCase(item.text.substr(0, this.filter.length), this.filter));
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ function Script(name)
|
|||||||
return plugins.contexts[name];
|
return plugins.contexts[name];
|
||||||
plugins.contexts[name] = this;
|
plugins.contexts[name] = this;
|
||||||
this.NAME = name;
|
this.NAME = name;
|
||||||
|
this.__context__ = this;
|
||||||
}
|
}
|
||||||
Script.prototype = plugins;
|
Script.prototype = plugins;
|
||||||
|
|
||||||
|
|||||||
@@ -206,8 +206,15 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
if (compl)
|
if (compl)
|
||||||
{
|
{
|
||||||
setCommand(command.substring(0, completions.start) + compl + completionPostfix);
|
previewClear();
|
||||||
commandWidget.selectionStart = commandWidget.selectionEnd = completions.start + compl.length;
|
let editor = commandWidget.inputField.editor;
|
||||||
|
|
||||||
|
editor.selection.focusNode.textContent = command.substring(0, completions.start) + compl + completionPostfix;
|
||||||
|
|
||||||
|
let range = editor.selection.getRangeAt(0);
|
||||||
|
range.setStart(range.startContainer, completions.start + compl.length);
|
||||||
|
range.collapse(true);
|
||||||
|
|
||||||
if (longest)
|
if (longest)
|
||||||
liberator.triggerCallback("change", currentExtendedMode, commandline.getCommand());
|
liberator.triggerCallback("change", currentExtendedMode, commandline.getCommand());
|
||||||
|
|
||||||
@@ -306,18 +313,21 @@ function CommandLine() //{{{
|
|||||||
promptWidget.setAttributeNS(NS.uri, "highlight", highlightGroup || commandline.HL_NORMAL);
|
promptWidget.setAttributeNS(NS.uri, "highlight", highlightGroup || commandline.HL_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
function previewSubstring()
|
function previewClear()
|
||||||
{
|
{
|
||||||
if (!options.get("wildoptions").has("auto") || !completionContext)
|
|
||||||
return;
|
|
||||||
// Kludge. Major kludge.
|
|
||||||
let editor = commandWidget.inputField.editor;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
let editor = commandWidget.inputField.editor;
|
||||||
let node = editor.rootElement;
|
let node = editor.rootElement;
|
||||||
editor.deleteNode(node.firstChild.nextSibling);
|
editor.deleteNode(node.firstChild.nextSibling);
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
|
}
|
||||||
|
function previewSubstring()
|
||||||
|
{
|
||||||
|
if (!options.get("wildoptions").has("auto") || !completionContext)
|
||||||
|
return;
|
||||||
|
let editor = commandWidget.inputField.editor;
|
||||||
let wildmode = options.get("wildmode");
|
let wildmode = options.get("wildmode");
|
||||||
let wildType = wildmode.values[Math.min(wildIndex, wildmode.values.length - 1)];
|
let wildType = wildmode.values[Math.min(wildIndex, wildmode.values.length - 1)];
|
||||||
if (wildmode.checkHas(wildType, "longest") && commandWidget.selectionStart == commandWidget.value.length)
|
if (wildmode.checkHas(wildType, "longest") && commandWidget.selectionStart == commandWidget.value.length)
|
||||||
@@ -812,13 +822,7 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
onEvent: function onEvent(event)
|
onEvent: function onEvent(event)
|
||||||
{
|
{
|
||||||
let editor = commandWidget.inputField.editor;
|
previewClear();
|
||||||
try
|
|
||||||
{
|
|
||||||
let node = editor.rootElement;
|
|
||||||
editor.deleteNode(node.firstChild.nextSibling);
|
|
||||||
}
|
|
||||||
catch (e) {}
|
|
||||||
let command = this.getCommand();
|
let command = this.getCommand();
|
||||||
|
|
||||||
if (event.type == "blur")
|
if (event.type == "blur")
|
||||||
|
|||||||
Reference in New Issue
Block a user