summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/container/keymap.py12
-rw-r--r--test/tc_newkeys.py16
2 files changed, 11 insertions, 17 deletions
diff --git a/ranger/container/keymap.py b/ranger/container/keymap.py
index e8cf6119..41875cb2 100644
--- a/ranger/container/keymap.py
+++ b/ranger/container/keymap.py
@@ -144,12 +144,6 @@ class KeyBuffer(object):
 			self._do_eval_direction(key)
 
 	def _do_eval_direction(self, key):
-		# swap quant and direction_quant in bindings like '<dir>'
-		if self.quant is not None and self.command is None \
-		and self.direction_quant is None:
-			self.direction_quant = self.quant
-			self.quant = None
-
 		try:
 			assert isinstance(self.dir_tree_pointer, dict)
 			self.dir_tree_pointer = self.dir_tree_pointer[key]
@@ -176,11 +170,9 @@ class KeyBuffer(object):
 					self.failure = True
 					return None
 			else:
+				direction = match.actions['dir'].copy()
 				if self.direction_quant is not None:
-					direction = match.actions['dir'] * self.direction_quant
-					direction.has_explicit_direction = True
-				else:
-					direction = match.actions['dir'].copy()
+					direction.multiply(self.direction_quant)
 				self.directions.append(direction)
 				self.direction_quant = None
 				self.eval_command = True
diff --git a/test/tc_newkeys.py b/test/tc_newkeys.py
index 0c810af5..bcf08e5f 100644
--- a/test/tc_newkeys.py
+++ b/test/tc_newkeys.py
@@ -85,7 +85,7 @@ class Test(PressTestCase):
 
 	def test_map_collision(self):
 		def add_dirs(arg):
-			return sum(dir.down for dir in arg.directions)
+			return sum(dir.down() for dir in arg.directions)
 		def return5(_):
 			return 5
 
@@ -145,7 +145,7 @@ class Test(PressTestCase):
 
 	def test_alias(self):
 		def add_dirs(arg):
-			return sum(dir.down for dir in arg.directions)
+			return sum(dir.down() for dir in arg.directions)
 		def return5(_):
 			return 5
 
@@ -326,7 +326,7 @@ class Test(PressTestCase):
 			n = arg.n is None and 1 or arg.n
 			dir = arg.direction is None and Direction(down=1) \
 					or arg.direction
-			return n * dir.down
+			return n * dir.down()
 		km.map('d<dir>', nd)
 		km.map('dd', func=nd)
 
@@ -401,7 +401,7 @@ class Test(PressTestCase):
 		directions.map('k', dir=Direction(down=-1))
 
 		def add_dirs(arg):
-			return sum(dir.down for dir in arg.directions)
+			return sum(dir.down() for dir in arg.directions)
 
 		km.map('x<dir>y<dir>', add_dirs)
 		km.map('four<dir><dir><dir><dir>', add_dirs)
@@ -445,7 +445,7 @@ class Test(PressTestCase):
 		press = self._mkpress(kb, km)
 
 		def move(arg):
-			return arg.direction.down
+			return arg.direction.down()
 
 		directions.map('j', dir=Direction(down=1))
 		directions.map('s', alias='j')
@@ -471,11 +471,13 @@ class Test(PressTestCase):
 		self.assertEqual(1, press('j'))
 		self.assertEqual('love', press('k'))
 
-		self.assertEqual(40, press('40j'))
+		self.assertEqual(1, press('40j'))
+		self.assertEqual(40, kb.quant)
 
 		km.map('<dir><dir><any><any>', func=move)
 
-		self.assertEqual(40, press('40jkhl'))
+		self.assertEqual(1, press('40jkhl'))
+		self.assertEqual(40, kb.quant)
 
 	def test_tree_deep_copy(self):
 		t = Tree()
>
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
60
61
62
63
64
65
66
67
68