Fix 'dired-movement-style' in Dired when subdirs are shown
authorEli Zaretskii <eliz@gnu.org>
Thu, 13 Mar 2025 10:34:23 +0000 (12:34 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sat, 15 Mar 2025 15:27:43 +0000 (16:27 +0100)
* lisp/dired.el (dired--move-to-next-line): Don't consider
sub-directory lines as empty.  (Bug#76596)

(cherry picked from commit 04034cd9ce746e3914daa66add34c66ad2db032d)

lisp/dired.el

index 06c627c3cda16df2456092d449d14355ebb975b0..8bb05a4540ebb4303df4901a0897ee16dbebde0a 100644 (file)
@@ -2931,15 +2931,19 @@ is controlled by `dired-movement-style'."
           (setq wrapped t))
          ;; `bounded': go back to the last non-empty line.
          (dired-movement-style ; Either 'bounded or anything else non-nil.
-          (while (and (dired-between-files) (not (zerop arg)))
+          (while (and (dired-between-files)
+                      (not (dired-get-subdir))
+                      (not (zerop arg)))
             (funcall jumpfun (- moving-down))
             ;; Point not moving means infinite loop.
             (if (= old-position (point))
                 (setq arg 0)
               (setq old-position (point))))
           ;; Encountered a boundary, so let's stop movement.
-          (setq arg (if (dired-between-files) 0 moving-down)))))
-      (unless (dired-between-files)
+          (setq arg (if (and (dired-between-files)
+                             (not (dired-get-subdir)))
+                        0 moving-down)))))
+      (unless (and (dired-between-files) (not (dired-get-subdir)))
         ;; Has moved to a non-empty line.  This movement does
         ;; make sense.
         (decf arg moving-down))