mirror of
https://github.com/vim/vim.git
synced 2025-10-06 05:44:14 -04:00
patch 8.0.1769: repeated saving and restoring viewstate for 'incsearch'
Problem: Repeated saving and restoring viewstate for 'incsearch'. Solution: Use a structure.
This commit is contained in:
@@ -187,6 +187,45 @@ empty_pattern(char_u *p)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef FEAT_SEARCH_EXTRA
|
||||||
|
typedef struct {
|
||||||
|
colnr_T vs_curswant;
|
||||||
|
colnr_T vs_leftcol;
|
||||||
|
linenr_T vs_topline;
|
||||||
|
# ifdef FEAT_DIFF
|
||||||
|
int vs_topfill;
|
||||||
|
# endif
|
||||||
|
linenr_T vs_botline;
|
||||||
|
linenr_T vs_empty_rows;
|
||||||
|
} viewstate_T;
|
||||||
|
|
||||||
|
static void
|
||||||
|
save_viewstate(viewstate_T *vs)
|
||||||
|
{
|
||||||
|
vs->vs_curswant = curwin->w_curswant;
|
||||||
|
vs->vs_leftcol = curwin->w_leftcol;
|
||||||
|
vs->vs_topline = curwin->w_topline;
|
||||||
|
# ifdef FEAT_DIFF
|
||||||
|
vs->vs_topfill = curwin->w_topfill;
|
||||||
|
# endif
|
||||||
|
vs->vs_botline = curwin->w_botline;
|
||||||
|
vs->vs_empty_rows = curwin->w_empty_rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
restore_viewstate(viewstate_T *vs)
|
||||||
|
{
|
||||||
|
curwin->w_curswant = vs->vs_curswant;
|
||||||
|
curwin->w_leftcol = vs->vs_leftcol;
|
||||||
|
curwin->w_topline = vs->vs_topline;
|
||||||
|
# ifdef FEAT_DIFF
|
||||||
|
curwin->w_topfill = vs->vs_topfill;
|
||||||
|
# endif
|
||||||
|
curwin->w_botline = vs->vs_botline;
|
||||||
|
curwin->w_empty_rows = vs->vs_empty_rows;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* getcmdline() - accept a command line starting with firstc.
|
* getcmdline() - accept a command line starting with firstc.
|
||||||
*
|
*
|
||||||
@@ -225,21 +264,10 @@ getcmdline(
|
|||||||
#ifdef FEAT_SEARCH_EXTRA
|
#ifdef FEAT_SEARCH_EXTRA
|
||||||
pos_T search_start; /* where 'incsearch' starts searching */
|
pos_T search_start; /* where 'incsearch' starts searching */
|
||||||
pos_T save_cursor;
|
pos_T save_cursor;
|
||||||
colnr_T old_curswant;
|
viewstate_T init_viewstate;
|
||||||
colnr_T init_curswant = curwin->w_curswant;
|
viewstate_T old_viewstate;
|
||||||
colnr_T old_leftcol;
|
|
||||||
colnr_T init_leftcol = curwin->w_leftcol;
|
|
||||||
linenr_T old_topline;
|
|
||||||
linenr_T init_topline = curwin->w_topline;
|
|
||||||
pos_T match_start = curwin->w_cursor;
|
pos_T match_start = curwin->w_cursor;
|
||||||
pos_T match_end;
|
pos_T match_end;
|
||||||
# ifdef FEAT_DIFF
|
|
||||||
int old_topfill;
|
|
||||||
int init_topfill = curwin->w_topfill;
|
|
||||||
# endif
|
|
||||||
linenr_T old_botline, old_empty_rows;
|
|
||||||
linenr_T init_botline = curwin->w_botline;
|
|
||||||
linenr_T init_empty_rows = curwin->w_empty_rows;
|
|
||||||
int did_incsearch = FALSE;
|
int did_incsearch = FALSE;
|
||||||
int incsearch_postponed = FALSE;
|
int incsearch_postponed = FALSE;
|
||||||
#endif
|
#endif
|
||||||
@@ -285,14 +313,8 @@ getcmdline(
|
|||||||
CLEAR_POS(&match_end);
|
CLEAR_POS(&match_end);
|
||||||
save_cursor = curwin->w_cursor; /* may be restored later */
|
save_cursor = curwin->w_cursor; /* may be restored later */
|
||||||
search_start = curwin->w_cursor;
|
search_start = curwin->w_cursor;
|
||||||
old_curswant = curwin->w_curswant;
|
save_viewstate(&init_viewstate);
|
||||||
old_leftcol = curwin->w_leftcol;
|
save_viewstate(&old_viewstate);
|
||||||
old_topline = curwin->w_topline;
|
|
||||||
# ifdef FEAT_DIFF
|
|
||||||
old_topfill = curwin->w_topfill;
|
|
||||||
# endif
|
|
||||||
old_botline = curwin->w_botline;
|
|
||||||
old_empty_rows = curwin->w_empty_rows;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1070,14 +1092,7 @@ getcmdline(
|
|||||||
search_start = save_cursor;
|
search_start = save_cursor;
|
||||||
/* save view settings, so that the screen
|
/* save view settings, so that the screen
|
||||||
* won't be restored at the wrong position */
|
* won't be restored at the wrong position */
|
||||||
old_curswant = init_curswant;
|
old_viewstate = init_viewstate;
|
||||||
old_leftcol = init_leftcol;
|
|
||||||
old_topline = init_topline;
|
|
||||||
# ifdef FEAT_DIFF
|
|
||||||
old_topfill = init_topfill;
|
|
||||||
# endif
|
|
||||||
old_botline = init_botline;
|
|
||||||
old_empty_rows = init_empty_rows;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
redrawcmd();
|
redrawcmd();
|
||||||
@@ -1800,14 +1815,7 @@ getcmdline(
|
|||||||
update_topline();
|
update_topline();
|
||||||
validate_cursor();
|
validate_cursor();
|
||||||
highlight_match = TRUE;
|
highlight_match = TRUE;
|
||||||
old_curswant = curwin->w_curswant;
|
save_viewstate(&old_viewstate);
|
||||||
old_leftcol = curwin->w_leftcol;
|
|
||||||
old_topline = curwin->w_topline;
|
|
||||||
# ifdef FEAT_DIFF
|
|
||||||
old_topfill = curwin->w_topfill;
|
|
||||||
# endif
|
|
||||||
old_botline = curwin->w_botline;
|
|
||||||
old_empty_rows = curwin->w_empty_rows;
|
|
||||||
update_screen(NOT_VALID);
|
update_screen(NOT_VALID);
|
||||||
redrawcmdline();
|
redrawcmdline();
|
||||||
}
|
}
|
||||||
@@ -2018,13 +2026,7 @@ cmdline_changed:
|
|||||||
|
|
||||||
/* first restore the old curwin values, so the screen is
|
/* first restore the old curwin values, so the screen is
|
||||||
* positioned in the same way as the actual search command */
|
* positioned in the same way as the actual search command */
|
||||||
curwin->w_leftcol = old_leftcol;
|
restore_viewstate(&old_viewstate);
|
||||||
curwin->w_topline = old_topline;
|
|
||||||
# ifdef FEAT_DIFF
|
|
||||||
curwin->w_topfill = old_topfill;
|
|
||||||
# endif
|
|
||||||
curwin->w_botline = old_botline;
|
|
||||||
curwin->w_empty_rows = old_empty_rows;
|
|
||||||
changed_cline_bef_curs();
|
changed_cline_bef_curs();
|
||||||
update_topline();
|
update_topline();
|
||||||
|
|
||||||
@@ -2112,14 +2114,7 @@ returncmd:
|
|||||||
}
|
}
|
||||||
curwin->w_cursor = search_start;
|
curwin->w_cursor = search_start;
|
||||||
}
|
}
|
||||||
curwin->w_curswant = old_curswant;
|
restore_viewstate(&old_viewstate);
|
||||||
curwin->w_leftcol = old_leftcol;
|
|
||||||
curwin->w_topline = old_topline;
|
|
||||||
# ifdef FEAT_DIFF
|
|
||||||
curwin->w_topfill = old_topfill;
|
|
||||||
# endif
|
|
||||||
curwin->w_botline = old_botline;
|
|
||||||
curwin->w_empty_rows = old_empty_rows;
|
|
||||||
highlight_match = FALSE;
|
highlight_match = FALSE;
|
||||||
validate_cursor(); /* needed for TAB */
|
validate_cursor(); /* needed for TAB */
|
||||||
redraw_all_later(SOME_VALID);
|
redraw_all_later(SOME_VALID);
|
||||||
|
@@ -761,6 +761,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1769,
|
||||||
/**/
|
/**/
|
||||||
1768,
|
1768,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user