1
0
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:
Kris Maglione
2008-12-05 06:20:42 -05:00
parent 84e84c81fd
commit 809da07b11
4 changed files with 33 additions and 29 deletions

View File

@@ -1300,7 +1300,6 @@ function Completion() //{{{
cmdContext.completions = compObject.items;
}
}
context.updateAsync = true;
}
},

View File

@@ -47,7 +47,6 @@ function Hints() //{{{
var pageHints = [];
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 canUpdate = false;
@@ -89,7 +88,7 @@ function Hints() //{{{
validHints = [];
canUpdate = false;
docs = [];
escapeNumbers = false;
hints.escNumbers = false;
if (activeTimeout)
clearTimeout(activeTimeout);
@@ -98,7 +97,7 @@ function Hints() //{{{
function updateStatusline()
{
statusline.updateInputBuffer((escapeNumbers ? mappings.getMapLeader() : "") + (hintNumber || ""));
statusline.updateInputBuffer((hints.escNumbers ? mappings.getMapLeader() : "") + (hintNumber || ""));
}
function generate(win)
@@ -724,8 +723,8 @@ function Hints() //{{{
break;
case mappings.getMapLeader():
escapeNumbers = !escapeNumbers;
if (escapeNumbers && usedTabKey) // hintNumber not used normally, but someone may wants to toggle
hints.escNumbers = !hints.escNumbers;
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.
updateStatusline();
@@ -734,18 +733,6 @@ function Hints() //{{{
default:
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";
var oldHintNumber = hintNumber;
@@ -779,7 +766,7 @@ function Hints() //{{{
// the hint after a timeout, as the user might have wanted to follow link 34
if (hintNumber > 0 && hintNumber * 10 <= validHints.length)
{
var timeout = options["hinttimeout"];
let timeout = options["hinttimeout"];
if (timeout > 0)
activeTimeout = setTimeout(function () { processHints(true); }, timeout);

View File

@@ -86,10 +86,9 @@ const modes = (function () //{{{
case modes.VISUAL:
if (newMode == modes.CARET)
{
// clear any selection made
var selection = window.content.getSelection();
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();
}
catch (e) {}
@@ -113,7 +112,7 @@ const modes = (function () //{{{
if (newMode == modes.NORMAL)
{
// 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)
options.setPref("accessibility.browsewithcaret", false);
@@ -124,7 +123,7 @@ const modes = (function () //{{{
let urlbar = document.getElementById("urlbar");
if (!urlbar || focus != urlbar.inputField)
liberator.focusContent(false);
}, 100);
}, 0);
}
}

View File

@@ -102,7 +102,7 @@ function CommandLine() //{{{
let self = this;
context.onUpdate = function ()
{
self.reset(true);
self._reset();
};
this.context = context;
this.editor = context.editor;
@@ -165,7 +165,9 @@ function CommandLine() //{{{
this.context.reset();
this.context.tabPressed = tabPressed;
liberator.triggerCallback("complete", currentExtendedMode, this.context);
this.context.updateAsync = true;
this.reset(show, tabPressed);
this.wildIndex = 0;
},
preview: function preview()
@@ -230,7 +232,6 @@ function CommandLine() //{{{
reset: function reset(show)
{
this.wildtypes = this.wildmode.values;
this.wildIndex = -1;
this.prefix = this.context.value.substring(0, this.start);
@@ -244,6 +245,22 @@ function CommandLine() //{{{
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();
},
@@ -288,7 +305,7 @@ function CommandLine() //{{{
{
// Check if we need to run the completer.
if (this.context.waitingForTab || this.wildIndex == -1)
this.complete(true, true);
this.complete(false, true);
if (this.items.length == 0)
{
@@ -350,7 +367,8 @@ function CommandLine() //{{{
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)
completions.tab(event.shiftKey);
});
@@ -1076,7 +1094,8 @@ function CommandLine() //{{{
// user pressed TAB to get completions of a command
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
event.preventDefault();
event.stopPropagation();