diff options
author | nfnty <git@nfnty.se> | 2015-10-02 15:18:13 +0200 |
---|---|---|
committer | nfnty <git@nfnty.se> | 2015-10-03 18:24:31 +0200 |
commit | f8ed0eebb97c6ba725f04df168964c49fa16a541 (patch) | |
tree | cf33c1ce5cd4ce74bb597782cf9136b6840cc3af /ranger | |
parent | 946ff7e1fe071cf5d3ff91fd68b79fdde0b6e364 (diff) | |
download | ranger-f8ed0eebb97c6ba725f04df168964c49fa16a541.tar.gz |
Fix regex splitting for natural sort, Fixes #381
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/container/fsobject.py | 10 |
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): |