fix(inccommand): avoid crash if callback changes inccommand option (#18830)

clang: Result of operation is garbage or undefined
clang: Uninitialized argument value

Also check for == 's' instead of != 'n' as it is more straightforward.

Also fix another unrelated PVS warning:
PVS/V1071: Return value of win_comp_pos() is not always used
This commit is contained in:
zeertzjq
2022-06-02 03:48:36 +08:00
committed by GitHub
parent 209824ce2c
commit 57a296d899
4 changed files with 23 additions and 5 deletions

View File

@@ -5872,7 +5872,7 @@ static int show_sub(exarg_T *eap, pos_T old_cusr, PreviewLines *preview_lines, i
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 != 'n') && (eap->line1 != old_cusr.lnum || eap->line2 != old_cusr.lnum);
bool preview = (*p_icm == 's') && (eap->line1 != old_cusr.lnum || eap->line2 != old_cusr.lnum);
if (preview) {
cmdpreview_buf = buflist_findnr(cmdpreview_bufnr);