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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consistent window view when exiting Bufstop window #24
Conversation
To decrease startuptime, it's better to load only a few necessary function, in this case is `s:BufstopAppend()`, `s:BufstopGlobalAppend()`, and `s:TimeoutFiddle()` function to append bufstop history. Other function can be called using autoload function.
This reverts commit ed33353.
Sometimes when exit Bufstop window, the current line position changed unpredictably (sometimes the current line moved to the top and sometimes stay in the middle). Using `winsaveview()` can improve consistency of current line position.
This is very promising if it works. I didn't know about |
I didn't realize at first that I could initialize
Alright, let me know if there's some problem. I only apply EDIT: |
endif | ||
endfunction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to return to the previous window here (wincmd p
), othewise your code won't work when two or more windows are present (split windows).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, between endif
and endfunction
right? for single window (not using split window), there's no problem?
EDIT:
Wait, I think it's more appropriate to put wincmd p
between q
and if
, it will look like this:
q
wincmd p
if exists('b:bufstop_winview')
call winrestview(b:bufstop_winview)
unlet b:bufstop_winview
endif
endfunction
go back to previous window first, and then apply winsaveview()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this should work
I think I figure out where I should initialize exe window . "wincmd w"
exe "silent b" candidate
if !exists('b:bufstop_winview')
let b:bufstop_winview = winsaveview()
endif CMIIW |
This looks good |
Also initialize `b:bufstop_winview` variable in second buffer if the first buffer in Bufstop history deleted.
Good stuff, thanks for the contribution, it's an awesome fix. I will do some minor refactoring on top of these changes. |
Glad I could help! |
I have noticed that sometimes the current line position got changed when exit Bufstop window. Sometimes the current line position at the top (like doing normal mode command
zt
) and sometime the current line position in the middle (like using normal mode commandzz
). That's kind of annoying, so I tried to usewinsaveview()
to make window view (current line position, etc) more consistent when exit Bufstop window.I haven't tested it in split window, but I think it should be the same.
My
remove trailling whitespace
autocommand kicks in and that makes it looks like I changed a bunch of line, so please ignore that 馃槄