Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lost ability to navigate to parent directory #290

Open
jcmuller opened this issue Mar 19, 2018 · 3 comments
Open

Lost ability to navigate to parent directory #290

jcmuller opened this issue Mar 19, 2018 · 3 comments

Comments

@jcmuller
Copy link

How can I begin to debug this issue?

@palikar
Copy link
Collaborator

palikar commented Nov 8, 2018

The button for the parent directory is inserted in the function neo-buffer--insert-root-entry. Maybe you can start form there. Also, what do you mean exactly? Did you do something with your config and broke something or did you played with the code of neotree itself?

@mrspeaker
Copy link

mrspeaker commented May 31, 2019

I think I have this issue too: if you use n/p to navigate to the line for the parent directory ("> ..") then press SPC or RET - nothing happens. I expect it to move to the parent directory.

To actually move to the parent directory you need to move your cursor over until it is on the ".." and THEN press spc or ret (or use the shortcut key).

This is different behaviour than all other files and directory where they can be activated from anywhere on the line.

@mrspeaker
Copy link

mrspeaker commented Jun 1, 2019

I did a little digging into this and think I can see where the issue is, but I'm not sure the correct way to fix it. Currently the parent directory line ".." is treated the same as every other line, and when you hit RET it tries to unfold it but because it's above the current path it does nothing.

As a "proof of concept" I made a dodgy hack by changing neo-open-dir from this:

(defun neo-open-dir (full-path &optional arg)
  (if neo-click-changes-root
      (neotree-change-root)
    (let ((new-state (neo-buffer--toggle-expand full-path)))
      ... stuff to expand the path

To a version where there is an "or" check to also change root if full-path is a parent directory:

(defun neo-open-dir (full-path &optional arg)
  (if (or neo-click-changes-root
          (< (length full-path) (length neo-buffer--start-node)))
      (neotree-change-root)
    (let ((new-state (neo-buffer--toggle-expand full-path)))
      ... etc

However, I guess this is a bad way to do it - it shouldn't be based on the path string length: it should actually know it's the parent! The code above does work (and hitting SPC or RET on ".." will take you up a directory), but I suspect it will do weird things on symlinks. Maybe.

Anyway, if I figure out a more robust way to do it I'll make a pull request.

[EDIT: I think this is a better way, that actually checks the nodes not just string length:

 (if (or neo-click-changes-root
          (equal full-path (neo-path--updir neo-buffer--start-node)))
      (neotree-change-root)

]

mrspeaker added a commit to mrspeaker/emacs-neotree that referenced this issue Jun 2, 2019
Currently the shortcut keys (RET, SPC) do not trigger a change root to the parent directory on the ".." node. To trigger it, you have to move your cursor to the ".." button.

This fix makes the shortcut keys trigger a change root if the path is equal to the parent directory path.
mrspeaker added a commit to mrspeaker/emacs-neotree that referenced this issue Jun 2, 2019
Currently the shortcut keys (RET, SPC) do not trigger a change root to the parent directory on the ".." node. To trigger it, you have to move your cursor to the ".." button.

This fix makes the shortcut keys trigger a change root if the path is equal to the parent directory path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants