From 9e25dbdfb3ccdd0c3975ecff9c9f3d947b700844 Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Thu, 29 Oct 2015 21:57:54 +0100 Subject: Make sure current_position isn't negative We use current_position as an index into the current text on the line. Make sure it's never negative. This prevents a backtrace when trying to complete with an empty string. --- wee_slack.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'wee_slack.py') diff --git a/wee_slack.py b/wee_slack.py index 84bf17d..c789b43 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1686,6 +1686,8 @@ def complete_next_cb(data, buffer, command): # If we're on a non-word, look left for something to complete while current_pos >= 0 and input[current_pos] != '@' and not input[current_pos].isalnum(): current_pos = current_pos - 1 + if current_pos < 0: + current_pos = 0 for l in range(current_pos, 0, -1): if input[l] != '@' and not input[l].isalnum(): word_start = l + 1 -- cgit