Patch 8.0.1769
Problem:    Repeated saving and restoring viewstate for 'incsearch'.
Solution:   Use a structure.
Files:      src/ex_getln.c


*** ../vim-8.0.1768/src/ex_getln.c      2018-04-27 22:53:03.926590734 +0200
--- src/ex_getln.c      2018-04-28 13:45:40.882903721 +0200
***************
*** 187,192 ****
--- 187,231 ----
  }
  #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.
   *
***************
*** 225,245 ****
  #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;
      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
--- 264,273 ----
  #ifdef FEAT_SEARCH_EXTRA
      pos_T     search_start;           /* where 'incsearch' starts searching */
      pos_T       save_cursor;
!     viewstate_T       init_viewstate;
!     viewstate_T       old_viewstate;
      pos_T       match_start = curwin->w_cursor;
      pos_T       match_end;
      int               did_incsearch = FALSE;
      int               incsearch_postponed = FALSE;
  #endif
***************
*** 285,298 ****
      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;
  #endif
  
      /*
--- 313,320 ----
      CLEAR_POS(&match_end);
      save_cursor = curwin->w_cursor;       /* may be restored later */
      search_start = curwin->w_cursor;
!     save_viewstate(&init_viewstate);
!     save_viewstate(&old_viewstate);
  #endif
  
      /*
***************
*** 1070,1083 ****
                        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;
                    }
  #endif
                    redrawcmd();
--- 1092,1098 ----
                        search_start = save_cursor;
                        /* save view settings, so that the screen
                         * won't be restored at the wrong position */
!                       old_viewstate = init_viewstate;
                    }
  #endif
                    redrawcmd();
***************
*** 1800,1813 ****
                        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;
                        update_screen(NOT_VALID);
                        redrawcmdline();
                    }
--- 1815,1821 ----
                        update_topline();
                        validate_cursor();
                        highlight_match = TRUE;
!                       save_viewstate(&old_viewstate);
                        update_screen(NOT_VALID);
                        redrawcmdline();
                    }
***************
*** 2018,2030 ****
  
            /* 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;
            changed_cline_bef_curs();
            update_topline();
  
--- 2026,2032 ----
  
            /* first restore the old curwin values, so the screen is
             * positioned in the same way as the actual search command */
!           restore_viewstate(&old_viewstate);
            changed_cline_bef_curs();
            update_topline();
  
***************
*** 2112,2125 ****
            }
            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;
        highlight_match = FALSE;
        validate_cursor();      /* needed for TAB */
        redraw_all_later(SOME_VALID);
--- 2114,2120 ----
            }
            curwin->w_cursor = search_start;
        }
!       restore_viewstate(&old_viewstate);
        highlight_match = FALSE;
        validate_cursor();      /* needed for TAB */
        redraw_all_later(SOME_VALID);
*** ../vim-8.0.1768/src/version.c       2018-04-27 22:53:03.934590686 +0200
--- src/version.c       2018-04-28 13:46:50.082502321 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     1769,
  /**/

-- 
Facepalm statement #8: "Drive faster, the petrol is running out"

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui