Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3024 from matrix-org/bwindels/autocomplete-tab
Browse files Browse the repository at this point in the history
Message editing: tab completion
  • Loading branch information
bwindels authored May 24, 2019
2 parents 3c778e8 + cf5e4d3 commit 9d6a818
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
20 changes: 18 additions & 2 deletions src/editor/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,24 @@ export default class AutocompleteWrapperModel {
this._updateCallback({close: true});
}

onTab() {
//forceCompletion here?
async onTab(e) {
const acComponent = this._getAutocompleterComponent();

if (acComponent.state.completionList.length === 0) {
// Force completions to show for the text currently entered
await acComponent.forceComplete();
// Select the first item by moving "down"
await acComponent.onDownArrow();
} else {
if (e.shiftKey) {
await acComponent.onUpArrow();
} else {
await acComponent.onDownArrow();
}
}
this._updateCallback({
close: true,
});
}

onUpArrow() {
Expand Down
12 changes: 10 additions & 2 deletions src/editor/parts.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,16 @@ export class PillCandidatePart extends PlainPart {
return this._autoCompleteCreator(updateCallback);
}

acceptsInsertion(chr) {
return true;
acceptsInsertion(chr, i) {
if (i === 0) {
return true;
} else {
return super.acceptsInsertion(chr, i);
}
}

merge() {
return false;
}

acceptsRemoval(position, chr) {
Expand Down

0 comments on commit 9d6a818

Please sign in to comment.