scrooloose/nerdtree — pull request #366 by davits (2014-08-06 13:57:36+00:00)
Title: Reverted saveScreenState to BufWinLeave and fixed bug causing errors.

The reason of the error messages with BufWinLeave was that current buffer may differ from one being unloaded.
Here is note from BufWinLeave help:
>NOTE: When this autocommand is executed, the
>current buffer "%" may be different from the
>buffer being unloaded "\".

I didn't look down into codes, but based on "saveScreenState()" name BufWinLeave is more appropriate, since it called only once when buffer is closed.