plugins/code: Prevent traceback when not enough arguments -- thanks Ge0rG

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2020-09-04 09:29:19 +02:00
parent c7a46f1712
commit fe960cb825
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -41,7 +41,11 @@ class Plugin(BasePlugin):
help='Sends syntax-highlighted code in the current tab') help='Sends syntax-highlighted code in the current tab')
def command_code(self, args): def command_code(self, args):
language, code = args.split(None, 1) split = args.split(None, 1)
if len(split) != 2:
self.api.information('Usage: /code <language> <code>', 'Error')
return None
language, code = split
lexer = get_lexer_by_name(language) lexer = get_lexer_by_name(language)
tab = self.api.current_tab() tab = self.api.current_tab()
code = highlight(code, lexer, FORMATTER) code = highlight(code, lexer, FORMATTER)