Skip to content

fix: api.node.open.preview should toggle directories #2099

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

Merged
merged 1 commit into from
Apr 3, 2023

Conversation

gegoune
Copy link
Collaborator

@gegoune gegoune commented Mar 29, 2023

Regression introduced by 7495975.

Closes #2097

@alex-courtis I have kept parity with open_or_expand_or_dir_up in regards to behaviour on .., which might not be desired. I believe we might not want to do anything in that case as it was previously?
If we do want to keep parity perhaps those two functions can be merged into one with preview argument.

if node.nodes or node.name == ".." then
return
if node.name == ".." then
require("nvim-tree.actions.root.change-dir").fn ".."
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to return early here. This was inline with previous behaviour.

Suggested change
require("nvim-tree.actions.root.change-dir").fn ".."
return

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing with 9c97e64 (before on_attach): preview does nothing on the root directory.

However, the change-dir does make sense and brings it in line with open.

How about this help:

api.node.open.edit()                          *nvim-tree.api.node.open.edit()*
    File:   open as per |nvim-tree.actions.open_file|
    Folder: expand or collapse
    Root:   change directory up

api.node.open.preview()                    *nvim-tree.api.node.open.preview()*
    Perform |nvim-tree.api.node.edit()|
    File buffer will have |bufhidden| set to `delete`.

Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for dealing with this one!

if node.nodes or node.name == ".." then
return
if node.name == ".." then
require("nvim-tree.actions.root.change-dir").fn ".."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing with 9c97e64 (before on_attach): preview does nothing on the root directory.

However, the change-dir does make sense and brings it in line with open.

How about this help:

api.node.open.edit()                          *nvim-tree.api.node.open.edit()*
    File:   open as per |nvim-tree.actions.open_file|
    Folder: expand or collapse
    Root:   change directory up

api.node.open.preview()                    *nvim-tree.api.node.open.preview()*
    Perform |nvim-tree.api.node.edit()|
    File buffer will have |bufhidden| set to `delete`.

@gegoune gegoune merged commit 7ad1c20 into nvim-tree:master Apr 3, 2023
@gegoune gegoune deleted the fix/preview branch April 3, 2023 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<Tab> key no longer toggles directories
2 participants