Skip to content

Commit 0f39a55

Browse files
authored
Merge pull request #655 from buzzingwires/none_sorting
Add the 'none' sorting setting
2 parents cbcc268 + ab25bc1 commit 0f39a55

File tree

6 files changed

+40
-2
lines changed

6 files changed

+40
-2
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Wolfgang Popp (woefe) <mail at wolfgang-popp dot de>
33
Ankur Sinha (sanjayankur31) <ankursinha at fedoraproject dot org>
44
Jean-Claude Graf (jcjgraf) <jeanggi90 at gmail dot com>
55
Mateus Etto (Yutsuten) <mateus dot etto at gmail dot com>
6+
buzzingwires (buzzingwires) <buzzingwires at outlook dot com>
67

78
All contributors of non-trivial code are listed here. Please send an email to
89
<karlch at protonmail dot com> or open an issue / pull request if you feel like your

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ Added:
8989
the changes with ``<return>`` and reject them with ``<escape>``. The
9090
``{transformation-info}`` status module displays the currently selected geometry of
9191
the original image. Thanks `@Yutsuten`_ for reviving this!
92+
* Add the ``none`` sorting type for the ``sort.image_order`` and ``sort.directory_order``
93+
options, implemented by `@buzzingwires`_
9294

9395
Changed:
9496
^^^^^^^^
@@ -535,3 +537,4 @@ Initial release of the Qt version.
535537
.. _@timsofteng: https://github.com/timsofteng
536538
.. _@kAldown: https://github.com/kaldown
537539
.. _@Yutsuten: https://github.com/Yutsuten
540+
.. _@buzzingwires: https://github.com/buzzingwires

docs/documentation/configuration/settings.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ directories. The ordering principle is defined by the ``sort.image_order`` and
5656
natural Natural ordering by basename, i.e. image2.jpg comes before image11.jpg
5757
recently-modified Ordering by modification time (``mtime``)
5858
size Ordering by filesize, in bytes for images, in number of files for directories
59+
none Do not sort or reverse. Use the existing order of the images (including that of a previous sort type). This is mostly for keeping the order from the command line or stdin.
5960
========================= ===========
6061

6162
In addition, the ordering can be reversed using ``sort.reverse`` and the string-like
6263
orderings (``alphabetical`` and ``natural``) can be made case-insensitive using
63-
``sort.ignore_case``. When ``sort.shuffle`` is set, the image filelist is shuffled
64-
regardless of the other orderings, but the library remains ordered.
64+
``sort.ignore_case`` except for when the ``none`` ordering type is used.
65+
When ``sort.shuffle`` is set, the image filelist is shuffled regardless of the other
66+
orderings, but the library remains ordered.

tests/end2end/features/image/imageorder.feature

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,26 @@ Feature: Ordering the image filelist.
88
And the image number 2 should be image_2.jpg
99
And the image number 11 should be image_11.jpg
1010

11+
Scenario: Set none sorting after another sort
12+
Given I open 12 images without leading zeros in their name
13+
When I run set sort.image_order natural
14+
Then the image should have the index 1
15+
And the image number 1 should be image_1.jpg
16+
And the image number 2 should be image_2.jpg
17+
And the image number 11 should be image_11.jpg
18+
When I run set sort.image_order none
19+
Then the image should have the index 1
20+
And the image number 1 should be image_1.jpg
21+
And the image number 2 should be image_2.jpg
22+
And the image number 11 should be image_11.jpg
23+
24+
Scenario: Reverse none sorting
25+
Given I open 5 images
26+
When I run set sort.image_order none
27+
Then the image should have the index 1
28+
When I run set sort.reverse
29+
Then the image should have the index 1
30+
1131
Scenario: Reverse current filelist
1232
Given I open 5 images
1333
When I run set sort.reverse!

tests/unit/api/test_settings.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,17 @@ def test_order_setting_sort(
189189
assert sorted_values == expected_values
190190

191191

192+
@pytest.mark.parametrize("reverse", [True, False])
193+
@pytest.mark.parametrize("ignore_case", [True, False])
194+
def test_order_setting_sort_none(monkeypatch, reverse, ignore_case):
195+
values = ["a5.j", "A6.j", "a11.j", "a3.j"]
196+
monkeypatch.setattr(settings.sort.reverse, "value", reverse)
197+
monkeypatch.setattr(settings.sort.ignore_case, "value", ignore_case)
198+
o = settings.OrderSetting("order", "none")
199+
sorted_values = o.sort(values)
200+
assert sorted_values == values
201+
202+
192203
@pytest.mark.parametrize("ignore_case", [True, False])
193204
def test_order_setting_sort_ignore_case(monkeypatch, ignore_case):
194205
monkeypatch.setattr(settings.sort.ignore_case, "value", ignore_case)

vimiv/api/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ class OrderSetting(Setting):
325325
"alphabetical": str,
326326
"natural": natural_sort,
327327
"recently-modified": os.path.getmtime,
328+
"none": lambda x: 0
328329
}
329330

330331
STR_ORDER_TYPES = "alphabetical", "natural"

0 commit comments

Comments
 (0)