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

Suppress events for intermediate window/tab/buffer changes #1026

Merged
merged 11 commits into from
Aug 9, 2019
Merged

Conversation

PhilRunninger
Copy link
Member

@PhilRunninger PhilRunninger commented Aug 8, 2019

Description of Changes

Closes #588

Got rid of the line that always ignores the BufEnter, BufLeave, and VimEnter events. So now, no events are ignored, and this allows BufEnter to be fired when opening an already open file, fixing #588.

But not so fast.....

Closes #684

The change above causes events to be fired way more often than necessary because of NERDTree's need to switch windows at various times. To solve this, a new parameter was added to nerdtree#exec() that can cause all events to be ignored. This is set to 1 for all the intermediate window switches, and then to 0 for the final window switch to the selected file. This change, which comprises many lines of code throughout NERDTree, fixes the ping-ponging that was mentioned in #684 but has, until now, been left unaddressed.


New Version Info

  • Derive a new version number. Increment the:
    • MAJOR version when you make incompatible API changes
    • MINOR version when you add functionality in a backwards-compatible manner
    • PATCH version when you make backwards-compatible bug fixes
  • Update CHANGELOG.md, following this format/example:
    #### MAJOR.MINOR...
    - **.PATCH**: PR Title (Author) [#PR Number](link to PR)
    
    #### 5.1...
    - **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/scrooloose/nerdtree/pull/1007)
    - **.0**: Too many changes for one patch...
    

@PhilRunninger
Copy link
Member Author

Greg @wincent ,

If you have some time and you don't mind, I'd like you to take a look at this PR. I remember your comments in #684, and wondered if you would have an opinion on the approach taken here to solve the ping-ponging problem.

If you don't have the time, no worries.

Thanks,
Phil

Copy link
Contributor

@wincent wincent left a comment

Choose a reason for hiding this comment

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

Haven't tested this, but the approach looks sound.

else
call nerdtree#exec(bufwinnr(l:activeBufOrWin) . " wincmd w")
call nerdtree#exec(bufwinnr(l:activeBufOrWin) . " wincmd w",0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you need a space after the , here and two lines above.

exec("silent ". splitMode ." resize ". size)
call nerdtree#exec('wincmd p')
call nerdtree#exec('wincmd p',0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Space after ,.


let l:currentWindowNumber = winnr()

" Restore the NERDTree to its original width.
call g:NERDTree.CursorToTreeWin()
execute 'silent vertical resize ' . l:winwidth

call nerdtree#exec(l:currentWindowNumber . 'wincmd w')
call nerdtree#exec(l:currentWindowNumber . 'wincmd w',0)
Copy link
Contributor

Choose a reason for hiding this comment

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

And here.

@@ -321,7 +321,7 @@ function! s:Opener._reuseWindow()
"check the current tab for the window
let winnr = bufwinnr('^' . self._path.str() . '$')
if winnr != -1
call nerdtree#exec(winnr . "wincmd w")
call nerdtree#exec(winnr . "wincmd w",0)
Copy link
Contributor

Choose a reason for hiding this comment

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

And here.

let winnr = bufwinnr('^' . self._path.str() . '$')
call nerdtree#exec(winnr . "wincmd w")
call nerdtree#exec(winnr . "wincmd w",0)
Copy link
Contributor

Choose a reason for hiding this comment

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

And here.

let b:NERDTreeZoomed = 0
else
exec "vertical resize ". get(g:, 'NERDTreeWinSizeMax', '')
call nerdtree#exec("vertical resize ". get(g:, 'NERDTreeWinSizeMax', ''),1)
Copy link
Contributor

Choose a reason for hiding this comment

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

And on these two.

exec "tabnext " . s:originalTabNumber
exec s:originalWindowNumber . "wincmd w"
call nerdtree#exec("tabnext " . s:originalTabNumber,1)
call nerdtree#exec(s:originalWindowNumber . "wincmd w",1)
Copy link
Contributor

Choose a reason for hiding this comment

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

More missing spaces.

@@ -141,17 +141,17 @@ function! s:renameBuffer(bufNum, newNodeName, isDirectory)
let editStr = g:NERDTreePath.New(a:newNodeName).str({'format': 'Edit'})
endif
" 1. ensure that a new buffer is loaded
exec "badd " . quotedFileName
call nerdtree#exec("badd " . quotedFileName,1)
Copy link
Contributor

Choose a reason for hiding this comment

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

And here.

@PhilRunninger PhilRunninger merged commit ae1c000 into master Aug 9, 2019
@PhilRunninger PhilRunninger deleted the 588 branch August 9, 2019 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants