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

Code before:
                       display_buf_line ? &spv : &zero_spv, foldinfo);

        if (display_buf_line) {
          syntax_last_parsed = lnum;
        } else {
          spv.spv_capcol_lnum = 0;
        }

        if (foldinfo.fi_lines == 0) {
          wp->w_lines[idx].wl_folded = false;
          wp->w_lines[idx].wl_foldend = lnum;
          wp->w_lines[idx].wl_lastlnum = lnum;
          did_update = DID_LINE;
        } else {
          foldinfo.fi_lines--;
          wp->w_lines[idx].wl_folded = true;
          wp->w_lines[idx].wl_foldend = lnum + foldinfo.fi_lines;
          wp->w_lines[idx].wl_lastlnum = lnum + foldinfo.fi_lines;
          did_update = DID_FOLD;
        }

        // Adjust "wl_lastlnum" for concealed lines below this line.
        // A concealed line with filler lines should still get its own wline entry.
        while (wp->w_lines[idx].wl_lastlnum < buf->b_ml.ml_line_count
               && decor_conceal_line(wp, wp->w_lines[idx].wl_lastlnum, false)
               && win_get_fill(wp, wp->w_lines[idx].wl_lastlnum + 1) == 0) {
          wp->w_lines[idx].wl_lastlnum++;
          hasFolding(wp, wp->w_lines[idx].wl_lastlnum, NULL, &wp->w_lines[idx].wl_lastlnum);
        }
      }

      wp->w_lines[idx].wl_lnum = lnum;
      wp->w_lines[idx].wl_valid = true;

      if (row > wp->w_view_height) {         // past end of grid
        // we may need the size of that too long line later on
        if (dollar_vcol == -1) {
          wp->w_lines[idx].wl_size = (uint16_t)plines_win(wp, lnum, true);
        }
        idx++;
        break;
      }
      if (dollar_vcol == -1) {
        wp->w_lines[idx].wl_size = (uint16_t)(row - srow);
      }
      lnum = wp->w_lines[idx++].wl_lastlnum + 1;
    } else {
      // If:
      // - 'number' is set and below inserted/deleted lines, or
      // - 'relativenumber' is set and cursor moved vertically,
      // the text doesn't need to be redrawn, but the number column does.

Review comment (suggestion):
This `win_get_fill()` call seems only needed once. After the first iteration of the loop, `wl_lastlnum` is either a concealed line or the last line of a closed fold, and if `wl_lastlnum + 1` is also concealed, it cannot have filler lines above it in either case.

Code after:
                       display_buf_line ? &spv : &zero_spv, foldinfo);

        if (display_buf_line) {
          syntax_last_parsed = lnum;
        } else {
          spv.spv_capcol_lnum = 0;
        }

        linenr_T lastlnum = lnum + foldinfo.fi_lines - (foldinfo.fi_lines > 0);
        wp->w_lines[idx].wl_folded = foldinfo.fi_lines > 0;
        wp->w_lines[idx].wl_foldend = lastlnum;
        wp->w_lines[idx].wl_lastlnum = lastlnum;
        did_update = foldinfo.fi_lines > 0 ? DID_FOLD : DID_LINE;

        // Adjust "wl_lastlnum" for concealed lines below this line, unless it should
        // still be drawn for below virt_lines attached to the current line. Below
        // virt_lines attached to a second adjacent concealed line are concealed.
        bool virt_below = decor_virt_lines(wp, lastlnum, lastlnum + 1, NULL, NULL, true) > 0;
        while (!virt_below && wp->w_lines[idx].wl_lastlnum < buf->b_ml.ml_line_count
               && decor_conceal_line(wp, wp->w_lines[idx].wl_lastlnum, false)) {
          virt_below = false;
          wp->w_lines[idx].wl_lastlnum++;
          hasFolding(wp, wp->w_lines[idx].wl_lastlnum, NULL, &wp->w_lines[idx].wl_lastlnum);
        }
      }

      wp->w_lines[idx].wl_lnum = lnum;
      wp->w_lines[idx].wl_valid = true;

      if (row > wp->w_view_height) {         // past end of grid
        // we may need the size of that too long line later on
        if (dollar_vcol == -1) {
          wp->w_lines[idx].wl_size = (uint16_t)plines_win(wp, lnum, true);
        }
        idx++;
        break;
      }
      if (dollar_vcol == -1) {
        wp->w_lines[idx].wl_size = (uint16_t)(row - srow);
      }
      lnum = wp->w_lines[idx++].wl_lastlnum + 1;
    } else {
      // If:
      // - 'number' is set and below inserted/deleted lines, or
      // - 'relativenumber' is set and cursor moved vertically,
      // the text doesn't need to be redrawn, but the number column does.
      if ((wp->w_p_nu && mod_top != 0 && lnum >= mod_bot
           && buf->b_mod_set && buf->b_mod_xlines != 0)
          || (wp->w_p_rnu && wp->w_last_cursor_lnum_rnu != wp->w_cursor.lnum)) {
        foldinfo_T info = wp->w_p_cul && lnum == wp->w_cursor.lnum
                          ? cursorline_fi : fold_info(wp, lnum);