Skip to content

Conversation

@Gelio
Copy link
Contributor

@Gelio Gelio commented Nov 5, 2022

When opening a new neo-tree window with the current position, do not close all other current windows.
This allows having multiple current windows side-by-side on the same tabpage.

It was possible before with the following combination (open neo-tree in one buffer, then split it):

:e .<CR>:vs

This opened two neo-tree windows side-by-side (when hijack_netrw_behavior was set to open_current).

Peek.2022-11-05.10-53.netrw.side.by.side.working.well.mp4

However, when trying to it the other way around (open two buffers side by side, open neo-tree in one of them, then switch to the other buffer and open neo-tree in that one):

:vs<CR>:Neotree position=current<CR><C-W>p:Neotree position=current

Opening the second neo-tree window closed the first one.

Peek.2022-11-05.10-54.neotree.open.current.closes.the.other.one.mp4

With this fix, both combinations lead to the same result of having two independent neo-tree windows side-by-side with the current position.

Peek.2022-11-05.10-54.neotree.open.current.works.fine.with.fix.mp4

My neo-tree config in case that is relevant: https://github.com/Gelio/ubuntu-dotfiles/blob/4cb7abb39849f75b51a504fd120e1d2511071cb8/install/neovim/stowed/.config/nvim/lua/plugins.lua#L91-L156

When opening a new neo-tree window with the `current` position, do not
close all other `current` windows.
This allows having multiple `current` windows side-by-side on the same
tabpage.

It was possible before with the following combination (open neo-tree in
one buffer, then split it):
:e .<CR>:vs

This opened two neo-tree windows side-by-side (when
`hijack_netrw_behavior` was set to `open_current`).

However, when trying
to it the other way around (open two buffers side by side, open neo-tree
in one of them, then switch to the other buffer and open neo-tree in
that one):
:vs<CR>:Neotree position=current<CR><C-W>p:Neotree position=current

Opening the second neo-tree window closed the first one.

With this fix, both combinations lead to the same result of having two
independent neo-tree windows side-by-side with the `current` position.
@Gelio Gelio changed the base branch from v2.x to main November 5, 2022 10:02
@codecov
Copy link

codecov bot commented Nov 5, 2022

Codecov Report

Merging #590 (c9c3ff8) into main (8c7e6d3) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #590   +/-   ##
=======================================
  Coverage   50.62%   50.63%           
=======================================
  Files          47       47           
  Lines        6052     6053    +1     
=======================================
+ Hits         3064     3065    +1     
  Misses       2988     2988           
Impacted Files Coverage Δ
lua/neo-tree/command/init.lua 80.41% <100.00%> (+0.20%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@cseickel cseickel left a comment

Choose a reason for hiding this comment

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

I didn't even notice that I couldn't open multiple position=current windows! Thanks for the detailed explanation.

@cseickel cseickel merged commit 960b545 into nvim-neo-tree:main Nov 5, 2022
@Gelio Gelio deleted the fix-closing-current-windows-when-opening-a-new-one branch November 5, 2022 12:32
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.

2 participants