summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2020-09-04 09:29:19 +0200
committerMaxime “pep” Buquet <pep@bouah.net>2020-09-04 09:29:19 +0200
commitfe960cb825c9188dd726630c6c79c0003ba3a629 (patch)
tree5ae20a82bd2b866fce5d418529295607966334a0
parentc7a46f17126a34fb10194114c831f635c325866b (diff)
downloadpoezio-fe960cb825c9188dd726630c6c79c0003ba3a629.tar.gz
poezio-fe960cb825c9188dd726630c6c79c0003ba3a629.tar.bz2
poezio-fe960cb825c9188dd726630c6c79c0003ba3a629.tar.xz
poezio-fe960cb825c9188dd726630c6c79c0003ba3a629.zip
plugins/code: Prevent traceback when not enough arguments -- thanks Ge0rG
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r--plugins/code.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/plugins/code.py b/plugins/code.py
index 1c6dfab0..8d9c57a3 100644
--- a/plugins/code.py
+++ b/plugins/code.py
@@ -41,7 +41,11 @@ class Plugin(BasePlugin):
help='Sends syntax-highlighted code in the current tab')
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)
tab = self.api.current_tab()
code = highlight(code, lexer, FORMATTER)