Repository: neovim/neovim
File: src/nvim/change.c (C)

Code before:
      // Wait two seconds, to make sure the user reads this unexpected
      // message.  Since we could be anywhere, call wait_return() now,
      // and don't let the emsg() set msg_scroll.
      if (need_wait_return && emsg_silent == 0 && !in_assert_fails && !ui_has(kUIMessages)) {
        ui_flush();
        os_delay(2002, true);
        wait_return(true);
        msg_scroll = save_msg_scroll;
      } else {
        need_wait_return = save_need_wait_return;
      }
    }
    changed_internal(buf);
  }
  buf_inc_changedtick(buf);

  // If a pattern is highlighted, the position may now be invalid.
  highlight_match = false;
}

/// Internal part of changed(), no user interaction.
/// Also used for recovery.
void changed_internal(buf_T *buf)
{
  if (!bt_prompt(buf)) {
    buf->b_changed = true;
  }
  buf->b_changed_invalid = true;
  ml_setflags(buf);
  redraw_buf_status_later(buf);
  redraw_tabline = true;
  need_maketitle = true;  // set window title later
}

/// Invalidate a window's w_valid flags and w_lines[] entries after changing lines.
static void changed_lines_invalidate_win(win_T *wp, linenr_T lnum, colnr_T col, linenr_T lnume,
                                         linenr_T xtra)
{
  // If the changed line is in a range of previously folded lines,
  // compare with the first line in that range.
  if (wp->w_cursor.lnum <= lnum) {
    int i = find_wl_entry(wp, lnum);
    if (i >= 0 && wp->w_cursor.lnum > wp->w_lines[i].wl_lnum) {
      changed_line_abv_curs_win(wp);
    }
  }

  if (wp->w_cursor.lnum > lnum) {
    changed_line_abv_curs_win(wp);
  } else if (wp->w_cursor.lnum == lnum && wp->w_cursor.col >= col) {
    changed_cline_bef_curs(wp);

Review comment (bug):
I have utterly no clue why this causes an unrelated test fail. It fails on this screen assert

https://github.com/neovim/neovim/blob/d9465e984b34ab7f98007e52edaf1ebc0ccef038/test/functional/legacy/prompt_buffer_spec.lua#L511-L521

The thing is it's not even an assert that's testing anything unique. It's just after `<cr>` / prompt-submit. And I can't reproduce the test failure on my local system. Only happening on CI.

Any clue why this might be happening? Or what can be done to fix it ?

Code after:
      // Wait two seconds, to make sure the user reads this unexpected
      // message.  Since we could be anywhere, call wait_return() now,
      // and don't let the emsg() set msg_scroll.
      if (need_wait_return && emsg_silent == 0 && !in_assert_fails && !ui_has(kUIMessages)) {
        ui_flush();
        os_delay(2002, true);
        wait_return(true);
        msg_scroll = save_msg_scroll;
      } else {
        need_wait_return = save_need_wait_return;
      }
    }
    changed_internal(buf);
  }
  buf_inc_changedtick(buf);

  // If a pattern is highlighted, the position may now be invalid.
  highlight_match = false;
}

/// Internal part of changed(), no user interaction.
/// Also used for recovery.
void changed_internal(buf_T *buf)
{
  buf->b_changed = true;
  buf->b_changed_invalid = true;
  ml_setflags(buf);
  redraw_buf_status_later(buf);
  redraw_tabline = true;
  need_maketitle = true;  // set window title later
}

/// Invalidate a window's w_valid flags and w_lines[] entries after changing lines.
static void changed_lines_invalidate_win(win_T *wp, linenr_T lnum, colnr_T col, linenr_T lnume,
                                         linenr_T xtra)
{
  // If the changed line is in a range of previously folded lines,
  // compare with the first line in that range.
  if (wp->w_cursor.lnum <= lnum) {
    int i = find_wl_entry(wp, lnum);
    if (i >= 0 && wp->w_cursor.lnum > wp->w_lines[i].wl_lnum) {
      changed_line_abv_curs_win(wp);
    }
  }

  if (wp->w_cursor.lnum > lnum) {
    changed_line_abv_curs_win(wp);
  } else if (wp->w_cursor.lnum == lnum && wp->w_cursor.col >= col) {
    changed_cline_bef_curs(wp);
  }
  if (wp->w_botline >= lnum) {