mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 16:52:25 +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,
|
||||
set caret(val) this._caret = val + this.offset,
|
||||
|
||||
get compare() this._compare || function () 0,
|
||||
set compare(val) this._compare = val,
|
||||
@@ -452,8 +453,8 @@ CompletionContext.prototype = {
|
||||
this.updateAsync = false;
|
||||
if (this.editor)
|
||||
{
|
||||
this.value = this.editor.rootElement.textContent;
|
||||
this._caret = this.editor.selection.getRangeAt(0).startOffset;
|
||||
this.value = this.editor.selection.focusNode.textContent;
|
||||
this._caret = this.editor.selection.focusOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -880,11 +881,11 @@ function Completion() //{{{
|
||||
// Constants are unsorted, and appear before other non-null strings.
|
||||
// Other strings are sorted in the default manner.
|
||||
let compare = context.compare;
|
||||
context.compare = function ({ item: { key: a } }, { item: { key: b } })
|
||||
context.compare = function (a, b)
|
||||
{
|
||||
if (!isNaN(a) && !isNaN(b))
|
||||
return a - b;
|
||||
return isNaN(b) - isNaN(a) || compare(a, b);
|
||||
if (!isNaN(a.key) && !isNaN(b.key))
|
||||
return a.key - b.key;
|
||||
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.
|
||||
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];
|
||||
plugins.contexts[name] = this;
|
||||
this.NAME = name;
|
||||
this.__context__ = this;
|
||||
}
|
||||
Script.prototype = plugins;
|
||||
|
||||
|
||||
@@ -206,8 +206,15 @@ function CommandLine() //{{{
|
||||
|
||||
if (compl)
|
||||
{
|
||||
setCommand(command.substring(0, completions.start) + compl + completionPostfix);
|
||||
commandWidget.selectionStart = commandWidget.selectionEnd = completions.start + compl.length;
|
||||
previewClear();
|
||||
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)
|
||||
liberator.triggerCallback("change", currentExtendedMode, commandline.getCommand());
|
||||
|
||||
@@ -306,18 +313,21 @@ function CommandLine() //{{{
|
||||
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
|
||||
{
|
||||
let editor = commandWidget.inputField.editor;
|
||||
let node = editor.rootElement;
|
||||
editor.deleteNode(node.firstChild.nextSibling);
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
function previewSubstring()
|
||||
{
|
||||
if (!options.get("wildoptions").has("auto") || !completionContext)
|
||||
return;
|
||||
let editor = commandWidget.inputField.editor;
|
||||
let wildmode = options.get("wildmode");
|
||||
let wildType = wildmode.values[Math.min(wildIndex, wildmode.values.length - 1)];
|
||||
if (wildmode.checkHas(wildType, "longest") && commandWidget.selectionStart == commandWidget.value.length)
|
||||
@@ -812,13 +822,7 @@ function CommandLine() //{{{
|
||||
|
||||
onEvent: function onEvent(event)
|
||||
{
|
||||
let editor = commandWidget.inputField.editor;
|
||||
try
|
||||
{
|
||||
let node = editor.rootElement;
|
||||
editor.deleteNode(node.firstChild.nextSibling);
|
||||
}
|
||||
catch (e) {}
|
||||
previewClear();
|
||||
let command = this.getCommand();
|
||||
|
||||
if (event.type == "blur")
|
||||
|
||||
Reference in New Issue
Block a user