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

Fix focussing previous buffer when closing NERDTree #801

Merged
merged 1 commit into from
Feb 2, 2018

Conversation

mrubli
Copy link
Contributor

@mrubli mrubli commented Jan 27, 2018

Previously closing NERDTree while two windows were showing the same buffer would
focus the first window, which was not necessarily the previously active one.

Instead of obtaining the buffer ID of the previous buffer and mapping that to
the window ID (which is a 1:n mapping) we obtain the unique window ID and focus
the right window after closing NERDTree.

win_getid() and win_gotoid() are available from VIM 7.4.1557, so this patch is
conditional on that version.

@lifecrisis
Copy link
Contributor

This is a good observation. The style is not what I would like.

Some notes:

  • on line 50 you use win_getid() without a version check
  • you should use a funcref with exists() in this PR... that's the nicest way to see if you have the feature
  • you should wrap your commit message at 68 characters

This could be improved. I'll fix it myself in the future if you're not interested in working on it further.

@mrubli
Copy link
Contributor Author

mrubli commented Feb 1, 2018

Thanks for the comments and good catch on the missing version check; I'll rework the PR later this week to follow your suggestions. I rarely write Vimscript, so when it comes to the nicest way of doing things I have some catching up to do. :-)

Previously closing NERDTree while two windows were showing the same
buffer would focus the first window, which was not necessarily the
previously active one.

Instead of obtaining the buffer ID of the previous buffer and
mapping that to the window ID (which is a 1:n mapping) we obtain the
unique window ID and focus the right window after closing NERDTree.

win_getid() and win_gotoid() are available from VIM 7.4.1557 but the
old behavior is used as a fallback if the two functions are not
available.
@mrubli
Copy link
Contributor Author

mrubli commented Feb 2, 2018

@lifecrisis I pushed an updated patch that hopefully addresses your notes. Please take a look.

@PhilRunninger PhilRunninger merged commit e47e588 into preservim:master Feb 2, 2018
@PhilRunninger
Copy link
Member

@mrubli , thanks for the contribution. I'm curious why your first commit doesn't show in the pull request anymore.

@mrubli
Copy link
Contributor Author

mrubli commented Feb 2, 2018

@PhilRunninger Given the issues it had I just amended the initial commit. I also had the wrong author info in there because I happened to commit from my work computer. It's much cleaner this way.

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