mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-25 16:05:47 +01:00
Add CompletionContextcompletion.jscancelAll
This commit is contained in:
@@ -117,7 +117,7 @@ function CompletionContext(editor, name, offset) //{{{
|
|||||||
* a completion window with Esc or Ctrl-c. Usually this callback
|
* a completion window with Esc or Ctrl-c. Usually this callback
|
||||||
* is only needed for long, asynchronous completions
|
* is only needed for long, asynchronous completions
|
||||||
*/
|
*/
|
||||||
this.cancelFunc = null;
|
this.cancel = null;
|
||||||
/**
|
/**
|
||||||
* @property {function} The function used to filter the results.
|
* @property {function} The function used to filter the results.
|
||||||
* @default Selects all results which match every predicate in the
|
* @default Selects all results which match every predicate in the
|
||||||
@@ -526,6 +526,15 @@ CompletionContext.prototype = {
|
|||||||
this._filter = this._filter.substr(count);
|
this._filter = this._filter.substr(count);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cancelAll: function ()
|
||||||
|
{
|
||||||
|
for (let [,context] in Iterator(this.contextList))
|
||||||
|
{
|
||||||
|
if (context.cancel)
|
||||||
|
context.cancel();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a key from {@link #cache}, setting it to <b>defVal</b> if it
|
* Gets a key from {@link #cache}, setting it to <b>defVal</b> if it
|
||||||
* doesn't already exists.
|
* doesn't already exists.
|
||||||
@@ -629,6 +638,8 @@ CompletionContext.prototype = {
|
|||||||
for (let type in this.selectionTypes)
|
for (let type in this.selectionTypes)
|
||||||
this.highlight(0, 0, type);
|
this.highlight(0, 0, type);
|
||||||
|
|
||||||
|
this.cancelAll();
|
||||||
|
|
||||||
this.contextList = [];
|
this.contextList = [];
|
||||||
this.offset = 0;
|
this.offset = 0;
|
||||||
this.process = [];
|
this.process = [];
|
||||||
@@ -1563,7 +1574,7 @@ function Completion() //{{{
|
|||||||
context.incomplete = true;
|
context.incomplete = true;
|
||||||
context.hasItems = context.completions.length > 0; // XXX
|
context.hasItems = context.completions.length > 0; // XXX
|
||||||
context.filterFunc = null;
|
context.filterFunc = null;
|
||||||
context.cancelFunc = function () services.get("autoCompleteSearch").stopSearch();
|
context.cancel = function () services.get("autoCompleteSearch").stopSearch();
|
||||||
context.compare = null;
|
context.compare = null;
|
||||||
let timer = new Timer(50, 100, function (result) {
|
let timer = new Timer(50, 100, function (result) {
|
||||||
context.incomplete = result.searchResult >= result.RESULT_NOMATCH_ONGOING;
|
context.incomplete = result.searchResult >= result.RESULT_NOMATCH_ONGOING;
|
||||||
|
|||||||
@@ -1438,10 +1438,7 @@ function CommandLine() //{{{
|
|||||||
// liberator.dump("Resetting completions...");
|
// liberator.dump("Resetting completions...");
|
||||||
if (completions)
|
if (completions)
|
||||||
{
|
{
|
||||||
// if any child context has a cancelFunc, call it
|
completions.context.cancelAll();
|
||||||
for (let [, context] in Iterator(completions.context.top.contexts))
|
|
||||||
if (context.cancelFunc)
|
|
||||||
context.cancelFunc();
|
|
||||||
|
|
||||||
completions.wildIndex = -1;
|
completions.wildIndex = -1;
|
||||||
completions.previewClear();
|
completions.previewClear();
|
||||||
|
|||||||
Reference in New Issue
Block a user