You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-08 21:42:24 +03:00
Hide/show autocomplete based on selection state
This commit is contained in:
@@ -39,22 +39,23 @@ const COMMANDS = [
|
||||
}
|
||||
];
|
||||
|
||||
let COMMAND_RE = /(^\/\w*)/g;
|
||||
|
||||
let instance = null;
|
||||
|
||||
export default class CommandProvider extends AutocompleteProvider {
|
||||
constructor() {
|
||||
super();
|
||||
super(COMMAND_RE);
|
||||
this.fuse = new Fuse(COMMANDS, {
|
||||
keys: ['command', 'args', 'description']
|
||||
});
|
||||
}
|
||||
|
||||
getCompletions(query: String) {
|
||||
getCompletions(query: string, selection: {start: number, end: number}) {
|
||||
let completions = [];
|
||||
const matches = query.match(/(^\/\w*)/);
|
||||
if(!!matches) {
|
||||
const command = matches[0];
|
||||
completions = this.fuse.search(command).map(result => {
|
||||
const command = this.getCurrentCommand(query, selection);
|
||||
if(command) {
|
||||
completions = this.fuse.search(command[0]).map(result => {
|
||||
return {
|
||||
title: result.command,
|
||||
subtitle: result.args,
|
||||
|
||||
Reference in New Issue
Block a user