Krolyxon
Commit 64b885b

Branches

Refs →

nsxiv64b885b

Fix navigating from last to previous image over invalid files

Author
Bert Münnich
Date
2017-10-26 22:20 +0200
Parent
2d34c4b
Commit
64b885b6a9fbb5522654af919a3c4ce719f11c2e

+5 −4

2 files changed

  1. M Makefile +1 −1
  2. M main.c +4 −3
M Makefile View
@@ -1,4 +1,4 @@
1−VERSION = git-20171024
1+VERSION = git-20171026
22
33 srcdir = .
44 VPATH = $(srcdir)
M main.c View
@@ -159,8 +159,8 @@ void remove_file(int n, bool manual)
159159 memmove(files + n, files + n + 1, (filecnt - n - 1) * sizeof(*files));
160160 }
161161 filecnt--;
162− if (fileidx >= filecnt)
163− fileidx = filecnt - 1;
162+ if (n < fileidx)
163+ fileidx--;
164164 if (n < alternate)
165165 alternate--;
166166 }
@@ -290,6 +290,7 @@ end:
290290
291291 void load_image(int new)
292292 {
293+ bool prev = new < fileidx;
293294 static int current;
294295
295296 if (new < 0 || new >= filecnt)
@@ -307,7 +308,7 @@ void load_image(int new)
307308 remove_file(new, false);
308309 if (new >= filecnt)
309310 new = filecnt - 1;
310− else if (new > 0 && new < fileidx)
311+ else if (new > 0 && prev)
311312 new--;
312313 }
313314 files[new].flags &= ~FF_WARN;