]> Sergey Matveev's repositories - nnn.git/commitdiff
Refactor move_cursor()
authorArun Prakash Jana <engineerarun@gmail.com>
Mon, 4 May 2020 00:47:38 +0000 (06:17 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Mon, 4 May 2020 00:47:38 +0000 (06:17 +0530)
plugins/finder
plugins/mimelist
src/nnn.c

index c3b2242044f7ec5cefe6f68ce6358b490d3a4a78..b7cda42009544c4444573232d5374049592cc0c7 100755 (executable)
@@ -6,7 +6,7 @@
 #       - export FZF_DEFAULT_OPTS='--bind ctrl-a:select-all,ctrl-d:deselect-all'
 #
 # Shell: POSIX compliant
-# Author: Arun Prakash jana
+# Author: Arun Prakash Jana
 
 . "$(dirname "$0")"/.nnn-plugin-helper
 
index 5635afda3b279e57c1887815e2407592a7f67238..f179e6e38f3db68845220525a0691828fd8e9af7 100755 (executable)
@@ -4,7 +4,7 @@
 # Requires: fd/find
 #
 # Shell: POSIX compliant
-# Author: Arun Prakash jana
+# Author: Arun Prakash Jana
 
 . "$(dirname "$0")"/.nnn-plugin-helper
 
index 6c46db0010c9b089deb8d24218e30c3d8f298fcd..1a2ad77f3a08180af8f4d34898da0413e6682c2a 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -4669,15 +4669,17 @@ static void populate(char *path, char *lastname)
 
 static void move_cursor(int target, int ignore_scrolloff)
 {
-       int delta, scrolloff, onscreen = xlines - 4;
+       int onscreen = xlines - 4; /* Leave top 2 and bottom 2 lines */
 
-       last_curscroll = curscroll;
        target = MAX(0, MIN(ndents - 1, target));
-       delta = target - cur;
+       last_curscroll = curscroll;
        last = cur;
        cur = target;
+
        if (!ignore_scrolloff) {
-               scrolloff = MIN(SCROLLOFF, onscreen >> 1);
+               int delta = target - last;
+               int scrolloff = MIN(SCROLLOFF, onscreen >> 1);
+
                /*
                 * When ignore_scrolloff is 1, the cursor can jump into the scrolloff
                 * margin area, but when ignore_scrolloff is 0, act like a boa