Karsten Hopp 81c285
To: vim-dev@vim.org
Karsten Hopp 81c285
Subject: Patch 7.2.215
Karsten Hopp 81c285
Fcc: outbox
Karsten Hopp 81c285
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 81c285
Mime-Version: 1.0
Karsten Hopp 81c285
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 81c285
Content-Transfer-Encoding: 8bit
Karsten Hopp 81c285
------------
Karsten Hopp 81c285
Karsten Hopp 81c285
Patch 7.2.215
Karsten Hopp 81c285
Problem:    ml_get error when using ":vimgrep".
Karsten Hopp 81c285
Solution:   Load the memfile for the hidden buffer before putting it in a
Karsten Hopp 81c285
	    window.  Correct the order of splitting the window and filling
Karsten Hopp 81c285
	    the window and buffer with data.
Karsten Hopp 81c285
Files:	    src/fileio.c, src/proto/window.pro, src/quickfix.c, src/window.c
Karsten Hopp 81c285
Karsten Hopp 81c285
Karsten Hopp 81c285
*** ../vim-7.2.214/src/fileio.c	2009-06-24 11:57:53.000000000 +0200
Karsten Hopp 81c285
--- src/fileio.c	2009-06-24 12:53:19.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 710,716 ****
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  #ifdef UNIX
Karsten Hopp 81c285
  	/* Set swap file protection bits after creating it. */
Karsten Hopp 81c285
! 	if (swap_mode > 0 && curbuf->b_ml.ml_mfp->mf_fname != NULL)
Karsten Hopp 81c285
  	    (void)mch_setperm(curbuf->b_ml.ml_mfp->mf_fname, (long)swap_mode);
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
--- 710,717 ----
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  #ifdef UNIX
Karsten Hopp 81c285
  	/* Set swap file protection bits after creating it. */
Karsten Hopp 81c285
! 	if (swap_mode > 0 && curbuf->b_ml.ml_mfp != NULL
Karsten Hopp 81c285
! 			  && curbuf->b_ml.ml_mfp->mf_fname != NULL)
Karsten Hopp 81c285
  	    (void)mch_setperm(curbuf->b_ml.ml_mfp->mf_fname, (long)swap_mode);
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 8435,8443 ****
Karsten Hopp 81c285
  	 * effects, insert it in a the current tab page.
Karsten Hopp 81c285
  	 * Anything related to a window (e.g., setting folds) may have
Karsten Hopp 81c285
  	 * unexpected results. */
Karsten Hopp 81c285
! 	curwin = aucmd_win;
Karsten Hopp 81c285
! 	curwin->w_buffer = buf;
Karsten Hopp 81c285
  	++buf->b_nwindows;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #ifdef FEAT_WINDOWS
Karsten Hopp 81c285
  	/* Split the current window, put the aucmd_win in the upper half. */
Karsten Hopp 81c285
--- 8436,8444 ----
Karsten Hopp 81c285
  	 * effects, insert it in a the current tab page.
Karsten Hopp 81c285
  	 * Anything related to a window (e.g., setting folds) may have
Karsten Hopp 81c285
  	 * unexpected results. */
Karsten Hopp 81c285
! 	aucmd_win->w_buffer = buf;
Karsten Hopp 81c285
  	++buf->b_nwindows;
Karsten Hopp 81c285
+ 	win_init_empty(aucmd_win); /* set cursor and topline to safe values */
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #ifdef FEAT_WINDOWS
Karsten Hopp 81c285
  	/* Split the current window, put the aucmd_win in the upper half. */
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 8448,8459 ****
Karsten Hopp 81c285
  	(void)win_comp_pos();   /* recompute window positions */
Karsten Hopp 81c285
  	p_ea = save_ea;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
! 	/* set cursor and topline to safe values */
Karsten Hopp 81c285
! 	curwin_init();
Karsten Hopp 81c285
! #ifdef FEAT_VERTSPLIT
Karsten Hopp 81c285
! 	curwin->w_wincol = 0;
Karsten Hopp 81c285
! 	curwin->w_width = Columns;
Karsten Hopp 81c285
! #endif
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
      curbuf = buf;
Karsten Hopp 81c285
      aco->new_curwin = curwin;
Karsten Hopp 81c285
--- 8449,8455 ----
Karsten Hopp 81c285
  	(void)win_comp_pos();   /* recompute window positions */
Karsten Hopp 81c285
  	p_ea = save_ea;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
! 	curwin = aucmd_win;
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
      curbuf = buf;
Karsten Hopp 81c285
      aco->new_curwin = curwin;
Karsten Hopp 81c285
*** ../vim-7.2.214/src/proto/window.pro	2009-06-16 16:01:34.000000000 +0200
Karsten Hopp 81c285
--- src/proto/window.pro	2009-06-24 12:53:13.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 14,19 ****
Karsten Hopp 81c285
--- 14,20 ----
Karsten Hopp 81c285
  win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp));
Karsten Hopp 81c285
  void close_others __ARGS((int message, int forceit));
Karsten Hopp 81c285
  void curwin_init __ARGS((void));
Karsten Hopp 81c285
+ void win_init_empty __ARGS((win_T *wp));
Karsten Hopp 81c285
  int win_alloc_first __ARGS((void));
Karsten Hopp 81c285
  void win_alloc_aucmd_win __ARGS((void));
Karsten Hopp 81c285
  void win_init_size __ARGS((void));
Karsten Hopp 81c285
*** ../vim-7.2.214/src/quickfix.c	2009-05-17 13:30:58.000000000 +0200
Karsten Hopp 81c285
--- src/quickfix.c	2009-06-24 15:30:06.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 3411,3424 ****
Karsten Hopp 81c285
      /* Init the options. */
Karsten Hopp 81c285
      buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     /* set curwin/curbuf to buf and save a few things */
Karsten Hopp 81c285
!     aucmd_prepbuf(&aco, newbuf);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     /* Need to set the filename for autocommands. */
Karsten Hopp 81c285
!     (void)setfname(curbuf, fname, NULL, FALSE);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
-     if (ml_open(curbuf) == OK)
Karsten Hopp 81c285
-     {
Karsten Hopp 81c285
  	/* Create swap file now to avoid the ATTENTION message. */
Karsten Hopp 81c285
  	check_need_swap(TRUE);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
--- 3411,3425 ----
Karsten Hopp 81c285
      /* Init the options. */
Karsten Hopp 81c285
      buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     /* need to open the memfile before putting the buffer in a window */
Karsten Hopp 81c285
!     if (ml_open(newbuf) == OK)
Karsten Hopp 81c285
!     {
Karsten Hopp 81c285
! 	/* set curwin/curbuf to buf and save a few things */
Karsten Hopp 81c285
! 	aucmd_prepbuf(&aco, newbuf);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	/* Need to set the filename for autocommands. */
Karsten Hopp 81c285
! 	(void)setfname(curbuf, fname, NULL, FALSE);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	/* Create swap file now to avoid the ATTENTION message. */
Karsten Hopp 81c285
  	check_need_swap(TRUE);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 3441,3450 ****
Karsten Hopp 81c285
  		newbuf = curbuf;
Karsten Hopp 81c285
  	    }
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
-     }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     /* restore curwin/curbuf and a few other things */
Karsten Hopp 81c285
!     aucmd_restbuf(&aco;;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      if (!buf_valid(newbuf))
Karsten Hopp 81c285
  	return NULL;
Karsten Hopp 81c285
--- 3442,3451 ----
Karsten Hopp 81c285
  		newbuf = curbuf;
Karsten Hopp 81c285
  	    }
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	/* restore curwin/curbuf and a few other things */
Karsten Hopp 81c285
! 	aucmd_restbuf(&aco;;
Karsten Hopp 81c285
!     }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      if (!buf_valid(newbuf))
Karsten Hopp 81c285
  	return NULL;
Karsten Hopp 81c285
*** ../vim-7.2.214/src/window.c	2009-06-16 16:01:34.000000000 +0200
Karsten Hopp 81c285
--- src/window.c	2009-06-24 14:35:16.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 2354,2366 ****
Karsten Hopp 81c285
      frame_T	*frp;
Karsten Hopp 81c285
      win_T	*wp;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
- #ifdef FEAT_FOLDING
Karsten Hopp 81c285
-     clearFolding(win);
Karsten Hopp 81c285
- #endif
Karsten Hopp 81c285
- 
Karsten Hopp 81c285
-     /* reduce the reference count to the argument list. */
Karsten Hopp 81c285
-     alist_unlink(win->w_alist);
Karsten Hopp 81c285
- 
Karsten Hopp 81c285
      /* Remove the window and its frame from the tree of frames. */
Karsten Hopp 81c285
      frp = win->w_frame;
Karsten Hopp 81c285
      wp = winframe_remove(win, dirp, tp);
Karsten Hopp 81c285
--- 2354,2359 ----
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 2386,2394 ****
Karsten Hopp 81c285
  	tabpage_close(TRUE);
Karsten Hopp 81c285
  # endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
-     while (firstwin != NULL)
Karsten Hopp 81c285
- 	(void)win_free_mem(firstwin, &dummy, NULL);
Karsten Hopp 81c285
- 
Karsten Hopp 81c285
  # ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
      if (aucmd_win != NULL)
Karsten Hopp 81c285
      {
Karsten Hopp 81c285
--- 2379,2384 ----
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 2396,2401 ****
Karsten Hopp 81c285
--- 2386,2394 ----
Karsten Hopp 81c285
  	aucmd_win = NULL;
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  # endif
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
+     while (firstwin != NULL)
Karsten Hopp 81c285
+ 	(void)win_free_mem(firstwin, &dummy, NULL);
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 3204,3230 ****
Karsten Hopp 81c285
      void
Karsten Hopp 81c285
  curwin_init()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     redraw_win_later(curwin, NOT_VALID);
Karsten Hopp 81c285
!     curwin->w_lines_valid = 0;
Karsten Hopp 81c285
!     curwin->w_cursor.lnum = 1;
Karsten Hopp 81c285
!     curwin->w_curswant = curwin->w_cursor.col = 0;
Karsten Hopp 81c285
  #ifdef FEAT_VIRTUALEDIT
Karsten Hopp 81c285
!     curwin->w_cursor.coladd = 0;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
!     curwin->w_pcmark.lnum = 1;	/* pcmark not cleared but set to line 1 */
Karsten Hopp 81c285
!     curwin->w_pcmark.col = 0;
Karsten Hopp 81c285
!     curwin->w_prev_pcmark.lnum = 0;
Karsten Hopp 81c285
!     curwin->w_prev_pcmark.col = 0;
Karsten Hopp 81c285
!     curwin->w_topline = 1;
Karsten Hopp 81c285
  #ifdef FEAT_DIFF
Karsten Hopp 81c285
!     curwin->w_topfill = 0;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
!     curwin->w_botline = 2;
Karsten Hopp 81c285
  #ifdef FEAT_FKMAP
Karsten Hopp 81c285
!     if (curwin->w_p_rl)
Karsten Hopp 81c285
! 	curwin->w_farsi = W_CONV + W_R_L;
Karsten Hopp 81c285
      else
Karsten Hopp 81c285
! 	curwin->w_farsi = W_CONV;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
--- 3197,3230 ----
Karsten Hopp 81c285
      void
Karsten Hopp 81c285
  curwin_init()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
!     win_init_empty(curwin);
Karsten Hopp 81c285
! }
Karsten Hopp 81c285
! 
Karsten Hopp 81c285
!     void
Karsten Hopp 81c285
! win_init_empty(wp)
Karsten Hopp 81c285
!     win_T *wp;
Karsten Hopp 81c285
! {
Karsten Hopp 81c285
!     redraw_win_later(wp, NOT_VALID);
Karsten Hopp 81c285
!     wp->w_lines_valid = 0;
Karsten Hopp 81c285
!     wp->w_cursor.lnum = 1;
Karsten Hopp 81c285
!     wp->w_curswant = wp->w_cursor.col = 0;
Karsten Hopp 81c285
  #ifdef FEAT_VIRTUALEDIT
Karsten Hopp 81c285
!     wp->w_cursor.coladd = 0;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
!     wp->w_pcmark.lnum = 1;	/* pcmark not cleared but set to line 1 */
Karsten Hopp 81c285
!     wp->w_pcmark.col = 0;
Karsten Hopp 81c285
!     wp->w_prev_pcmark.lnum = 0;
Karsten Hopp 81c285
!     wp->w_prev_pcmark.col = 0;
Karsten Hopp 81c285
!     wp->w_topline = 1;
Karsten Hopp 81c285
  #ifdef FEAT_DIFF
Karsten Hopp 81c285
!     wp->w_topfill = 0;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
!     wp->w_botline = 2;
Karsten Hopp 81c285
  #ifdef FEAT_FKMAP
Karsten Hopp 81c285
!     if (wp->w_p_rl)
Karsten Hopp 81c285
! 	wp->w_farsi = W_CONV + W_R_L;
Karsten Hopp 81c285
      else
Karsten Hopp 81c285
! 	wp->w_farsi = W_CONV;
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 4325,4330 ****
Karsten Hopp 81c285
--- 4325,4337 ----
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      int		i;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
+ #ifdef FEAT_FOLDING
Karsten Hopp 81c285
+     clearFolding(wp);
Karsten Hopp 81c285
+ #endif
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
+     /* reduce the reference count to the argument list. */
Karsten Hopp 81c285
+     alist_unlink(wp->w_alist);
Karsten Hopp 81c285
+ 
Karsten Hopp 81c285
  #ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
      /* Don't execute autocommands while the window is halfway being deleted.
Karsten Hopp 81c285
       * gui_mch_destroy_scrollbar() may trigger a FocusGained event. */
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 4387,4393 ****
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  #endif /* FEAT_GUI */
Karsten Hopp 81c285
  
Karsten Hopp 81c285
!     win_remove(wp, tp);
Karsten Hopp 81c285
      vim_free(wp);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
--- 4394,4403 ----
Karsten Hopp 81c285
      }
Karsten Hopp 81c285
  #endif /* FEAT_GUI */
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! #ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
!     if (wp != aucmd_win)
Karsten Hopp 81c285
! #endif
Karsten Hopp 81c285
! 	win_remove(wp, tp);
Karsten Hopp 81c285
      vim_free(wp);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #ifdef FEAT_AUTOCMD
Karsten Hopp 81c285
*** ../vim-7.2.214/src/version.c	2009-06-24 17:04:40.000000000 +0200
Karsten Hopp 81c285
--- src/version.c	2009-06-24 17:27:38.000000000 +0200
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 678,679 ****
Karsten Hopp 81c285
--- 678,681 ----
Karsten Hopp 81c285
  {   /* Add new patch number below this line */
Karsten Hopp 81c285
+ /**/
Karsten Hopp 81c285
+     215,
Karsten Hopp 81c285
  /**/
Karsten Hopp 81c285
Karsten Hopp 81c285
-- 
Karsten Hopp 81c285
Micro$oft: where do you want to go today?
Karsten Hopp 81c285
    Linux: where do you want to go tomorrow?
Karsten Hopp 81c285
  FreeBSD: are you guys coming, or what?
Karsten Hopp 81c285
Karsten Hopp 81c285
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 81c285
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 81c285
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 81c285
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///