Mark a TODO for timeout handling
This commit is contained in:
parent
ba63b5dfff
commit
c8aaee46d7
2 changed files with 35 additions and 3 deletions
|
@ -27,6 +27,7 @@ class TabComplete {
|
||||||
opts.startingWordSuffix = opts.startingWordSuffix || "";
|
opts.startingWordSuffix = opts.startingWordSuffix || "";
|
||||||
opts.wordSuffix = opts.wordSuffix || "";
|
opts.wordSuffix = opts.wordSuffix || "";
|
||||||
opts.allowLooping = opts.allowLooping || false;
|
opts.allowLooping = opts.allowLooping || false;
|
||||||
|
opts.autoEnterTabComplete = opts.autoEnterTabComplete || false;
|
||||||
this.opts = opts;
|
this.opts = opts;
|
||||||
this.completing = false;
|
this.completing = false;
|
||||||
this.list = []; // full set of tab-completable things
|
this.list = []; // full set of tab-completable things
|
||||||
|
@ -35,6 +36,7 @@ class TabComplete {
|
||||||
this.originalText = null; // original input text when tab was first hit
|
this.originalText = null; // original input text when tab was first hit
|
||||||
this.textArea = opts.textArea; // DOMElement
|
this.textArea = opts.textArea; // DOMElement
|
||||||
this.isFirstWord = false; // true if you tab-complete on the first word
|
this.isFirstWord = false; // true if you tab-complete on the first word
|
||||||
|
this.enterTabCompleteTimerId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,6 +66,12 @@ class TabComplete {
|
||||||
this._notifyStateChange();
|
this._notifyStateChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startTabCompleting() {
|
||||||
|
this.completing = true;
|
||||||
|
this.currentIndex = 0;
|
||||||
|
this._calculateCompletions();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Number} numAheadToPeek Return *up to* this many elements.
|
* @param {Number} numAheadToPeek Return *up to* this many elements.
|
||||||
* @return {TabComplete.Entry[]}
|
* @return {TabComplete.Entry[]}
|
||||||
|
@ -106,6 +114,31 @@ class TabComplete {
|
||||||
this.stopTabCompleting();
|
this.stopTabCompleting();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.opts.autoEnterTabComplete) {
|
||||||
|
/*
|
||||||
|
TODO:
|
||||||
|
- This is passive so we shouldn't clobber the partial word that
|
||||||
|
the user may have entered. This requires more logic to handle
|
||||||
|
that vs a normal TAB which does clobber.
|
||||||
|
- The first invocation of this timer will give no results because
|
||||||
|
we horribly set the enumeration onKeyDown in MessageComposer, which
|
||||||
|
was never actually hit. We should hook into RoomView's RoomState.members
|
||||||
|
event and set the list there.
|
||||||
|
|
||||||
|
|
||||||
|
clearTimeout(this.enterTabCompleteTimerId);
|
||||||
|
this.enterTabCompleteTimerId = setTimeout(() => {
|
||||||
|
if (!this.completing) {
|
||||||
|
// inject a fake tab event so we use the same code paths
|
||||||
|
this.onKeyDown({
|
||||||
|
keyCode: KEY_TAB,
|
||||||
|
preventDefault: function(){} // NOP
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, DELAY_TIME_MS); */
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,9 +149,7 @@ class TabComplete {
|
||||||
|
|
||||||
// init struct if necessary
|
// init struct if necessary
|
||||||
if (!this.completing) {
|
if (!this.completing) {
|
||||||
this.completing = true;
|
this.startTabCompleting();
|
||||||
this.currentIndex = 0;
|
|
||||||
this._calculateCompletions();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ev.shiftKey) {
|
if (ev.shiftKey) {
|
||||||
|
|
|
@ -92,6 +92,7 @@ module.exports = React.createClass({
|
||||||
startingWordSuffix: ": ",
|
startingWordSuffix: ": ",
|
||||||
wordSuffix: " ",
|
wordSuffix: " ",
|
||||||
allowLooping: false,
|
allowLooping: false,
|
||||||
|
autoEnterTabComplete: true,
|
||||||
onStateChange: (isCompleting) => {
|
onStateChange: (isCompleting) => {
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue