about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authornfnty <git@nfnty.se>2015-10-02 15:18:13 +0200
committernfnty <git@nfnty.se>2015-10-03 18:24:31 +0200
commitf8ed0eebb97c6ba725f04df168964c49fa16a541 (patch)
treecf33c1ce5cd4ce74bb597782cf9136b6840cc3af /ranger
parent946ff7e1fe071cf5d3ff91fd68b79fdde0b6e364 (diff)
downloadranger-f8ed0eebb97c6ba725f04df168964c49fa16a541.tar.gz
Fix regex splitting for natural sort, Fixes #381
Diffstat (limited to 'ranger')
-rw-r--r--ranger/container/fsobject.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/ranger/container/fsobject.py b/ranger/container/fsobject.py
index 334cc2f9..aa848b7a 100644
--- a/ranger/container/fsobject.py
+++ b/ranger/container/fsobject.py
@@ -30,7 +30,7 @@ else:
     from string import maketrans
 _unsafe_chars = '\n' + ''.join(map(chr, range(32))) + ''.join(map(chr, range(128, 256)))
 _safe_string_table = maketrans(_unsafe_chars, '?' * len(_unsafe_chars))
-_extract_number_re = re.compile(r'([^0-9]?)(\d*)')
+_extract_number_re = re.compile(r'(\d+)')
 
 def safe_path(path):
     return path.translate(_safe_string_table)
@@ -144,13 +144,13 @@ class FileSystemObject(FileManagerAware, SettingsAware):
 
     @lazy_property
     def basename_natural(self):
-        return [c if i % 3 == 1 else (int(c) if c else 0) for i, c in \
-            enumerate(_extract_number_re.split(self.relative_path))]
+        return [int(s) if s.isdigit() else s \
+                for s in _extract_number_re.split(self.relative_path)]
 
     @lazy_property
     def basename_natural_lower(self):
-        return [c if i % 3 == 1 else (int(c) if c else 0) for i, c in \
-            enumerate(_extract_number_re.split(self.relative_path_lower))]
+        return [int(s) if s.isdigit() else s \
+                for s in _extract_number_re.split(self.relative_path_lower)]
 
     @lazy_property
     def safe_basename(self):
r Kartik K. Agaram <vc@akkartik.com> 2017-10-09 01:19:33 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2017-10-09 01:19:33 -0700 4011 - start of sub-x86 VM' href='/akkartik/mu/commit/subx/002test.cc?h=hlt&id=224474d7fd04263b7300d22df337c33b97de5fe5'>224474d7 ^
248e789e ^


224474d7 ^


248e789e ^











224474d7 ^
248e789e ^


248e789e ^

e1eefb8a ^

















248e789e ^

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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104