Remove pat/sub from show_sub

They were only used to not show the preview window when typing "s/" or
"s//" only, in which case the previous pattern would be reused. Now the
window is shown in that case.
This commit is contained in:
KillTheMule
2017-09-22 21:37:13 +02:00
parent a4e4f2bd02
commit 3e5ecd9538

View File

@@ -4061,8 +4061,8 @@ skip:
pre_hl_id = syn_check_group((char_u *)"Substitute", 13); pre_hl_id = syn_check_group((char_u *)"Substitute", 13);
} }
curbuf->b_changed = save_b_changed; // preserve 'modified' during preview curbuf->b_changed = save_b_changed; // preserve 'modified' during preview
preview_buf = show_sub(eap, old_cursor, pat, sub, &preview_lines, preview_buf = show_sub(eap, old_cursor, &preview_lines, has_second_delim,
has_second_delim, pre_hl_id, pre_src_id); pre_hl_id, pre_src_id);
bufhl_clear_line_range(orig_buf, pre_src_id, eap->line1, bufhl_clear_line_range(orig_buf, pre_src_id, eap->line1,
kv_last(preview_lines.subresults).end.lnum); kv_last(preview_lines.subresults).end.lnum);
} }
@@ -6071,7 +6071,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
/// Shows the effects of the :substitute command being typed ('inccommand'). /// Shows the effects of the :substitute command being typed ('inccommand').
/// If inccommand=split, shows a preview window and later restores the layout. /// If inccommand=split, shows a preview window and later restores the layout.
static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, char_u *pat, char_u *sub, static buf_T *show_sub(exarg_T *eap, pos_T old_cusr,
PreviewLines *preview_lines, bool show_hl, int hl_id, PreviewLines *preview_lines, bool show_hl, int hl_id,
int src_id) int src_id)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
@@ -6081,8 +6081,6 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, char_u *pat, char_u *sub,
win_T *save_curwin = curwin; win_T *save_curwin = curwin;
cmdmod_T save_cmdmod = cmdmod; cmdmod_T save_cmdmod = cmdmod;
char_u *save_shm_p = vim_strsave(p_shm); char_u *save_shm_p = vim_strsave(p_shm);
size_t sub_size = mb_string2cells(sub);
size_t pat_size = mb_string2cells(pat);
PreviewLines lines = *preview_lines; PreviewLines lines = *preview_lines;
buf_T *orig_buf = curbuf; buf_T *orig_buf = curbuf;
@@ -6096,7 +6094,7 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, char_u *pat, char_u *sub,
bool outside_curline = (eap->line1 != old_cusr.lnum bool outside_curline = (eap->line1 != old_cusr.lnum
|| eap->line2 != old_cusr.lnum); || eap->line2 != old_cusr.lnum);
bool split = outside_curline && (*p_icm != 'n') && (sub_size || pat_size); bool split = outside_curline && (*p_icm != 'n');
if (preview_buf == curbuf) { // Preview buffer cannot preview itself! if (preview_buf == curbuf) { // Preview buffer cannot preview itself!
split = false; split = false;
preview_buf = NULL; preview_buf = NULL;