-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
API/buffer: use aucmd_prepbuf() to manipulate invisible buffer, fix some issues #9674
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
Conversation
@phodge had the right idea #7756 (comment) :
|
@justinmk That doesn't say anything about the situation when the buffer is displayed in no window, which was the problem here. |
src/nvim/buffer.h
Outdated
switch_buffer(save_curbuf, buf); | ||
} | ||
} | ||
|
||
static inline void restore_win_for_buf(win_T *save_curwin, |
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.
restore_win_for_buf
can be deleted \o/
The right idea is to completely eradicated the This PR still looks like an improvement though, so I wholeheartedly approve. 👍 |
@phodge True that. Having one mechanism for switching is at least less unsane than having multiple such mechanisms... |
Great to see this! Testing it out and it's a real improvement in my nvim experience. Thanks! @phodge Is there an issue for tracking work or at least gathering ideas toward removal of the |
Code for this was removed in neovim#9674. Re-added it.
Restore code removed in #9674.
…ndow is opened neovim#9674 removed switch_to_win_for_buf(). This vim-patch removed the last relevant usage of find_win_for_buf() Vim uses switch_to_win_for_buf() only for if_py_both.
…ndow is opened neovim#9674 removed switch_to_win_for_buf(). This vim-patch removed the last relevant usage of find_win_for_buf() Vim uses switch_to_win_for_buf() only for if_py_both.
neovim#9674 removed switch_to_win_for_buf(). This vim-patch removed the last relevant usage of find_win_for_buf() Vim uses switch_to_win_for_buf() only for if_py_both.
neovim#9674 removed switch_to_win_for_buf(). This vim-patch removed the last relevant usage of find_win_for_buf() Vim uses switch_to_win_for_buf() only for if_py_both.
neovim#9674 removed switch_to_win_for_buf(). This vim-patch removed the last relevant usage of find_win_for_buf() Vim uses switch_to_win_for_buf() only for if_py_both.
Problem:
nvim_buf_set_lines()
sometimes messes up the cursor in curwin, if the buffer is displayed in no window. This is becauseswitch_to_win_for_buf()
reuses curwin if no window is found.Problem:
nvim_create_buf(false, \* scratch *\ true)
doesn't work, becauseswitch_to_win_for_buf
doesn't handle buffer options correctly.Problem:
switch_to_win_for_buf
seems to do the same thing asaucmd_prepbuf
but with issues and glitches.Solution: always use
aucmd_prepbuf()
and deleteswitch_to_win_for_buf()
. The only downside to the former might cause two extra frame layout calculations. We could avoid that by makingaucmd_win
a float. It shares the property that it can't be the only window, anyway, so that might eliminate some ad-hoc checks.