}
#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.
*
#ifdef FEAT_SEARCH_EXTRA
pos_T search_start; /* where 'incsearch' starts searching */
pos_T save_cursor;
- colnr_T old_curswant;
- colnr_T init_curswant = curwin->w_curswant;
- colnr_T old_leftcol;
- colnr_T init_leftcol = curwin->w_leftcol;
- linenr_T old_topline;
- linenr_T init_topline = curwin->w_topline;
+ viewstate_T init_viewstate;
+ viewstate_T old_viewstate;
pos_T match_start = curwin->w_cursor;
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 incsearch_postponed = FALSE;
#endif
CLEAR_POS(&match_end);
save_cursor = curwin->w_cursor; /* may be restored later */
search_start = curwin->w_cursor;
- old_curswant = curwin->w_curswant;
- 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;
+ save_viewstate(&init_viewstate);
+ save_viewstate(&old_viewstate);
#endif
/*
search_start = save_cursor;
/* save view settings, so that the screen
* won't be restored at the wrong position */
- old_curswant = init_curswant;
- 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;
+ old_viewstate = init_viewstate;
}
#endif
redrawcmd();
update_topline();
validate_cursor();
highlight_match = TRUE;
- old_curswant = curwin->w_curswant;
- 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;
+ save_viewstate(&old_viewstate);
update_screen(NOT_VALID);
redrawcmdline();
}
/* first restore the old curwin values, so the screen is
* positioned in the same way as the actual search command */
- 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;
+ restore_viewstate(&old_viewstate);
changed_cline_bef_curs();
update_topline();
}
curwin->w_cursor = search_start;
}
- curwin->w_curswant = old_curswant;
- 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;
+ restore_viewstate(&old_viewstate);
highlight_match = FALSE;
validate_cursor(); /* needed for TAB */
redraw_all_later(SOME_VALID);