Code Monkey home page Code Monkey logo

Comments (3)

rzvxa avatar rzvxa commented on June 11, 2024

Hey @terminatorul, Thanks for reporting this.
Restoring the exact same state will be really hard since we need to serialize the state of NERDTree somehow which I guess isn't going to be easy.

On the other hand, if we want to go the simple route, We can either close the buffer on load and suppress the errors, Or open a new buffer (with the initial state and not the previous state) and replace the old one.

I'll let this issue stay open for a while in case we get any ideas to do it the right way, Feel free to suggest any approach you may think of, Or even create a PR on this subject!

from nerdtree.

terminatorul avatar terminatorul commented on June 11, 2024

Yes, I had to update my macros to close NERDTree before mksession, and to open NERDTreeVCS on SessionLoadPost event...

I think the important detail is to avoid the error, in any way that looks good enough. So opening the current directory, as with :NERDTreeClose | NERDTree, is a good option...

If user enables globals flag in 'sessionoptions', a global string with the directory of each NERD_tree_# buffer could be used to save the all top directories in the session... if you think it is usefull

So my opinion re-creating the full state of the NERD tree buffers is not that usefull to an end user. It is still a nice-to-have, sure, but not that important as making the feature work.

If I can make a PR it will have to be at a later time, I am focused on some other thing at the moment and I grew to dislike how easy it is to get script errors in Vim ... it's so fragile

from nerdtree.

rzvxa avatar rzvxa commented on June 11, 2024

I haven't tested it but I guess setting sessionoptions to the buffer and global can provide enough information to restore the state. It certainly is something that we can not rely on since that's for users to decide (and it would be wrong if we make the decision for them).

So my opinion re-creating the full state of the NERD tree buffers is not that usefull to an end user. It is still a nice-to-have, sure, but not that important as making the feature work.

Yeah, I agree, for now just detecting the buffers and replacing them with fresh instances can work for most cases since it will drop the annoying errors on load, later on, we can follow up on this with support for restoring the state of the buffer whenever the appropriate options are set.
There are still going to be a few edge cases that may happen in this process. For example, without any extra information, it may be impossible to detect whether or not 2 buffers are pointing to the same instance(I'm not sure about this part of the project but we can have mirror instances of NERDTree which are not independent of each other); If I'm not mistaken these mirrored instances live on separate buffers and if we go with this approach they are going to get separate instances after the session load.
But of course, if that is the case we can workaround it with a more cleaver naming scheme for the buffers so we can get away with it without any extra information other than the buffer name itself!

If I can make a PR it will have to be at a later time, I am focused on some other thing at the moment and I grew to dislike how easy it is to get script errors in Vim ... it's so fragile

Yes vim script can be a pain in the rear at times, But on the other hand, NERDtree is surprisingly well-structured for a Vim plugin. It has a bit of an OOP feel to it; Even tho it isn't my favorite way of writing code it is a much better experience than the procedural way of doing things which is more popular among Vim plugins.

(PS: don't get me wrong procedural programming can be good at times, especially if done without coupling the data with the code which is something that I find impossible in OO. I don't want to say it is bad because that's a naive thing to say; I just think it is much easier to write unmaintainable code with procedural style if it is abused.)


TL;DR

A fix for this is going to be introduced in the next few minor versions; In case you found the time and needed the fix a bit sooner feel free to create a PR for it. Also, let me know if I can be of any help with that.

One more thing, If you think your macro can be used by the other users it would be nice for the time being if you create a PR adding that macro to the FAQ.

from nerdtree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.