summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/gui/widgets/console.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index b20224e1..4d1855f7 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -189,9 +189,12 @@ class Console(Widget):
 	def type_key(self, key):
 		self.tab_deque = None
 
-		result = self._add_character(key, self.unicode_buffer, "" if
-				self.question_queue else self.line, self.pos)
-		if not result:
+		line = "" if self.question_queue else self.line
+		result = self._add_character(key, self.unicode_buffer, line, self.pos)
+		if result[1] == line:
+			# line didn't change, so we don't need to do anything, just update
+			# the unicode _buffer.
+			self.unicode_buffer = result[0]
 			return
 
 		if self.question_queue:
@@ -202,20 +205,25 @@ class Console(Widget):
 			self.on_line_change()
 
 	def _add_character(self, key, unicode_buffer, line, pos):
+		# Takes the pressed key, a string "unicode_buffer" containing a
+		# potentially incomplete unicode character, the current line and the
+		# position of the cursor inside the line.
+		# This function returns the new unicode buffer, the modified line and
+		# position.
 		if isinstance(key, int):
 			try:
 				key = chr(key)
 			except ValueError:
-				return
+				return unicode_buffer, line, pos
 
 		if self.fm.py3:
 			unicode_buffer += key
 			try:
 				decoded = unicode_buffer.encode("latin-1").decode("utf-8")
 			except UnicodeDecodeError:
-				return
+				return unicode_buffer, line, pos
 			except UnicodeEncodeError:
-				return
+				return unicode_buffer, line, pos
 			else:
 				unicode_buffer = ""
 				if pos == len(line):
by a couple of methods' href='/akspecs/ranger/commit/test/tc_history.py?h=v1.8.1&id=3dbefa71785bf61b8f28d4a780064f3f4e04dcb5'>3dbefa71 ^
22bb7e35 ^
3dbefa71 ^
22bb7e35 ^

3dbefa71 ^


22bb7e35 ^
3dbefa71 ^
22bb7e35 ^
3dbefa71 ^
22bb7e35 ^


3dbefa71 ^
22bb7e35 ^








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59