wyuenho / all-the-icons-dired

Adds dired support to all-the-icons
GNU General Public License v3.0
23 stars 7 forks source link

Mangled icons when using `dired-narrow` with the `dired-narrow-enter-directory` function #6

Closed bastidest closed 2 years ago

bastidest commented 3 years ago

Information

all-the-icons-dired Version melpa 20210614.1350 (newest)
Emacs Version GNU Emacs 28.0.50.148618
OS Arch Linux (5.12.15-arch1-1)
emacs -q ? yes

Emacs Configuration:

(require 'package)
(package-initialize)

(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

(use-package dired-narrow
  :after (dired)
  :bind (:map dired-mode-map
        ("/" . dired-narrow)))

(use-package all-the-icons-dired
  :hook
  (dired-mode . all-the-icons-dired-mode))

Bug Description

all-the-icons-dired does not update the icons when using dired-narrow with the dired-narrow-enter-directory function.

How to Reproduce

  1. Use emacs -q with the given configuration and up-to-date melpa packages
  2. Open dired in a arbitrary directory
  3. Press / or M-x dired-narrow
  4. Move cursor to a directory
  5. Press C-j

Expected Behavior

The all-the-icons-dired--refresh-advice should be executed when entering a directory (dired-narrow-enter-directory) with dired-narrow. The dired buffer should not display mangled icons.

Actual Behavior

The all-the-icons-dired--refresh-advice function is not executed when entering a directory (dired-narrow-enter-directory) with dired-narrow. This results in mangled icons. image

Cause

It seems like the advice using the dired-narrow--internal function should use dired-narrow--remove-text-with-property since after executing this function the icons appear mangled (by stepping through it with the debugger).

Workaround

(push '(dired-narrow dired-narrow--remove-text-with-property all-the-icons-dired--refresh-advice) all-the-icons-dired-advice-alist)

Suggested Change

Either replace or add this line. Replacing it has worked for me (1 day of testing).

diff --git a/all-the-icons-dired.el b/all-the-icons-dired.el
index 625b027..9b7cf71 100644
--- a/all-the-icons-dired.el
+++ b/all-the-icons-dired.el
@@ -118,7 +118,7 @@
     (dired-aux     dired-insert-subdir          all-the-icons-dired--refresh-advice)
     (dired         wdired-abort-changes         all-the-icons-dired--refresh-advice)
     (dired         dired-internal-do-deletions  all-the-icons-dired--refresh-advice)
-    (dired-narrow  dired-narrow--internal       all-the-icons-dired--refresh-advice)
+    (dired-narrow  dired-narrow--remove-text-with-property  all-the-icons-dired--refresh-advice)
     (dired         dired-readin                 all-the-icons-dired--refresh-advice)
     (dired         dired-revert                 all-the-icons-dired--refresh-advice)
     (find-dired    find-dired-sentinel          all-the-icons-dired--refresh-advice))

Comment

Thank you for maintaining this package!

wyuenho commented 2 years ago

I've applied your suggested fix but it doesn't seem to fix the issue. In fact, I'm not even sure what dired-narrow-enter-directory is suppose to do, it just erases the buffer and insert a line of text into the buffer. It looks like a very crude way to exit narrowing. Your best bet is to reimplement this hack or file a bug to dired-narrow.