mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
fix(inccommand): don't crash with "split" and 'n' flag
(cherry picked from commit bc5b0da84e
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
f4642d4c81
commit
b56a18b1df
@@ -4573,7 +4573,6 @@ static int show_sub(exarg_T *eap, pos_T old_cusr, PreviewLines *preview_lines, i
|
||||
}
|
||||
|
||||
// Width of the "| lnum|..." column which displays the line numbers.
|
||||
linenr_T highest_num_line = 0;
|
||||
int col_width = 0;
|
||||
// Use preview window only when inccommand=split and range is not just the current line
|
||||
bool preview = (*p_icm == 's') && (eap->line1 != old_cusr.lnum || eap->line2 != old_cusr.lnum);
|
||||
@@ -4583,8 +4582,11 @@ static int show_sub(exarg_T *eap, pos_T old_cusr, PreviewLines *preview_lines, i
|
||||
assert(cmdpreview_buf != NULL);
|
||||
|
||||
if (lines.subresults.size > 0) {
|
||||
highest_num_line = kv_last(lines.subresults).end.lnum;
|
||||
col_width = (int)log10(highest_num_line) + 1 + 3;
|
||||
SubResult last_match = kv_last(lines.subresults);
|
||||
// `last_match.end.lnum` may be 0 when using 'n' flag.
|
||||
linenr_T highest_lnum = MAX(last_match.start.lnum, last_match.end.lnum);
|
||||
assert(highest_lnum > 0);
|
||||
col_width = (int)log10(highest_lnum) + 1 + 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user