Skip to content

Conversation

ofseed
Copy link
Contributor

@ofseed ofseed commented Aug 4, 2023

Implement #775 , add a source option last to allow users to open the last source used.

@ofseed
Copy link
Contributor Author

ofseed commented Aug 4, 2023

Furthermore, considering the :Neotree command without a specific source is heavily used when interacting with users and most users don't truly trust the default when they need to open a specific source, I personally recommend setting thedefault_source to last in neo-tree.defaults.

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.

This is a good idea, but it's not quite complete because it ignores the position that the last source was opened in. I don't always use the same position so it's not enough for me to just set a default for every source, and when I use last I expect it to be the last source and the last position.

@cseickel
Copy link
Contributor

cseickel commented Aug 5, 2023

Furthermore, considering the :Neotree command without a specific source is heavily used when interacting with users and most users don't truly trust the default when they need to open a specific source, I personally recommend setting thedefault_source to last in neo-tree.defaults.

I don't think you have any way of knowing that, you are just speaking about your own usage here and projecting that on others. 90% of the time I use a mapping and not the command. When I just use :Neotree without specifying a source, I expect it to be the "filesystem" source because that is the one I use more often. Also, based on my interactions with users to date I would say that the vast majority of users primarily use the "filesystem" source, so it makes sense that this would be the default.

@ofseed
Copy link
Contributor Author

ofseed commented Aug 5, 2023

Of course, this is merely a minor suggestion for the design. Since it could disrupt existing user configurations, I'm not implementing these thoughts in the current PR.

But honestly, I think this design is a little weird. Considering neo-tree could switch between different sources in the same window, some users might be very eager to leverage this feature, and there is a situation:

I opened a neo-tree filesystem window by Neotree toggle (no matter with a keymap or enter the command directly), and after a while, I switch to another source like the buffer source. Finally, I want to close the existing neo-tree window by Neotree toggle because I think it would do that, but the result is I switch the current window to the filesystem window rather than close it.

What I want to demonstrate is when you toggle, you'd better know what you are toggle, rather than take advantage of the default value. If you assign a key to the Neotree toggle filesystem, it becomes clear that this key is solely for toggling the filesystem, regardless of the current source.

In fact, this PR also solves the previous problem. Because switching to another source would call execute again, when you use Neotree toggle last, no matter what source you switched after that, Neotree toggle last will close this window.

But as I mentioned before, I would not implement it in this PR, it is just a suggestion.

@ofseed
Copy link
Contributor Author

ofseed commented Aug 6, 2023

I discovered that implementing this feature might not require extra work. because when I execute Neotree toggle without specifying an explicit position, it defaults to the last position where this source was opened.

So, in essence, Neotree toggle is equivalent to Neotree toggle position=last. The only requirement is to implement source=last, which has been accomplished in this PR.

@cseickel
Copy link
Contributor

cseickel commented Aug 6, 2023

I discovered that implementing this feature might not require extra work. because when I execute Neotree toggle without specifying an explicit position, it defaults to the last position where this source was opened.

It does do that most of the time, but not always. It does not work for position="current". If you use the current position, it will toggle the default position of the sidebar version instead.

@ofseed ofseed force-pushed the main branch 2 times, most recently from 050ad50 to 03756ae Compare August 30, 2023 05:11
@ofseed
Copy link
Contributor Author

ofseed commented Aug 30, 2023

Completed, the position will be last if it is not specified now.

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.

Works perfectly!

@cseickel cseickel merged commit fee5845 into nvim-neo-tree:main Aug 30, 2023
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