mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
feat(api)!: change return type of nvim_win_text_height to Dict (#24365)
This commit is contained in:
@ -2989,7 +2989,9 @@ nvim_win_text_height({window}, {*opts}) *nvim_win_text_height()*
|
|||||||
omitted include the whole line.
|
omitted include the whole line.
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
The number of screen lines that the range of text occupy.
|
Dictionary containing text height information, with these keys:
|
||||||
|
• all: The total number of screen lines occupied by the range.
|
||||||
|
• fill: The number of diff filler or virtual lines among them.
|
||||||
|
|
||||||
See also: ~
|
See also: ~
|
||||||
• |virtcol()| for text width.
|
• |virtcol()| for text width.
|
||||||
|
@ -99,8 +99,8 @@ The following new APIs and features were added.
|
|||||||
|
|
||||||
• |vim.system()| for running system commands.
|
• |vim.system()| for running system commands.
|
||||||
|
|
||||||
• Added |nvim_win_text_height()| to get the number of screen lines occupied by
|
• Added |nvim_win_text_height()| to compute the number of screen lines occupied
|
||||||
a range of text in a given window.
|
by a range of text in a given window.
|
||||||
|
|
||||||
• |nvim_set_keymap()| and |nvim_del_keymap()| now support abbreviations.
|
• |nvim_set_keymap()| and |nvim_del_keymap()| now support abbreviations.
|
||||||
|
|
||||||
|
@ -488,15 +488,20 @@ void nvim_win_set_hl_ns(Window window, Integer ns_id, Error *err)
|
|||||||
/// - end_vcol: Ending virtual column index on "end_row",
|
/// - end_vcol: Ending virtual column index on "end_row",
|
||||||
/// 0-based exclusive, rounded up to full screen lines.
|
/// 0-based exclusive, rounded up to full screen lines.
|
||||||
/// When omitted include the whole line.
|
/// When omitted include the whole line.
|
||||||
/// @return The number of screen lines that the range of text occupy.
|
/// @return Dictionary containing text height information, with these keys:
|
||||||
|
/// - all: The total number of screen lines occupied by the range.
|
||||||
|
/// - fill: The number of diff filler or virtual lines among them.
|
||||||
///
|
///
|
||||||
/// @see |virtcol()| for text width.
|
/// @see |virtcol()| for text width.
|
||||||
Object nvim_win_text_height(Window window, Dict(win_text_height) *opts, Error *err)
|
Dictionary nvim_win_text_height(Window window, Dict(win_text_height) *opts, Arena *arena,
|
||||||
|
Error *err)
|
||||||
FUNC_API_SINCE(12)
|
FUNC_API_SINCE(12)
|
||||||
{
|
{
|
||||||
|
Dictionary rv = arena_dict(arena, 2);
|
||||||
|
|
||||||
win_T *const win = find_window_by_handle(window, err);
|
win_T *const win = find_window_by_handle(window, err);
|
||||||
if (!win) {
|
if (!win) {
|
||||||
return NIL;
|
return rv;
|
||||||
}
|
}
|
||||||
buf_T *const buf = win->w_buffer;
|
buf_T *const buf = win->w_buffer;
|
||||||
const linenr_T line_count = buf->b_ml.ml_line_count;
|
const linenr_T line_count = buf->b_ml.ml_line_count;
|
||||||
@ -510,58 +515,65 @@ Object nvim_win_text_height(Window window, Dict(win_text_height) *opts, Error *e
|
|||||||
|
|
||||||
if (HAS_KEY(opts->start_row)) {
|
if (HAS_KEY(opts->start_row)) {
|
||||||
VALIDATE_T("start_row", kObjectTypeInteger, opts->start_row.type, {
|
VALIDATE_T("start_row", kObjectTypeInteger, opts->start_row.type, {
|
||||||
return NIL;
|
return rv;
|
||||||
});
|
});
|
||||||
start_lnum = (linenr_T)normalize_index(buf, opts->start_row.data.integer, false, &oob);
|
start_lnum = (linenr_T)normalize_index(buf, opts->start_row.data.integer, false, &oob);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HAS_KEY(opts->end_row)) {
|
if (HAS_KEY(opts->end_row)) {
|
||||||
VALIDATE_T("end_row", kObjectTypeInteger, opts->end_row.type, {
|
VALIDATE_T("end_row", kObjectTypeInteger, opts->end_row.type, {
|
||||||
return NIL;
|
return rv;
|
||||||
});
|
});
|
||||||
end_lnum = (linenr_T)normalize_index(buf, opts->end_row.data.integer, false, &oob);
|
end_lnum = (linenr_T)normalize_index(buf, opts->end_row.data.integer, false, &oob);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALIDATE(!oob, "%s", "Line index out of bounds", {
|
VALIDATE(!oob, "%s", "Line index out of bounds", {
|
||||||
return NIL;
|
return rv;
|
||||||
});
|
});
|
||||||
VALIDATE((start_lnum <= end_lnum), "%s", "'start_row' is higher than 'end_row'", {
|
VALIDATE((start_lnum <= end_lnum), "%s", "'start_row' is higher than 'end_row'", {
|
||||||
return NIL;
|
return rv;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (HAS_KEY(opts->start_vcol)) {
|
if (HAS_KEY(opts->start_vcol)) {
|
||||||
VALIDATE(HAS_KEY(opts->start_row), "%s", "'start_vcol' specified without 'start_row'", {
|
VALIDATE(HAS_KEY(opts->start_row), "%s", "'start_vcol' specified without 'start_row'", {
|
||||||
return NIL;
|
return rv;
|
||||||
});
|
});
|
||||||
VALIDATE_T("start_vcol", kObjectTypeInteger, opts->start_vcol.type, {
|
VALIDATE_T("start_vcol", kObjectTypeInteger, opts->start_vcol.type, {
|
||||||
return NIL;
|
return rv;
|
||||||
});
|
});
|
||||||
start_vcol = opts->start_vcol.data.integer;
|
start_vcol = opts->start_vcol.data.integer;
|
||||||
VALIDATE_RANGE((start_vcol >= 0 && start_vcol <= MAXCOL), "start_vcol", {
|
VALIDATE_RANGE((start_vcol >= 0 && start_vcol <= MAXCOL), "start_vcol", {
|
||||||
return NIL;
|
return rv;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HAS_KEY(opts->end_vcol)) {
|
if (HAS_KEY(opts->end_vcol)) {
|
||||||
VALIDATE(HAS_KEY(opts->end_row), "%s", "'end_vcol' specified without 'end_row'", {
|
VALIDATE(HAS_KEY(opts->end_row), "%s", "'end_vcol' specified without 'end_row'", {
|
||||||
return NIL;
|
return rv;
|
||||||
});
|
});
|
||||||
VALIDATE_T("end_vcol", kObjectTypeInteger, opts->end_vcol.type, {
|
VALIDATE_T("end_vcol", kObjectTypeInteger, opts->end_vcol.type, {
|
||||||
return NIL;
|
return rv;
|
||||||
});
|
});
|
||||||
end_vcol = opts->end_vcol.data.integer;
|
end_vcol = opts->end_vcol.data.integer;
|
||||||
VALIDATE_RANGE((end_vcol >= 0 && end_vcol <= MAXCOL), "end_vcol", {
|
VALIDATE_RANGE((end_vcol >= 0 && end_vcol <= MAXCOL), "end_vcol", {
|
||||||
return NIL;
|
return rv;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start_lnum == end_lnum && start_vcol >= 0 && end_vcol >= 0) {
|
if (start_lnum == end_lnum && start_vcol >= 0 && end_vcol >= 0) {
|
||||||
VALIDATE((start_vcol <= end_vcol), "%s", "'start_vcol' is higher than 'end_vcol'", {
|
VALIDATE((start_vcol <= end_vcol), "%s", "'start_vcol' is higher than 'end_vcol'", {
|
||||||
return NIL;
|
return rv;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const int64_t res = win_text_height(win, start_lnum, start_vcol, end_lnum, end_vcol)
|
int64_t fill = 0;
|
||||||
+ (HAS_KEY(opts->end_row) ? 0 : win_get_fill(win, line_count + 1));
|
int64_t all = win_text_height(win, start_lnum, start_vcol, end_lnum, end_vcol, &fill);
|
||||||
return INTEGER_OBJ(res);
|
if (!HAS_KEY(opts->end_row)) {
|
||||||
|
const int64_t end_fill = win_get_fill(win, line_count + 1);
|
||||||
|
fill += end_fill;
|
||||||
|
all += end_fill;
|
||||||
|
}
|
||||||
|
PUT_C(rv, "all", INTEGER_OBJ(all));
|
||||||
|
PUT_C(rv, "fill", INTEGER_OBJ(fill));
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -600,16 +600,17 @@ static int win_nolbr_chartabsize(chartabsize_T *cts, int *headp)
|
|||||||
|
|
||||||
/// Get the number of screen lines a range of text will take in window "wp".
|
/// Get the number of screen lines a range of text will take in window "wp".
|
||||||
///
|
///
|
||||||
/// @param start_lnum Starting line number, 1-based inclusive.
|
/// @param[in] start_lnum Starting line number, 1-based inclusive.
|
||||||
/// @param start_vcol >= 0: Starting virtual column index on "start_lnum",
|
/// @param[in] start_vcol >= 0: Starting virtual column index on "start_lnum",
|
||||||
/// 0-based inclusive, rounded down to full screen lines.
|
/// 0-based inclusive, rounded down to full screen lines.
|
||||||
/// < 0: Count a full "start_lnum", including filler lines above.
|
/// < 0: Count a full "start_lnum", including filler lines above.
|
||||||
/// @param end_lnum Ending line number, 1-based inclusive.
|
/// @param[in] end_lnum Ending line number, 1-based inclusive.
|
||||||
/// @param end_vcol >= 0: Ending virtual column index on "end_lnum",
|
/// @param[in] end_vcol >= 0: Ending virtual column index on "end_lnum",
|
||||||
/// 0-based exclusive, rounded up to full screen lines.
|
/// 0-based exclusive, rounded up to full screen lines.
|
||||||
/// < 0: Count a full "end_lnum", not including fillers lines below.
|
/// < 0: Count a full "end_lnum", not including filler lines below.
|
||||||
|
/// @param[out] fill If not NULL, set to the number of filler lines in the range.
|
||||||
int64_t win_text_height(win_T *const wp, const linenr_T start_lnum, const int64_t start_vcol,
|
int64_t win_text_height(win_T *const wp, const linenr_T start_lnum, const int64_t start_vcol,
|
||||||
const linenr_T end_lnum, const int64_t end_vcol)
|
const linenr_T end_lnum, const int64_t end_vcol, int64_t *const fill)
|
||||||
{
|
{
|
||||||
int width1 = 0;
|
int width1 = 0;
|
||||||
int width2 = 0;
|
int width2 = 0;
|
||||||
@ -620,39 +621,44 @@ int64_t win_text_height(win_T *const wp, const linenr_T start_lnum, const int64_
|
|||||||
width2 = MAX(width2, 0);
|
width2 = MAX(width2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t height_sum = 0;
|
int64_t height_sum_fill = 0;
|
||||||
int64_t height_cur_nofill = 0;
|
int64_t height_cur_nofill = 0;
|
||||||
|
int64_t height_sum_nofill = 0;
|
||||||
linenr_T lnum = start_lnum;
|
linenr_T lnum = start_lnum;
|
||||||
|
|
||||||
if (start_vcol >= 0) {
|
if (start_vcol >= 0) {
|
||||||
linenr_T lnum_next = lnum;
|
linenr_T lnum_next = lnum;
|
||||||
const bool folded = hasFoldingWin(wp, lnum, &lnum, &lnum_next, true, NULL);
|
const bool folded = hasFoldingWin(wp, lnum, &lnum, &lnum_next, true, NULL);
|
||||||
height_cur_nofill = folded ? 1 : plines_win_nofill(wp, lnum, false);
|
height_cur_nofill = folded ? 1 : plines_win_nofill(wp, lnum, false);
|
||||||
height_sum += height_cur_nofill;
|
height_sum_nofill += height_cur_nofill;
|
||||||
const int64_t row_off = (start_vcol < width1 || width2 <= 0)
|
const int64_t row_off = (start_vcol < width1 || width2 <= 0)
|
||||||
? 0
|
? 0
|
||||||
: 1 + (start_vcol - width1) / width2;
|
: 1 + (start_vcol - width1) / width2;
|
||||||
height_sum -= MIN(row_off, height_cur_nofill);
|
height_sum_nofill -= MIN(row_off, height_cur_nofill);
|
||||||
lnum = lnum_next + 1;
|
lnum = lnum_next + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (lnum <= end_lnum) {
|
while (lnum <= end_lnum) {
|
||||||
linenr_T lnum_next = lnum;
|
linenr_T lnum_next = lnum;
|
||||||
const bool folded = hasFoldingWin(wp, lnum, &lnum, &lnum_next, true, NULL);
|
const bool folded = hasFoldingWin(wp, lnum, &lnum, &lnum_next, true, NULL);
|
||||||
|
height_sum_fill += win_get_fill(wp, lnum);
|
||||||
height_cur_nofill = folded ? 1 : plines_win_nofill(wp, lnum, false);
|
height_cur_nofill = folded ? 1 : plines_win_nofill(wp, lnum, false);
|
||||||
height_sum += win_get_fill(wp, lnum) + height_cur_nofill;
|
height_sum_nofill += height_cur_nofill;
|
||||||
lnum = lnum_next + 1;
|
lnum = lnum_next + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end_vcol >= 0) {
|
if (end_vcol >= 0) {
|
||||||
height_sum -= height_cur_nofill;
|
height_sum_nofill -= height_cur_nofill;
|
||||||
const int64_t row_off = end_vcol == 0
|
const int64_t row_off = end_vcol == 0
|
||||||
? 0
|
? 0
|
||||||
: (end_vcol <= width1 || width2 <= 0)
|
: (end_vcol <= width1 || width2 <= 0)
|
||||||
? 1
|
? 1
|
||||||
: 1 + (end_vcol - width1 + width2 - 1) / width2;
|
: 1 + (end_vcol - width1 + width2 - 1) / width2;
|
||||||
height_sum += MIN(row_off, height_cur_nofill);
|
height_sum_nofill += MIN(row_off, height_cur_nofill);
|
||||||
}
|
}
|
||||||
|
|
||||||
return height_sum;
|
if (fill != NULL) {
|
||||||
|
*fill = height_sum_fill;
|
||||||
|
}
|
||||||
|
return height_sum_fill + height_sum_nofill;
|
||||||
}
|
}
|
||||||
|
@ -1052,19 +1052,19 @@ void ui_ext_win_viewport(win_T *wp)
|
|||||||
|| (cur_topline == last_topline && wp->w_skipcol < last_skipcol)) {
|
|| (cur_topline == last_topline && wp->w_skipcol < last_skipcol)) {
|
||||||
if (last_topline > 0 && cur_botline < last_topline) {
|
if (last_topline > 0 && cur_botline < last_topline) {
|
||||||
// Scrolling too many lines: only give an approximate "scroll_delta".
|
// Scrolling too many lines: only give an approximate "scroll_delta".
|
||||||
delta -= win_text_height(wp, cur_topline, wp->w_skipcol, cur_botline, 0);
|
delta -= win_text_height(wp, cur_topline, wp->w_skipcol, cur_botline, 0, NULL);
|
||||||
delta -= last_topline - cur_botline;
|
delta -= last_topline - cur_botline;
|
||||||
} else {
|
} else {
|
||||||
delta -= win_text_height(wp, cur_topline, wp->w_skipcol, last_topline, last_skipcol);
|
delta -= win_text_height(wp, cur_topline, wp->w_skipcol, last_topline, last_skipcol, NULL);
|
||||||
}
|
}
|
||||||
} else if (cur_topline > last_topline
|
} else if (cur_topline > last_topline
|
||||||
|| (cur_topline == last_topline && wp->w_skipcol > last_skipcol)) {
|
|| (cur_topline == last_topline && wp->w_skipcol > last_skipcol)) {
|
||||||
if (last_botline > 0 && cur_topline > last_botline) {
|
if (last_botline > 0 && cur_topline > last_botline) {
|
||||||
// Scrolling too many lines: only give an approximate "scroll_delta".
|
// Scrolling too many lines: only give an approximate "scroll_delta".
|
||||||
delta += win_text_height(wp, last_topline, last_skipcol, last_botline, 0);
|
delta += win_text_height(wp, last_topline, last_skipcol, last_botline, 0, NULL);
|
||||||
delta += cur_topline - last_botline;
|
delta += cur_topline - last_botline;
|
||||||
} else {
|
} else {
|
||||||
delta += win_text_height(wp, last_topline, last_skipcol, cur_topline, wp->w_skipcol);
|
delta += win_text_height(wp, last_topline, last_skipcol, cur_topline, wp->w_skipcol, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delta += last_topfill;
|
delta += last_topfill;
|
||||||
|
@ -687,42 +687,42 @@ describe('API/win', function()
|
|||||||
{8:[No Name] [+] }{9:[No Name] [+] }|
|
{8:[No Name] [+] }{9:[No Name] [+] }|
|
||||||
|
|
|
|
||||||
]]}
|
]]}
|
||||||
eq(20, meths.win_text_height(1000, {}))
|
eq({ all = 20, fill = 5 }, meths.win_text_height(1000, {}))
|
||||||
eq(20, meths.win_text_height(1001, {}))
|
eq({ all = 20, fill = 5 }, meths.win_text_height(1001, {}))
|
||||||
eq(20, meths.win_text_height(1000, { start_row = 0 }))
|
eq({ all = 20, fill = 5 }, meths.win_text_height(1000, { start_row = 0 }))
|
||||||
eq(20, meths.win_text_height(1001, { start_row = 0 }))
|
eq({ all = 20, fill = 5 }, meths.win_text_height(1001, { start_row = 0 }))
|
||||||
eq(15, meths.win_text_height(1000, { end_row = -1 }))
|
eq({ all = 15, fill = 0 }, meths.win_text_height(1000, { end_row = -1 }))
|
||||||
eq(20, meths.win_text_height(1001, { end_row = -1 }))
|
eq({ all = 15, fill = 0 }, meths.win_text_height(1000, { end_row = 40 }))
|
||||||
eq(15, meths.win_text_height(1000, { end_row = 40 }))
|
eq({ all = 20, fill = 5 }, meths.win_text_height(1001, { end_row = -1 }))
|
||||||
eq(20, meths.win_text_height(1001, { end_row = 40 }))
|
eq({ all = 20, fill = 5 }, meths.win_text_height(1001, { end_row = 40 }))
|
||||||
eq(10, meths.win_text_height(1000, { start_row = 23 }))
|
eq({ all = 10, fill = 5 }, meths.win_text_height(1000, { start_row = 23 }))
|
||||||
eq(13, meths.win_text_height(1001, { start_row = 18 }))
|
eq({ all = 13, fill = 3 }, meths.win_text_height(1001, { start_row = 18 }))
|
||||||
eq(11, meths.win_text_height(1000, { end_row = 23 }))
|
eq({ all = 11, fill = 0 }, meths.win_text_height(1000, { end_row = 23 }))
|
||||||
eq(11, meths.win_text_height(1001, { end_row = 18 }))
|
eq({ all = 11, fill = 5 }, meths.win_text_height(1001, { end_row = 18 }))
|
||||||
eq(11, meths.win_text_height(1000, { start_row = 3, end_row = 39 }))
|
eq({ all = 11, fill = 0 }, meths.win_text_height(1000, { start_row = 3, end_row = 39 }))
|
||||||
eq(11, meths.win_text_height(1001, { start_row = 1, end_row = 34 }))
|
eq({ all = 11, fill = 3 }, meths.win_text_height(1001, { start_row = 1, end_row = 34 }))
|
||||||
eq(9, meths.win_text_height(1000, { start_row = 4, end_row = 38 }))
|
eq({ all = 9, fill = 0 }, meths.win_text_height(1000, { start_row = 4, end_row = 38 }))
|
||||||
eq(9, meths.win_text_height(1001, { start_row = 2, end_row = 33 }))
|
eq({ all = 9, fill = 3 }, meths.win_text_height(1001, { start_row = 2, end_row = 33 }))
|
||||||
eq(9, meths.win_text_height(1000, { start_row = 5, end_row = 37 }))
|
eq({ all = 9, fill = 0 }, meths.win_text_height(1000, { start_row = 5, end_row = 37 }))
|
||||||
eq(9, meths.win_text_height(1001, { start_row = 3, end_row = 32 }))
|
eq({ all = 9, fill = 3 }, meths.win_text_height(1001, { start_row = 3, end_row = 32 }))
|
||||||
eq(9, meths.win_text_height(1000, { start_row = 17, end_row = 25 }))
|
eq({ all = 9, fill = 0 }, meths.win_text_height(1000, { start_row = 17, end_row = 25 }))
|
||||||
eq(9, meths.win_text_height(1001, { start_row = 15, end_row = 20 }))
|
eq({ all = 9, fill = 3 }, meths.win_text_height(1001, { start_row = 15, end_row = 20 }))
|
||||||
eq(7, meths.win_text_height(1000, { start_row = 18, end_row = 24 }))
|
eq({ all = 7, fill = 0 }, meths.win_text_height(1000, { start_row = 18, end_row = 24 }))
|
||||||
eq(7, meths.win_text_height(1001, { start_row = 16, end_row = 19 }))
|
eq({ all = 7, fill = 3 }, meths.win_text_height(1001, { start_row = 16, end_row = 19 }))
|
||||||
eq(6, meths.win_text_height(1000, { start_row = -1 }))
|
eq({ all = 6, fill = 5 }, meths.win_text_height(1000, { start_row = -1 }))
|
||||||
eq(5, meths.win_text_height(1000, { start_row = -1, start_vcol = X }))
|
eq({ all = 5, fill = 5 }, meths.win_text_height(1000, { start_row = -1, start_vcol = X }))
|
||||||
eq(0, meths.win_text_height(1000, { start_row = -1, start_vcol = X, end_row = -1 }))
|
eq({ all = 0, fill = 0 }, meths.win_text_height(1000, { start_row = -1, start_vcol = X, end_row = -1 }))
|
||||||
eq(0, meths.win_text_height(1000, { start_row = -1, start_vcol = X, end_row = -1, end_vcol = X }))
|
eq({ all = 0, fill = 0 }, meths.win_text_height(1000, { start_row = -1, start_vcol = X, end_row = -1, end_vcol = X }))
|
||||||
eq(1, meths.win_text_height(1000, { start_row = -1, start_vcol = 0, end_row = -1, end_vcol = X }))
|
eq({ all = 1, fill = 0 }, meths.win_text_height(1000, { start_row = -1, start_vcol = 0, end_row = -1, end_vcol = X }))
|
||||||
eq(3, meths.win_text_height(1001, { end_row = 0 }))
|
eq({ all = 3, fill = 2 }, meths.win_text_height(1001, { end_row = 0 }))
|
||||||
eq(2, meths.win_text_height(1001, { end_row = 0, end_vcol = 0 }))
|
eq({ all = 2, fill = 2 }, meths.win_text_height(1001, { end_row = 0, end_vcol = 0 }))
|
||||||
eq(2, meths.win_text_height(1001, { start_row = 0, end_row = 0, end_vcol = 0 }))
|
eq({ all = 2, fill = 2 }, meths.win_text_height(1001, { start_row = 0, end_row = 0, end_vcol = 0 }))
|
||||||
eq(0, meths.win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 0, end_vcol = 0 }))
|
eq({ all = 0, fill = 0 }, meths.win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 0, end_vcol = 0 }))
|
||||||
eq(1, meths.win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 0, end_vcol = X }))
|
eq({ all = 1, fill = 0 }, meths.win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 0, end_vcol = X }))
|
||||||
eq(11, meths.win_text_height(1001, { end_row = 18 }))
|
eq({ all = 11, fill = 5 }, meths.win_text_height(1001, { end_row = 18 }))
|
||||||
eq(9, meths.win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 18 }))
|
eq({ all = 9, fill = 3 }, meths.win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 18 }))
|
||||||
eq(10, meths.win_text_height(1001, { end_row = 18, end_vcol = 0 }))
|
eq({ all = 10, fill = 5 }, meths.win_text_height(1001, { end_row = 18, end_vcol = 0 }))
|
||||||
eq(8, meths.win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 18, end_vcol = 0 }))
|
eq({ all = 8, fill = 3 }, meths.win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 18, end_vcol = 0 }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('with wrapped lines', function()
|
it('with wrapped lines', function()
|
||||||
@ -770,39 +770,42 @@ describe('API/win', function()
|
|||||||
{1: 1 }^foobar-foobar-foobar-foobar-foobar-foobar|
|
{1: 1 }^foobar-foobar-foobar-foobar-foobar-foobar|
|
||||||
|
|
|
|
||||||
]]}
|
]]}
|
||||||
eq(21, meths.win_text_height(0, {}))
|
eq({ all = 21, fill = 0 }, meths.win_text_height(0, {}))
|
||||||
eq(6, meths.win_text_height(0, { start_row = 0, end_row = 0 }))
|
eq({ all = 6, fill = 0 }, meths.win_text_height(0, { start_row = 0, end_row = 0 }))
|
||||||
eq(7, meths.win_text_height(0, { start_row = 1, end_row = 1 }))
|
eq({ all = 7, fill = 0 }, meths.win_text_height(0, { start_row = 1, end_row = 1 }))
|
||||||
eq(8, meths.win_text_height(0, { start_row = 2, end_row = 2 }))
|
eq({ all = 8, fill = 0 }, meths.win_text_height(0, { start_row = 2, end_row = 2 }))
|
||||||
eq(1, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 41 }))
|
eq({ all = 0, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 0 }))
|
||||||
eq(2, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 42 }))
|
eq({ all = 1, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 41 }))
|
||||||
eq(2, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 86 }))
|
eq({ all = 2, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 42 }))
|
||||||
eq(3, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 87 }))
|
eq({ all = 2, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 86 }))
|
||||||
eq(6, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 266 }))
|
eq({ all = 3, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 87 }))
|
||||||
eq(7, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 267 }))
|
eq({ all = 6, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 266 }))
|
||||||
eq(7, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 311 }))
|
eq({ all = 7, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 267 }))
|
||||||
eq(7, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 312 }))
|
eq({ all = 7, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 311 }))
|
||||||
eq(7, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = X }))
|
eq({ all = 7, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 312 }))
|
||||||
eq(7, meths.win_text_height(0, { start_row = 1, start_vcol = 40, end_row = 1, end_vcol = X }))
|
eq({ all = 7, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = X }))
|
||||||
eq(6, meths.win_text_height(0, { start_row = 1, start_vcol = 41, end_row = 1, end_vcol = X }))
|
eq({ all = 7, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 40, end_row = 1, end_vcol = X }))
|
||||||
eq(6, meths.win_text_height(0, { start_row = 1, start_vcol = 85, end_row = 1, end_vcol = X }))
|
eq({ all = 6, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 41, end_row = 1, end_vcol = X }))
|
||||||
eq(5, meths.win_text_height(0, { start_row = 1, start_vcol = 86, end_row = 1, end_vcol = X }))
|
eq({ all = 6, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 85, end_row = 1, end_vcol = X }))
|
||||||
eq(2, meths.win_text_height(0, { start_row = 1, start_vcol = 265, end_row = 1, end_vcol = X }))
|
eq({ all = 5, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 86, end_row = 1, end_vcol = X }))
|
||||||
eq(1, meths.win_text_height(0, { start_row = 1, start_vcol = 266, end_row = 1, end_vcol = X }))
|
eq({ all = 2, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 265, end_row = 1, end_vcol = X }))
|
||||||
eq(1, meths.win_text_height(0, { start_row = 1, start_vcol = 310, end_row = 1, end_vcol = X }))
|
eq({ all = 1, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 266, end_row = 1, end_vcol = X }))
|
||||||
eq(0, meths.win_text_height(0, { start_row = 1, start_vcol = 311, end_row = 1, end_vcol = X }))
|
eq({ all = 1, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 310, end_row = 1, end_vcol = X }))
|
||||||
eq(18, meths.win_text_height(0, { start_row = 0, start_vcol = 131 }))
|
eq({ all = 0, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 311, end_row = 1, end_vcol = X }))
|
||||||
eq(19, meths.win_text_height(0, { start_row = 0, start_vcol = 130 }))
|
eq({ all = 1, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 86, end_row = 1, end_vcol = 131 }))
|
||||||
eq(20, meths.win_text_height(0, { end_row = 2, end_vcol = 311 }))
|
eq({ all = 1, fill = 0 }, meths.win_text_height(0, { start_row = 1, start_vcol = 221, end_row = 1, end_vcol = 266 }))
|
||||||
eq(21, meths.win_text_height(0, { end_row = 2, end_vcol = 312 }))
|
eq({ all = 18, fill = 0 }, meths.win_text_height(0, { start_row = 0, start_vcol = 131 }))
|
||||||
eq(17, meths.win_text_height(0, { start_row = 0, start_vcol = 131, end_row = 2, end_vcol = 311 }))
|
eq({ all = 19, fill = 0 }, meths.win_text_height(0, { start_row = 0, start_vcol = 130 }))
|
||||||
eq(19, meths.win_text_height(0, { start_row = 0, start_vcol = 130, end_row = 2, end_vcol = 312 }))
|
eq({ all = 20, fill = 0 }, meths.win_text_height(0, { end_row = 2, end_vcol = 311 }))
|
||||||
eq(16, meths.win_text_height(0, { start_row = 0, start_vcol = 221 }))
|
eq({ all = 21, fill = 0 }, meths.win_text_height(0, { end_row = 2, end_vcol = 312 }))
|
||||||
eq(17, meths.win_text_height(0, { start_row = 0, start_vcol = 220 }))
|
eq({ all = 17, fill = 0 }, meths.win_text_height(0, { start_row = 0, start_vcol = 131, end_row = 2, end_vcol = 311 }))
|
||||||
eq(14, meths.win_text_height(0, { end_row = 2, end_vcol = 41 }))
|
eq({ all = 19, fill = 0 }, meths.win_text_height(0, { start_row = 0, start_vcol = 130, end_row = 2, end_vcol = 312 }))
|
||||||
eq(15, meths.win_text_height(0, { end_row = 2, end_vcol = 42 }))
|
eq({ all = 16, fill = 0 }, meths.win_text_height(0, { start_row = 0, start_vcol = 221 }))
|
||||||
eq(9, meths.win_text_height(0, { start_row = 0, start_vcol = 221, end_row = 2, end_vcol = 41 }))
|
eq({ all = 17, fill = 0 }, meths.win_text_height(0, { start_row = 0, start_vcol = 220 }))
|
||||||
eq(11, meths.win_text_height(0, { start_row = 0, start_vcol = 220, end_row = 2, end_vcol = 42 }))
|
eq({ all = 14, fill = 0 }, meths.win_text_height(0, { end_row = 2, end_vcol = 41 }))
|
||||||
|
eq({ all = 15, fill = 0 }, meths.win_text_height(0, { end_row = 2, end_vcol = 42 }))
|
||||||
|
eq({ all = 9, fill = 0 }, meths.win_text_height(0, { start_row = 0, start_vcol = 221, end_row = 2, end_vcol = 41 }))
|
||||||
|
eq({ all = 11, fill = 0 }, meths.win_text_height(0, { start_row = 0, start_vcol = 220, end_row = 2, end_vcol = 42 }))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user