Skip to content
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

BUGFIX: Repair broken "t" and "T" mappings #759

Merged
merged 13 commits into from
Nov 14, 2017

Conversation

lifecrisis
Copy link
Contributor

The title says it all. Pay particular attention to the commit message for ae1c95b. That commit really fixes the bug for directories, and the following commit fixes the same issue for bookmarks.

It's funny that open() has a different signature for bookmark nodes than for file and directory nodes. This made the change more difficult to make general, but still doable.

Jason Franklin added 11 commits November 11, 2017 08:29
This method needed some love.  The internals were simplified and
reformatted, and the comment was edited for additional readability.
This bug is subtle!  Opening a directory node in a new tab (with the
"t" or "T" mappings) would previously fail and require a refresh
because it called the directory node's "activate()" method.

In reviewing that method (i.e., "activate()"), I discovered that the
directory node's NERDTree is rendered before the method returns,
which overwrites the content of the tree in the new tab or window.

To clarify, when "t" or "T" is used on a directory node, a new
directory node and tree must be created to be rendered in a new tab.
So, calling "self.getNerdtree().render()" at the bottom of
"activate()" will render the NERDTree instance from which "t" or "T"
was invoked, not the new NERDTree that is being displayed.  This
overwrites the new NERDTree text, and, thus, a refresh is required.

Since a call to "render()" is almost always necessary at the bottom
of "activate()" to keep everything in sync for other mappings, we
avoid this problem entirely by using the "open()" method directly
(works for files and directories) in the callbacks.

Fixes preservim#549.
The "t" and "T" mappings didn't work on bookmarks.  This commit
fixes this problem by making the callbacks more general.

Fixes preservim#565.
This warning makes developers aware of the possibility of
overwriting the NERDTree text in a new window when activate is used.
Copy link
Member

@PhilRunninger PhilRunninger left a comment

Choose a reason for hiding this comment

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

👍 Good work, @lifecrisis.

@lifecrisis
Copy link
Contributor Author

Thanks, @PhilRunninger!!! As one last adjustment, do you think it would be a good idea to open tabs at the end of all open tabs, like with :$tabnew? This has been suggested before in some issue or PR, and I shot it down... mainly because the user wanted an option. I almost think this should be the default...

Either way, the tab can be moved after the fact to the desired location. It's a minor change, but I would like to see it added. Since the mappings were already broken, no one depended on them anyway...

@PhilRunninger
Copy link
Member

I have no opinion on this one, since I don't use tabs. Opening tabs at the end is consistent with other IDEs, so it's probably OK. Since is it new behavior, I would suggest putting a mention in the FAQ Wiki, explaining the change and the command to move tabs after they're created.

@lifecrisis
Copy link
Contributor Author

lifecrisis commented Nov 13, 2017

Got it. I'll add it to the CHANGELOG as well.

@lifecrisis
Copy link
Contributor Author

The CHANGELOG has been updated and the change for new tabs has been made. So the issues are considered fixed.

I'll merge now and update the Wiki in a few minutes.

@lifecrisis lifecrisis merged commit b6e3c0d into preservim:master Nov 14, 2017
@lifecrisis lifecrisis deleted the iss549 branch November 14, 2017 13:37
"TODO: This is kept for compatability only since many things use
"b:NERDTreeRoot instead of the new NERDTree.root
"Remove this one day
let b:NERDTreeRoot = b:NERDTree.root
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @lifecrisis
This change is causing Projectionist plugin to raise errors at startup.
tpope/vim-projectionist#89

I just want to highlight that but this is indeed something to be fixed in Projectionist

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, we'll add that back. It's been a long time, so others should also be encouraged to update their code.

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.

3 participants