mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 11:07:59 +01:00
Prevent async completions from resetting selected completion
This commit is contained in:
@@ -1300,7 +1300,6 @@ function Completion() //{{{
|
|||||||
cmdContext.completions = compObject.items;
|
cmdContext.completions = compObject.items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
context.updateAsync = true;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ function Hints() //{{{
|
|||||||
var pageHints = [];
|
var pageHints = [];
|
||||||
var validHints = []; // store the indices of the "hints" array with valid elements
|
var validHints = []; // store the indices of the "hints" array with valid elements
|
||||||
|
|
||||||
var escapeNumbers = false; // escape mode for numbers. true -> treated as hint-text
|
|
||||||
var activeTimeout = null; // needed for hinttimeout > 0
|
var activeTimeout = null; // needed for hinttimeout > 0
|
||||||
var canUpdate = false;
|
var canUpdate = false;
|
||||||
|
|
||||||
@@ -89,7 +88,7 @@ function Hints() //{{{
|
|||||||
validHints = [];
|
validHints = [];
|
||||||
canUpdate = false;
|
canUpdate = false;
|
||||||
docs = [];
|
docs = [];
|
||||||
escapeNumbers = false;
|
hints.escNumbers = false;
|
||||||
|
|
||||||
if (activeTimeout)
|
if (activeTimeout)
|
||||||
clearTimeout(activeTimeout);
|
clearTimeout(activeTimeout);
|
||||||
@@ -98,7 +97,7 @@ function Hints() //{{{
|
|||||||
|
|
||||||
function updateStatusline()
|
function updateStatusline()
|
||||||
{
|
{
|
||||||
statusline.updateInputBuffer((escapeNumbers ? mappings.getMapLeader() : "") + (hintNumber || ""));
|
statusline.updateInputBuffer((hints.escNumbers ? mappings.getMapLeader() : "") + (hintNumber || ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate(win)
|
function generate(win)
|
||||||
@@ -724,8 +723,8 @@ function Hints() //{{{
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case mappings.getMapLeader():
|
case mappings.getMapLeader():
|
||||||
escapeNumbers = !escapeNumbers;
|
hints.escNumbers = !hints.escNumbers;
|
||||||
if (escapeNumbers && usedTabKey) // hintNumber not used normally, but someone may wants to toggle
|
if (hints.escNumbers && usedTabKey) // hintNumber not used normally, but someone may wants to toggle
|
||||||
hintNumber = 0; // <tab>s ? reset. Prevent to show numbers not entered.
|
hintNumber = 0; // <tab>s ? reset. Prevent to show numbers not entered.
|
||||||
|
|
||||||
updateStatusline();
|
updateStatusline();
|
||||||
@@ -734,18 +733,6 @@ function Hints() //{{{
|
|||||||
default:
|
default:
|
||||||
if (/^\d$/.test(key))
|
if (/^\d$/.test(key))
|
||||||
{
|
{
|
||||||
// FIXME: Kludge.
|
|
||||||
if (escapeNumbers)
|
|
||||||
{
|
|
||||||
let cmdline = document.getElementById("liberator-commandline-command");
|
|
||||||
let start = cmdline.selectionStart;
|
|
||||||
let end = cmdline.selectionEnd;
|
|
||||||
cmdline.value = cmdline.value.substr(0, start) + key + cmdline.value.substr(start);
|
|
||||||
cmdline.selectionStart = start + 1;
|
|
||||||
cmdline.selectionEnd = end + 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
prevInput = "number";
|
prevInput = "number";
|
||||||
|
|
||||||
var oldHintNumber = hintNumber;
|
var oldHintNumber = hintNumber;
|
||||||
@@ -779,7 +766,7 @@ function Hints() //{{{
|
|||||||
// the hint after a timeout, as the user might have wanted to follow link 34
|
// the hint after a timeout, as the user might have wanted to follow link 34
|
||||||
if (hintNumber > 0 && hintNumber * 10 <= validHints.length)
|
if (hintNumber > 0 && hintNumber * 10 <= validHints.length)
|
||||||
{
|
{
|
||||||
var timeout = options["hinttimeout"];
|
let timeout = options["hinttimeout"];
|
||||||
if (timeout > 0)
|
if (timeout > 0)
|
||||||
activeTimeout = setTimeout(function () { processHints(true); }, timeout);
|
activeTimeout = setTimeout(function () { processHints(true); }, timeout);
|
||||||
|
|
||||||
|
|||||||
@@ -86,10 +86,9 @@ const modes = (function () //{{{
|
|||||||
case modes.VISUAL:
|
case modes.VISUAL:
|
||||||
if (newMode == modes.CARET)
|
if (newMode == modes.CARET)
|
||||||
{
|
{
|
||||||
// clear any selection made
|
|
||||||
var selection = window.content.getSelection();
|
|
||||||
try
|
try
|
||||||
{ // a simple if (selection) does not work
|
{ // clear any selection made; a simple if (selection) does not work
|
||||||
|
let selection = window.content.getSelection();
|
||||||
selection.collapseToStart();
|
selection.collapseToStart();
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
@@ -113,7 +112,7 @@ const modes = (function () //{{{
|
|||||||
if (newMode == modes.NORMAL)
|
if (newMode == modes.NORMAL)
|
||||||
{
|
{
|
||||||
// disable caret mode when we want to switch to normal mode
|
// disable caret mode when we want to switch to normal mode
|
||||||
var value = options.getPref("accessibility.browsewithcaret", false);
|
let value = options.getPref("accessibility.browsewithcaret", false);
|
||||||
if (value)
|
if (value)
|
||||||
options.setPref("accessibility.browsewithcaret", false);
|
options.setPref("accessibility.browsewithcaret", false);
|
||||||
|
|
||||||
@@ -124,7 +123,7 @@ const modes = (function () //{{{
|
|||||||
let urlbar = document.getElementById("urlbar");
|
let urlbar = document.getElementById("urlbar");
|
||||||
if (!urlbar || focus != urlbar.inputField)
|
if (!urlbar || focus != urlbar.inputField)
|
||||||
liberator.focusContent(false);
|
liberator.focusContent(false);
|
||||||
}, 100);
|
}, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ function CommandLine() //{{{
|
|||||||
let self = this;
|
let self = this;
|
||||||
context.onUpdate = function ()
|
context.onUpdate = function ()
|
||||||
{
|
{
|
||||||
self.reset(true);
|
self._reset();
|
||||||
};
|
};
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.editor = context.editor;
|
this.editor = context.editor;
|
||||||
@@ -165,7 +165,9 @@ function CommandLine() //{{{
|
|||||||
this.context.reset();
|
this.context.reset();
|
||||||
this.context.tabPressed = tabPressed;
|
this.context.tabPressed = tabPressed;
|
||||||
liberator.triggerCallback("complete", currentExtendedMode, this.context);
|
liberator.triggerCallback("complete", currentExtendedMode, this.context);
|
||||||
|
this.context.updateAsync = true;
|
||||||
this.reset(show, tabPressed);
|
this.reset(show, tabPressed);
|
||||||
|
this.wildIndex = 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
preview: function preview()
|
preview: function preview()
|
||||||
@@ -230,7 +232,6 @@ function CommandLine() //{{{
|
|||||||
|
|
||||||
reset: function reset(show)
|
reset: function reset(show)
|
||||||
{
|
{
|
||||||
this.wildtypes = this.wildmode.values;
|
|
||||||
this.wildIndex = -1;
|
this.wildIndex = -1;
|
||||||
|
|
||||||
this.prefix = this.context.value.substring(0, this.start);
|
this.prefix = this.context.value.substring(0, this.start);
|
||||||
@@ -244,6 +245,22 @@ function CommandLine() //{{{
|
|||||||
this.wildIndex = 0;
|
this.wildIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.wildtypes = this.wildmode.values;
|
||||||
|
this.preview();
|
||||||
|
},
|
||||||
|
|
||||||
|
_reset: function _reset()
|
||||||
|
{
|
||||||
|
this.prefix = this.context.value.substring(0, this.start);
|
||||||
|
this.value = this.context.value.substring(this.start, this.caret);
|
||||||
|
this.suffix = this.context.value.substring(this.caret);
|
||||||
|
|
||||||
|
this.itemList.reset();
|
||||||
|
this.itemList.selectItem(this.selected);
|
||||||
|
|
||||||
|
this.wildIndex = 0;
|
||||||
|
this.wildtypes = this.wildmode.values;
|
||||||
|
|
||||||
this.preview();
|
this.preview();
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -288,7 +305,7 @@ function CommandLine() //{{{
|
|||||||
{
|
{
|
||||||
// Check if we need to run the completer.
|
// Check if we need to run the completer.
|
||||||
if (this.context.waitingForTab || this.wildIndex == -1)
|
if (this.context.waitingForTab || this.wildIndex == -1)
|
||||||
this.complete(true, true);
|
this.complete(false, true);
|
||||||
|
|
||||||
if (this.items.length == 0)
|
if (this.items.length == 0)
|
||||||
{
|
{
|
||||||
@@ -350,7 +367,8 @@ function CommandLine() //{{{
|
|||||||
completions.itemList.show();
|
completions.itemList.show();
|
||||||
});
|
});
|
||||||
|
|
||||||
var tabTimer = new util.Timer(10, 10, function tabTell(event) {
|
var tabTimer = new util.Timer(0, 0, function tabTell(event) {
|
||||||
|
liberator.dump("tabTell");
|
||||||
if (completions)
|
if (completions)
|
||||||
completions.tab(event.shiftKey);
|
completions.tab(event.shiftKey);
|
||||||
});
|
});
|
||||||
@@ -1076,7 +1094,8 @@ function CommandLine() //{{{
|
|||||||
// user pressed TAB to get completions of a command
|
// user pressed TAB to get completions of a command
|
||||||
else if (key == "<Tab>" || key == "<S-Tab>")
|
else if (key == "<Tab>" || key == "<S-Tab>")
|
||||||
{
|
{
|
||||||
tabTimer.tell(event);
|
// tabTimer.tell(event);
|
||||||
|
completions.tab(event.shiftKey);
|
||||||
// prevent tab from moving to the next field
|
// prevent tab from moving to the next field
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|||||||
Reference in New Issue
Block a user