Skip to content

Close help on q/close instead of ignore keypress #1043

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
Mar 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lua/nvim-tree/actions/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ local keypress_funcs = {
}

function M.on_keypress(action)
if view.is_help_ui() and action == 'close' then
action = 'toggle_help';
end
Comment on lines +84 to +86
Copy link
Member

Choose a reason for hiding this comment

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

you toggle the help with g?, why does this need another binding ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's more natural to think of it as opening help, then using the generic close to close the current view. Most other "views" in vim works like this. e.g :help vs :q. I hit 'q' every time I am on the help view to close it and feel stuck on that screen until I remember it's the same command to close it as open it.

I don't really see a reason why 'close' should stop working just because the help view is open - having an escape out that works as expected on both screens seems pretty helpful to the user.

No doubt you are comfortable with the current behaviour - but I'm fairly sure new and casual users would agree with the 'q to close either screen' sentiment.

if view.is_help_ui() and action ~= 'toggle_help' then return end
local node = lib.get_node_at_cursor()
if not node then return end
Expand Down