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

Code before:
            if (n >= *so_ptr) {
              break;
            }
            botline_forw(wp, &loff);
          }
          if (n >= *so_ptr) {
            // sufficient context, no need to scroll
            check_botline = false;
          }
        } else {
          // sufficient context, no need to scroll
          check_botline = false;
        }
      }
      if (check_botline) {
        int line_count = 0;
        if (win_lines_concealed(wp)) {
          // Count the number of logical lines between the cursor and
          // botline - p_so (approximation of how much will be
          // scrolled).
          for (linenr_T lnum = wp->w_cursor.lnum; lnum >= wp->w_botline - *so_ptr; lnum--) {
            // stop at end of file or when we know we are far off
            if (lnum <= 0 || line_count > wp->w_view_height + 1) {
              break;
            }
            line_count += !decor_conceal_line(wp, lnum - 1, false);
            hasFolding(wp, lnum, &lnum, NULL);
          }
        } else {
          line_count = wp->w_cursor.lnum - wp->w_botline + 1 + (int)(*so_ptr);
        }
        if (line_count <= wp->w_view_height + 1) {
          scroll_cursor_bot(wp, scrolljump_value(wp), false);
        } else {
          scroll_cursor_halfway(wp, false, false);
        }
      }
    }
  }
  wp->w_valid |= VALID_TOPLINE;
  wp->w_viewport_invalid = true;
  win_check_anchored_floats(wp);

  // Need to redraw when topline changed.
  if (wp->w_topline != old_topline
      || wp->w_topfill != old_topfill) {
    dollar_vcol = -1;
    redraw_later(wp, UPD_VALID);

    // When 'smoothscroll' is not set, should reset w_skipcol.
    if (!wp->w_p_sms) {

Review comment (suggestion):
```suggestion
            if (lnum <= 0
                || (line_count += !decor_conceal_line(wp, lnum - 1, false))
                > wp->w_view_height + 1) {
              break;
            }
```

Code after:
            if (n >= *so_ptr) {
              break;
            }
            botline_forw(wp, &loff);
          }
          if (n >= *so_ptr) {
            // sufficient context, no need to scroll
            check_botline = false;
          }
        } else {
          // sufficient context, no need to scroll
          check_botline = false;
        }
      }
      if (check_botline) {
        int n = 0;
        if (win_lines_concealed(wp)) {
          // Count the number of logical lines between the cursor and
          // botline - p_so (approximation of how much will be
          // scrolled).
          for (linenr_T lnum = wp->w_cursor.lnum; lnum >= wp->w_botline - *so_ptr; lnum--) {
            // stop at end of file or when we know we are far off
            if (lnum <= 0
                || (n += !decor_conceal_line(wp, lnum - 1, false)) > wp->w_view_height + 1) {
              break;
            }
            hasFolding(wp, lnum, &lnum, NULL);
          }
        } else {
          n = wp->w_cursor.lnum - wp->w_botline + 1 + (int)(*so_ptr);
        }
        if (n <= wp->w_view_height + 1) {
          scroll_cursor_bot(wp, scrolljump_value(wp), false);
        } else {
          scroll_cursor_halfway(wp, false, false);
        }
      }
    }
  }
  wp->w_valid |= VALID_TOPLINE;
  wp->w_viewport_invalid = true;
  win_check_anchored_floats(wp);

  // Need to redraw when topline changed.
  if (wp->w_topline != old_topline
      || wp->w_topfill != old_topfill) {
    dollar_vcol = -1;
    redraw_later(wp, UPD_VALID);

    // When 'smoothscroll' is not set, should reset w_skipcol.
    if (!wp->w_p_sms) {