use event BufLeave instead of BurWinLeave to record screen state to avoid undefined b:NERDTree error