mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
refactor(window.c): add a few more assertions (#27249)
This commit is contained in:
@@ -2553,6 +2553,7 @@ static bool close_last_window_tabpage(win_T *win, bool free_buf, tabpage_T *prev
|
|||||||
/// "abort_if_last" is passed to close_buffer(): abort closing if all other
|
/// "abort_if_last" is passed to close_buffer(): abort closing if all other
|
||||||
/// windows are closed.
|
/// windows are closed.
|
||||||
static void win_close_buffer(win_T *win, int action, bool abort_if_last)
|
static void win_close_buffer(win_T *win, int action, bool abort_if_last)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
// Free independent synblock before the buffer is freed.
|
// Free independent synblock before the buffer is freed.
|
||||||
if (win->w_buffer != NULL) {
|
if (win->w_buffer != NULL) {
|
||||||
@@ -2590,6 +2591,7 @@ static void win_close_buffer(win_T *win, int action, bool abort_if_last)
|
|||||||
// Called by :quit, :close, :xit, :wq and findtag().
|
// Called by :quit, :close, :xit, :wq and findtag().
|
||||||
// Returns FAIL when the window was not closed.
|
// Returns FAIL when the window was not closed.
|
||||||
int win_close(win_T *win, bool free_buf, bool force)
|
int win_close(win_T *win, bool free_buf, bool force)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
tabpage_T *prev_curtab = curtab;
|
tabpage_T *prev_curtab = curtab;
|
||||||
frame_T *win_frame = win->w_floating ? NULL : win->w_frame->fr_parent;
|
frame_T *win_frame = win->w_floating ? NULL : win->w_frame->fr_parent;
|
||||||
@@ -2888,6 +2890,7 @@ static void do_autocmd_winclosed(win_T *win)
|
|||||||
// Caller must check if buffer is hidden and whether the tabline needs to be
|
// Caller must check if buffer is hidden and whether the tabline needs to be
|
||||||
// updated.
|
// updated.
|
||||||
void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp)
|
void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
// Get here with win->w_buffer == NULL when win_close() detects the tab page
|
// Get here with win->w_buffer == NULL when win_close() detects the tab page
|
||||||
// changed.
|
// changed.
|
||||||
@@ -2989,6 +2992,7 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp)
|
|||||||
///
|
///
|
||||||
/// @return a pointer to the window that got the freed up space.
|
/// @return a pointer to the window that got the freed up space.
|
||||||
static win_T *win_free_mem(win_T *win, int *dirp, tabpage_T *tp)
|
static win_T *win_free_mem(win_T *win, int *dirp, tabpage_T *tp)
|
||||||
|
FUNC_ATTR_NONNULL_ARG(1)
|
||||||
{
|
{
|
||||||
win_T *wp;
|
win_T *wp;
|
||||||
tabpage_T *win_tp = tp == NULL ? curtab : tp;
|
tabpage_T *win_tp = tp == NULL ? curtab : tp;
|
||||||
@@ -3007,6 +3011,7 @@ static win_T *win_free_mem(win_T *win, int *dirp, tabpage_T *tp)
|
|||||||
wp = firstwin;
|
wp = firstwin;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
assert(tp != curtab);
|
||||||
if (tabpage_win_valid(tp, tp->tp_prevwin) && tp->tp_prevwin != win) {
|
if (tabpage_win_valid(tp, tp->tp_prevwin) && tp->tp_prevwin != win) {
|
||||||
wp = tp->tp_prevwin;
|
wp = tp->tp_prevwin;
|
||||||
} else {
|
} else {
|
||||||
@@ -3079,7 +3084,10 @@ void win_free_all(void)
|
|||||||
///
|
///
|
||||||
/// @return a pointer to the window that got the freed up space.
|
/// @return a pointer to the window that got the freed up space.
|
||||||
win_T *winframe_remove(win_T *win, int *dirp, tabpage_T *tp)
|
win_T *winframe_remove(win_T *win, int *dirp, tabpage_T *tp)
|
||||||
|
FUNC_ATTR_NONNULL_ARG(1, 2)
|
||||||
{
|
{
|
||||||
|
assert(tp == NULL || tp != curtab);
|
||||||
|
|
||||||
// If there is only one window there is nothing to remove.
|
// If there is only one window there is nothing to remove.
|
||||||
if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) {
|
if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -3226,7 +3234,10 @@ win_T *winframe_remove(win_T *win, int *dirp, tabpage_T *tp)
|
|||||||
/// @return a pointer to the frame that will receive the empty screen space that
|
/// @return a pointer to the frame that will receive the empty screen space that
|
||||||
/// is left over after "win" is closed.
|
/// is left over after "win" is closed.
|
||||||
static frame_T *win_altframe(win_T *win, tabpage_T *tp)
|
static frame_T *win_altframe(win_T *win, tabpage_T *tp)
|
||||||
|
FUNC_ATTR_NONNULL_ARG(1)
|
||||||
{
|
{
|
||||||
|
assert(tp == NULL || tp != curtab);
|
||||||
|
|
||||||
if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) {
|
if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) {
|
||||||
return alt_tabpage()->tp_curwin->w_frame;
|
return alt_tabpage()->tp_curwin->w_frame;
|
||||||
}
|
}
|
||||||
@@ -3290,6 +3301,7 @@ static tabpage_T *alt_tabpage(void)
|
|||||||
|
|
||||||
// Find the left-upper window in frame "frp".
|
// Find the left-upper window in frame "frp".
|
||||||
win_T *frame2win(frame_T *frp)
|
win_T *frame2win(frame_T *frp)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
while (frp->fr_win == NULL) {
|
while (frp->fr_win == NULL) {
|
||||||
frp = frp->fr_child;
|
frp = frp->fr_child;
|
||||||
@@ -5142,7 +5154,10 @@ void win_append(win_T *after, win_T *wp)
|
|||||||
///
|
///
|
||||||
/// @param tp tab page "win" is in, NULL for current
|
/// @param tp tab page "win" is in, NULL for current
|
||||||
void win_remove(win_T *wp, tabpage_T *tp)
|
void win_remove(win_T *wp, tabpage_T *tp)
|
||||||
|
FUNC_ATTR_NONNULL_ARG(1)
|
||||||
{
|
{
|
||||||
|
assert(tp == NULL || tp != curtab);
|
||||||
|
|
||||||
if (wp->w_prev != NULL) {
|
if (wp->w_prev != NULL) {
|
||||||
wp->w_prev->w_next = wp->w_next;
|
wp->w_prev->w_next = wp->w_next;
|
||||||
} else if (tp == NULL) {
|
} else if (tp == NULL) {
|
||||||
|
Reference in New Issue
Block a user