From e8b3ae51480ac217c2f064704902ff2f28b9f635 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 25 Aug 2010 03:11:41 +0200 Subject: widgets.console: improved delete_word() --- ranger/gui/widgets/console.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py index ff8d137a..85b92548 100644 --- a/ranger/gui/widgets/console.py +++ b/ranger/gui/widgets/console.py @@ -20,6 +20,7 @@ commands, searching and executing files. import string import curses +import re from collections import deque from . import Widget @@ -258,15 +259,15 @@ class Console(Widget): self.on_line_change() def delete_word(self): - self.tab_deque = None - try: - i = self.line.rindex(' ', 0, self.pos - 1) + 1 - self.line = self.line[:i] + self.line[self.pos:] + if self.line: + self.tab_deque = None + i = len(self.line) - 2 + while i >= 0 and re.match(r'[\w\d]', self.line[i], re.U): + i -= 1 + self.copy = self.line[i + 1:] + self.line = self.line[:i + 1] self.pos = len(self.line) - except ValueError: - self.line = '' - self.pos = 0 - self.on_line_change() + self.on_line_change() def delete(self, mod): self.tab_deque = None -- cgit 1.4.1-2-gfad0