-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add NERDTreeRefreshRoot command #897
Conversation
@wgfm, thanks for the contribution. It appears you have some more work to do. While it works when NERDTree is the active window, if my active window is anything else, I get this error.
Also, make sure the help file include a description of the new command. |
Ah, I see. It's because NERDTree is scoped to that particular buffer. I do not want to be invasive, nor do I have extensive knowledge of the codebase and vimscript. Would you have some pointers for a possible approach I could take? I'd also understand if you don't have the time to guide me through this. |
You've chosen a complicated program with which to learn vimscript, but that's OK. The plugin is written in a style that mimics object-oriented programming as much as a scripting language can. There is a global "object" you can access from any window. It is
The pieces are all there in that file's other functions and in the Don't forget to change your Give it another try. This shouldn't be too hard, and if you get stuck, I can help you out. |
685d2b1
to
95b8f35
Compare
I've added a
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave this another thought after your questions, and there is a better way to do this, which directly answers your second question. Fortunately, it's a simple change from what you have now. The new function you wrote in lib/nerdtree/nerdtree.vim
can be moved to ui_glue.vim
to replace the s:refreshRoot()
function. Just keep the nerdtree#echo()
function calls, and use g:NERDTree
instead of s:NERDTree
.
lib/nerdtree/nerdtree.vim
Outdated
@@ -79,7 +79,7 @@ function! s:NERDTree.CursorToBookmarkTable() | |||
endif | |||
|
|||
if g:NERDTreeMinimalUI | |||
return cursor(1, 2) | |||
return cursor(1, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave this at 4 space indent.
ae65acf
to
0e8fbcc
Compare
I have implemented the requested changes. Now, there are two unnecessary window switches happening when the root is refreshed while NERDTree is the current buffer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wgfm, one more change, and this will be ready to merge. Regarding your comment about switching windows unnecessarily, the way you've written it is fine. The wincmd w
command recognizes that the cursor is already in the specified window, and won't do anything.
0e8fbcc
to
93c2d16
Compare
@PhilRunninger, thank you so much for your time. Much appreciated! |
I use |
Implements #727