hide some commands after space as they have special semantics
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/21833/head
							parent
							
								
									f429ae5617
								
							
						
					
					
						commit
						5867fe73dd
					
				| 
						 | 
					@ -26,11 +26,12 @@ import SettingsStore, {SettingLevel} from './settings/SettingsStore';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Command {
 | 
					class Command {
 | 
				
			||||||
    constructor({name, args='', description, runFn}) {
 | 
					    constructor({name, args='', description, runFn, hideCompletionAfterSpace=false}) {
 | 
				
			||||||
        this.command = '/' + name;
 | 
					        this.command = '/' + name;
 | 
				
			||||||
        this.args = args;
 | 
					        this.args = args;
 | 
				
			||||||
        this.description = description;
 | 
					        this.description = description;
 | 
				
			||||||
        this.runFn = runFn;
 | 
					        this.runFn = runFn;
 | 
				
			||||||
 | 
					        this.hideCompletionAfterSpace = hideCompletionAfterSpace;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    getCommand() {
 | 
					    getCommand() {
 | 
				
			||||||
| 
						 | 
					@ -78,6 +79,7 @@ export const CommandMap = {
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
            return success();
 | 
					            return success();
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 | 
					        hideCompletionAfterSpace: true,
 | 
				
			||||||
    }),
 | 
					    }),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    nick: new Command({
 | 
					    nick: new Command({
 | 
				
			||||||
| 
						 | 
					@ -466,6 +468,7 @@ export const CommandMap = {
 | 
				
			||||||
        name: 'me',
 | 
					        name: 'me',
 | 
				
			||||||
        args: '<message>',
 | 
					        args: '<message>',
 | 
				
			||||||
        description: _td('Displays action'),
 | 
					        description: _td('Displays action'),
 | 
				
			||||||
 | 
					        hideCompletionAfterSpace: true,
 | 
				
			||||||
    }),
 | 
					    }),
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
/* eslint-enable babel/no-invalid-this */
 | 
					/* eslint-enable babel/no-invalid-this */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,6 +46,8 @@ export default class CommandProvider extends AutocompleteProvider {
 | 
				
			||||||
            // The input looks like a command with arguments, perform exact match
 | 
					            // The input looks like a command with arguments, perform exact match
 | 
				
			||||||
            const name = command[1].substr(1); // strip leading `/`
 | 
					            const name = command[1].substr(1); // strip leading `/`
 | 
				
			||||||
            if (CommandMap[name]) {
 | 
					            if (CommandMap[name]) {
 | 
				
			||||||
 | 
					                // some commands, namely `me` and `ddg` don't suit having the usage shown whilst typing their arguments
 | 
				
			||||||
 | 
					                if (!CommandMap[name].hideCompletionAfterSpace) return [];
 | 
				
			||||||
                matches = [CommandMap[name]];
 | 
					                matches = [CommandMap[name]];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue