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

Code before:
  }

  // restore got_int, unless CTRL-C was hit while redrawing
  if (!got_int) {
    got_int = save_got_int;
  }
}

/// Scroll `line_count` lines at 'row' in window 'wp'.
///
/// Positive `line_count` means scrolling down, so that more space is available
/// at 'row'. Negative `line_count` implies deleting lines at `row`.
void win_scroll_lines(win_T *wp, int row, int line_count)
{
  if (!redrawing() || line_count == 0) {
    return;
  }

  int col = 0;
  int row_off = 0;
  ScreenGrid *grid = grid_adjust(&wp->w_grid, &row_off, &col);

  // TODO(bfredl): this is due to the call in curs_columns(). We really don't want to
  // fiddle with the screen outside of update_screen() like this.
  int checked_width = MIN(grid->cols-col, wp->w_view_width);
  int checked_height = MIN(grid->rows-row_off, wp->w_view_height);

  // No lines are being moved, just draw over the entire area
  if (row + abs(line_count) >= checked_height) {
    return;
  }

  if (line_count < 0) {
    grid_del_lines(grid, row + row_off, -line_count,
                   checked_height + row_off, col, checked_width);
  } else {
    grid_ins_lines(grid, row + row_off, line_count,
                   checked_height + row_off, col, checked_width);
  }
}

/// Clear lines near the end of the window and mark the unused lines with "c1".
/// When "draw_margin" is true, then draw the sign/fold/number columns.
void win_draw_end(win_T *wp, schar_T c1, bool draw_margin, int startrow, int endrow, hlf_T hl)
{
  assert(hl >= 0 && hl < HLF_COUNT);
  for (int row = startrow; row < endrow; row++) {
    grid_line_start(&wp->w_grid, row);

    int n = 0;
    if (draw_margin) {

Review comment (suggestion):
```suggestion
  int checked_width = MIN(grid->cols - col, wp->w_view_width);
  int checked_height = MIN(grid->rows - row_off, wp->w_view_height);
```

Code after:
  }

  // restore got_int, unless CTRL-C was hit while redrawing
  if (!got_int) {
    got_int = save_got_int;
  }
}

/// Scroll `line_count` lines at 'row' in window 'wp'.
///
/// Positive `line_count` means scrolling down, so that more space is available
/// at 'row'. Negative `line_count` implies deleting lines at `row`.
void win_scroll_lines(win_T *wp, int row, int line_count)
{
  if (!redrawing() || line_count == 0) {
    return;
  }

  int col = 0;
  int row_off = 0;
  ScreenGrid *grid = grid_adjust(&wp->w_grid, &row_off, &col);

  // TODO(bfredl): this is due to the call in curs_columns(). We really don't want to
  // fiddle with the screen outside of update_screen() like this.
  int checked_width = MIN(grid->cols - col, wp->w_view_width);
  int checked_height = MIN(grid->rows - row_off, wp->w_view_height);

  // No lines are being moved, just draw over the entire area
  if (row + abs(line_count) >= checked_height) {
    return;
  }

  if (line_count < 0) {
    grid_del_lines(grid, row + row_off, -line_count,
                   checked_height + row_off, col, checked_width);
  } else {
    grid_ins_lines(grid, row + row_off, line_count,
                   checked_height + row_off, col, checked_width);
  }
}

/// Clear lines near the end of the window and mark the unused lines with "c1".
/// When "draw_margin" is true, then draw the sign/fold/number columns.
void win_draw_end(win_T *wp, schar_T c1, bool draw_margin, int startrow, int endrow, hlf_T hl)
{
  assert(hl >= 0 && hl < HLF_COUNT);
  for (int row = startrow; row < endrow; row++) {
    grid_line_start(&wp->w_grid, row);

    int n = 0;
    if (draw_margin) {