diff options
author | hut <hut@lavabit.com> | 2010-08-25 03:11:41 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-08-25 03:11:41 +0200 |
commit | e8b3ae51480ac217c2f064704902ff2f28b9f635 (patch) | |
tree | ac0932d087a100e329fb048ef083309b787c59f9 /ranger | |
parent | 89f453db286f648dcaf498c32ac37d67ccd90e18 (diff) | |
download | ranger-e8b3ae51480ac217c2f064704902ff2f28b9f635.tar.gz |
widgets.console: improved delete_word()
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/gui/widgets/console.py | 17 |
1 files 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 |