Skip to content

fix(#1629): nvim start with file named *NvimTree* opens tree instead of buffer #1634

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 4 commits into from
Oct 10, 2022

Conversation

alex-courtis
Copy link
Member

fixes #1629

find_existing_windows misidentifies a buffer named *NvimTree* as the tree's buffer.

  • setup -> on_enter -> find_existing_windows is the only codepath
  • view is always closed in setup

∴ this may be removed

Comment on lines 261 to 267
-- Session that left a NvimTree Buffer opened, reopen with it
local existing_tree_wins = find_existing_windows()
if existing_tree_wins[1] then
api.nvim_set_current_win(existing_tree_wins[1])
end

if should_open or existing_tree_wins[1] ~= nil then
Copy link
Member

Choose a reason for hiding this comment

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

i think this is needed for user using sessions

Copy link
Member

Choose a reason for hiding this comment

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

maybe a better fix would be to change the matching string to NvimTree_

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch; I didn't think of nvim sessions, just user calling setup multiple times.

Added a util to check that the buffer name matches and that it is a real file. We can't test file type as it's not imported via default sessionoptions.

@barrett-ruth I'd be grateful for a re-test.

@alex-courtis
Copy link
Member Author

Raised #1639 to be completed in a separate branch.

@barrett-ruth
Copy link

@alex-courtis works great for me.

@alex-courtis alex-courtis merged commit c66cbdf into master Oct 10, 2022
Almo7aya pushed a commit to Almo7aya/nvim-tree.lua that referenced this pull request Oct 11, 2022
… instead of buffer (nvim-tree#1634)

* fix(nvim-tree#1629): nvim start with file named *NvimTree* opens tree instead of buffer

* Revert "fix(nvim-tree#1629): nvim start with file named *NvimTree* opens tree instead of buffer"

This reverts commit e713607.

* fix(nvim-tree#1629): nvim start with file named *NvimTree* treats file as tree

* fix(nvim-tree#1629): nvim start with file named *NvimTree* treats file as tree
@alex-courtis
Copy link
Member Author

Unfortunately this change has been reverted due to many regressions: #1668

A new mechanism to control startup behaviour is under way: #1669

@alex-courtis alex-courtis deleted the 1629-cannot-start-with-buffer-named-NvimTree branch December 16, 2022 04:38
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.

nvim NvimTree.lua does not open
3 participants