summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-05-17 17:36:16 +0200
committerhut <hut@lavabit.com>2010-05-17 17:41:32 +0200
commit3ac9d6c841c47cebaab028557a217911d6cecd0e (patch)
tree84ae5a8a46217606447fdd8d1baeb6a48c6260de
parent9e435dcd5bcaf20f74f979f5ac79714172648226 (diff)
downloadranger-3ac9d6c841c47cebaab028557a217911d6cecd0e.tar.gz
utf: fixed console.delete()
-rw-r--r--ranger/gui/widgets/console.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index 51ecf3b2..48116187 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -264,13 +264,15 @@ class Console(Widget):
 
 	def delete(self, mod):
 		self.tab_deque = None
-		if mod == -1 and len(self.line) == 0:
-			self.close()
-		pos = self.pos + mod
-
-		chars = uchars(self.line)
-		self.line = ''.join(chars[0:pos] + chars[pos+1:])
-		self.move(right=mod)
+		if mod == -1 and self.pos == 0:
+			if not self.line:
+				self.close()
+			return
+		uc = uchars(self.line)
+		upos = len(uchars(self.line[:self.pos])) + mod
+		left_part = ''.join(uc[:upos])
+		self.pos = len(left_part)
+		self.line = left_part + ''.join(uc[upos+1:])
 		self.on_line_change()
 
 	def execute(self):