summary refs log tree commit diff stats
diff options
context:
space:
mode:
authornfnty <git@nfnty.se>2015-10-02 15:18:13 +0200
committerhut <hut@lepus.uberspace.de>2015-10-04 01:34:23 +0200
commit28f9187f6f08a5b09293d44f1928a7da85c2a7b7 (patch)
tree9d33495a57546bf209cb1b9c8159f12de0ac2dc2
parent751127e231f084c0b6a8a717424d83564212f49b (diff)
downloadranger-28f9187f6f08a5b09293d44f1928a7da85c2a7b7.tar.gz
Fix regex splitting for natural sort, Fixes #381
-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 a8c70e03..b63781de 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):