Karsten Hopp de888e
To: vim_dev@googlegroups.com
Karsten Hopp de888e
Subject: Patch 7.3.052
Karsten Hopp de888e
Fcc: outbox
Karsten Hopp de888e
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp de888e
Mime-Version: 1.0
Karsten Hopp de888e
Content-Type: text/plain; charset=UTF-8
Karsten Hopp de888e
Content-Transfer-Encoding: 8bit
Karsten Hopp de888e
------------
Karsten Hopp de888e
Karsten Hopp de888e
Patch 7.3.052
Karsten Hopp de888e
Problem:    When 'completefunc' opens a new window all kinds of errors follow.
Karsten Hopp de888e
	    (Xavier Deguillard)
Karsten Hopp de888e
Solution:   When 'completefunc' goes to another window or buffer and when it
Karsten Hopp de888e
	    deletes text abort completion.  Add a test for 'completefunc'.
Karsten Hopp de888e
Files:	    src/edit.c, src/testdir/Make_amiga.mak, src/testdir/Make_dos.mak,
Karsten Hopp de888e
	    src/testdir/Make_ming.mak, src/testdir/Make_os2.mak,
Karsten Hopp de888e
	    src/testdir/Make_vms.mms, src/testdir/Makefile,
Karsten Hopp de888e
	    src/testdir/test76.in, src/testdir/test76.ok
Karsten Hopp de888e
Karsten Hopp de888e
Karsten Hopp de888e
*** ../vim-7.3.051/src/edit.c	2010-08-15 21:57:25.000000000 +0200
Karsten Hopp de888e
--- src/edit.c	2010-11-10 16:50:12.000000000 +0100
Karsten Hopp de888e
***************
Karsten Hopp de888e
*** 58,63 ****
Karsten Hopp de888e
--- 58,67 ----
Karsten Hopp de888e
  };
Karsten Hopp de888e
  
Karsten Hopp de888e
  static char e_hitend[] = N_("Hit end of paragraph");
Karsten Hopp de888e
+ #ifdef FEAT_COMPL_FUNC
Karsten Hopp de888e
+ static char e_complwin[] = N_("E839: Completion function changed window");
Karsten Hopp de888e
+ static char e_compldel[] = N_("E840: Completion function deleted text");
Karsten Hopp de888e
+ #endif
Karsten Hopp de888e
  
Karsten Hopp de888e
  /*
Karsten Hopp de888e
   * Structure used to store one match for insert completion.
Karsten Hopp de888e
***************
Karsten Hopp de888e
*** 3833,3838 ****
Karsten Hopp de888e
--- 3837,3844 ----
Karsten Hopp de888e
      char_u	*args[2];
Karsten Hopp de888e
      char_u	*funcname;
Karsten Hopp de888e
      pos_T	pos;
Karsten Hopp de888e
+     win_T	*curwin_save;
Karsten Hopp de888e
+     buf_T	*curbuf_save;
Karsten Hopp de888e
  
Karsten Hopp de888e
      funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu;
Karsten Hopp de888e
      if (*funcname == NUL)
Karsten Hopp de888e
***************
Karsten Hopp de888e
*** 3843,3855 ****
Karsten Hopp de888e
      args[1] = base;
Karsten Hopp de888e
  
Karsten Hopp de888e
      pos = curwin->w_cursor;
Karsten Hopp de888e
      matchlist = call_func_retlist(funcname, 2, args, FALSE);
Karsten Hopp de888e
      curwin->w_cursor = pos;	/* restore the cursor position */
Karsten Hopp de888e
!     if (matchlist == NULL)
Karsten Hopp de888e
! 	return;
Karsten Hopp de888e
  
Karsten Hopp de888e
!     ins_compl_add_list(matchlist);
Karsten Hopp de888e
!     list_unref(matchlist);
Karsten Hopp de888e
  }
Karsten Hopp de888e
  #endif /* FEAT_COMPL_FUNC */
Karsten Hopp de888e
  
Karsten Hopp de888e
--- 3849,3875 ----
Karsten Hopp de888e
      args[1] = base;
Karsten Hopp de888e
  
Karsten Hopp de888e
      pos = curwin->w_cursor;
Karsten Hopp de888e
+     curwin_save = curwin;
Karsten Hopp de888e
+     curbuf_save = curbuf;
Karsten Hopp de888e
      matchlist = call_func_retlist(funcname, 2, args, FALSE);
Karsten Hopp de888e
+     if (curwin_save != curwin || curbuf_save != curbuf)
Karsten Hopp de888e
+     {
Karsten Hopp de888e
+ 	EMSG(_(e_complwin));
Karsten Hopp de888e
+ 	goto theend;
Karsten Hopp de888e
+     }
Karsten Hopp de888e
      curwin->w_cursor = pos;	/* restore the cursor position */
Karsten Hopp de888e
!     check_cursor();
Karsten Hopp de888e
!     if (!equalpos(curwin->w_cursor, pos))
Karsten Hopp de888e
!     {
Karsten Hopp de888e
! 	EMSG(_(e_compldel));
Karsten Hopp de888e
! 	goto theend;
Karsten Hopp de888e
!     }
Karsten Hopp de888e
!     if (matchlist != NULL)
Karsten Hopp de888e
! 	ins_compl_add_list(matchlist);
Karsten Hopp de888e
  
Karsten Hopp de888e
! theend:
Karsten Hopp de888e
!     if (matchlist != NULL)
Karsten Hopp de888e
! 	list_unref(matchlist);
Karsten Hopp de888e
  }
Karsten Hopp de888e
  #endif /* FEAT_COMPL_FUNC */
Karsten Hopp de888e
  
Karsten Hopp de888e
***************
Karsten Hopp de888e
*** 4994,4999 ****
Karsten Hopp de888e
--- 5014,5021 ----
Karsten Hopp de888e
  	    int		col;
Karsten Hopp de888e
  	    char_u	*funcname;
Karsten Hopp de888e
  	    pos_T	pos;
Karsten Hopp de888e
+ 	    win_T	*curwin_save;
Karsten Hopp de888e
+ 	    buf_T	*curbuf_save;
Karsten Hopp de888e
  
Karsten Hopp de888e
  	    /* Call 'completefunc' or 'omnifunc' and get pattern length as a
Karsten Hopp de888e
  	     * string */
Karsten Hopp de888e
***************
Karsten Hopp de888e
*** 5009,5016 ****
Karsten Hopp de888e
--- 5031,5051 ----
Karsten Hopp de888e
  	    args[0] = (char_u *)"1";
Karsten Hopp de888e
  	    args[1] = NULL;
Karsten Hopp de888e
  	    pos = curwin->w_cursor;
Karsten Hopp de888e
+ 	    curwin_save = curwin;
Karsten Hopp de888e
+ 	    curbuf_save = curbuf;
Karsten Hopp de888e
  	    col = call_func_retnr(funcname, 2, args, FALSE);
Karsten Hopp de888e
+ 	    if (curwin_save != curwin || curbuf_save != curbuf)
Karsten Hopp de888e
+ 	    {
Karsten Hopp de888e
+ 		EMSG(_(e_complwin));
Karsten Hopp de888e
+ 		return FAIL;
Karsten Hopp de888e
+ 	    }
Karsten Hopp de888e
  	    curwin->w_cursor = pos;	/* restore the cursor position */
Karsten Hopp de888e
+ 	    check_cursor();
Karsten Hopp de888e
+ 	    if (!equalpos(curwin->w_cursor, pos))
Karsten Hopp de888e
+ 	    {
Karsten Hopp de888e
+ 		EMSG(_(e_compldel));
Karsten Hopp de888e
+ 		return FAIL;
Karsten Hopp de888e
+ 	    }
Karsten Hopp de888e
  
Karsten Hopp de888e
  	    if (col < 0)
Karsten Hopp de888e
  		col = curs_col;
Karsten Hopp de888e
*** ../vim-7.3.051/src/testdir/Make_amiga.mak	2010-10-27 18:36:32.000000000 +0200
Karsten Hopp de888e
--- src/testdir/Make_amiga.mak	2010-11-10 15:48:30.000000000 +0100
Karsten Hopp de888e
***************
Karsten Hopp de888e
*** 27,33 ****
Karsten Hopp de888e
  		test56.out test57.out test58.out test59.out test60.out \
Karsten Hopp de888e
  		test61.out test62.out test63.out test64.out test65.out \
Karsten Hopp de888e
  		test66.out test67.out test68.out test69.out test70.out \
Karsten Hopp de888e
! 		test71.out test72.out test73.out test74.out test75.out
Karsten Hopp de888e
  
Karsten Hopp de888e
  .SUFFIXES: .in .out
Karsten Hopp de888e
  
Karsten Hopp de888e
--- 27,34 ----
Karsten Hopp de888e
  		test56.out test57.out test58.out test59.out test60.out \
Karsten Hopp de888e
  		test61.out test62.out test63.out test64.out test65.out \
Karsten Hopp de888e
  		test66.out test67.out test68.out test69.out test70.out \
Karsten Hopp de888e
! 		test71.out test72.out test73.out test74.out test75.out \
Karsten Hopp de888e
! 		test76.out
Karsten Hopp de888e
  
Karsten Hopp de888e
  .SUFFIXES: .in .out
Karsten Hopp de888e
  
Karsten Hopp de888e
***************
Karsten Hopp de888e
*** 122,124 ****
Karsten Hopp de888e
--- 123,126 ----
Karsten Hopp de888e
  test73.out: test73.in
Karsten Hopp de888e
  test74.out: test74.in
Karsten Hopp de888e
  test75.out: test75.in
Karsten Hopp de888e
+ test76.out: test76.in
Karsten Hopp de888e
*** ../vim-7.3.051/src/testdir/Make_dos.mak	2010-10-27 18:36:32.000000000 +0200
Karsten Hopp de888e
--- src/testdir/Make_dos.mak	2010-11-10 15:48:38.000000000 +0100
Karsten Hopp de888e
***************
Karsten Hopp de888e
*** 28,34 ****
Karsten Hopp de888e
  		test37.out test38.out test39.out test40.out test41.out \
Karsten Hopp de888e
  		test42.out test52.out test65.out test66.out test67.out \
Karsten Hopp de888e
  		test68.out test69.out test71.out test72.out test73.out \
Karsten Hopp de888e
! 		test74.out test75.out
Karsten Hopp de888e
  
Karsten Hopp de888e
  SCRIPTS32 =	test50.out test70.out
Karsten Hopp de888e
  
Karsten Hopp de888e
--- 28,34 ----
Karsten Hopp de888e
  		test37.out test38.out test39.out test40.out test41.out \
Karsten Hopp de888e
  		test42.out test52.out test65.out test66.out test67.out \
Karsten Hopp de888e
  		test68.out test69.out test71.out test72.out test73.out \
Karsten Hopp de888e
! 		test74.out test75.out test76.out
Karsten Hopp de888e
  
Karsten Hopp de888e
  SCRIPTS32 =	test50.out test70.out
Karsten Hopp de888e
  
Karsten Hopp de888e
*** ../vim-7.3.051/src/testdir/Make_ming.mak	2010-10-27 18:36:32.000000000 +0200
Karsten Hopp de888e
--- src/testdir/Make_ming.mak	2010-11-10 15:48:53.000000000 +0100
Karsten Hopp de888e
***************
Karsten Hopp de888e
*** 48,54 ****
Karsten Hopp de888e
  		test37.out test38.out test39.out test40.out test41.out \
Karsten Hopp de888e
  		test42.out test52.out test65.out test66.out test67.out \
Karsten Hopp de888e
  		test68.out test69.out test71.out test72.out test73.out \
Karsten Hopp de888e
! 		test74.out test75.out
Karsten Hopp de888e
  
Karsten Hopp de888e
  SCRIPTS32 =	test50.out test70.out
Karsten Hopp de888e
  
Karsten Hopp de888e
--- 48,54 ----
Karsten Hopp de888e
  		test37.out test38.out test39.out test40.out test41.out \
Karsten Hopp de888e
  		test42.out test52.out test65.out test66.out test67.out \
Karsten Hopp de888e
  		test68.out test69.out test71.out test72.out test73.out \
Karsten Hopp de888e
! 		test74.out test75.out test76.out
Karsten Hopp de888e
  
Karsten Hopp de888e
  SCRIPTS32 =	test50.out test70.out
Karsten Hopp de888e
  
Karsten Hopp de888e
*** ../vim-7.3.051/src/testdir/Make_os2.mak	2010-10-27 18:36:32.000000000 +0200
Karsten Hopp de888e
--- src/testdir/Make_os2.mak	2010-11-10 15:49:10.000000000 +0100
Karsten Hopp de888e
***************
Karsten Hopp de888e
*** 27,33 ****
Karsten Hopp de888e
  		test56.out test57.out test58.out test59.out test60.out \
Karsten Hopp de888e
  		test61.out test62.out test63.out test64.out test65.out \
Karsten Hopp de888e
  		test66.out test67.out test68.out test69.out test70.out \
Karsten Hopp de888e
! 		test71.out test72.out test73.out test74.out test75.out
Karsten Hopp de888e
  
Karsten Hopp de888e
  .SUFFIXES: .in .out
Karsten Hopp de888e
  
Karsten Hopp de888e
--- 27,34 ----
Karsten Hopp de888e
  		test56.out test57.out test58.out test59.out test60.out \
Karsten Hopp de888e
  		test61.out test62.out test63.out test64.out test65.out \
Karsten Hopp de888e
  		test66.out test67.out test68.out test69.out test70.out \
Karsten Hopp de888e
! 		test71.out test72.out test73.out test74.out test75.out \
Karsten Hopp de888e
! 		test76.out
Karsten Hopp de888e
  
Karsten Hopp de888e
  .SUFFIXES: .in .out
Karsten Hopp de888e
  
Karsten Hopp de888e
*** ../vim-7.3.051/src/testdir/Make_vms.mms	2010-10-27 18:36:32.000000000 +0200
Karsten Hopp de888e
--- src/testdir/Make_vms.mms	2010-11-10 15:49:32.000000000 +0100
Karsten Hopp de888e
***************
Karsten Hopp de888e
*** 4,10 ****
Karsten Hopp de888e
  # Authors:	Zoltan Arpadffy, <arpadffy@polarhome.com>
Karsten Hopp de888e
  #		Sandor Kopanyi,  <sandor.kopanyi@mailbox.hu>
Karsten Hopp de888e
  #
Karsten Hopp de888e
! # Last change:  2010 Oct 20
Karsten Hopp de888e
  #
Karsten Hopp de888e
  # This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
Karsten Hopp de888e
  # Edit the lines in the Configuration section below to select.
Karsten Hopp de888e
--- 4,10 ----
Karsten Hopp de888e
  # Authors:	Zoltan Arpadffy, <arpadffy@polarhome.com>
Karsten Hopp de888e
  #		Sandor Kopanyi,  <sandor.kopanyi@mailbox.hu>
Karsten Hopp de888e
  #
Karsten Hopp de888e
! # Last change:  2010 Nov 10
Karsten Hopp de888e
  #
Karsten Hopp de888e
  # This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
Karsten Hopp de888e
  # Edit the lines in the Configuration section below to select.
Karsten Hopp de888e
***************
Karsten Hopp de888e
*** 74,80 ****
Karsten Hopp de888e
  	 test56.out test57.out test60.out \
Karsten Hopp de888e
  	 test61.out test62.out test63.out test64.out test65.out \
Karsten Hopp de888e
  	 test66.out test67.out test68.out test69.out \
Karsten Hopp de888e
! 	 test71.out test72.out test74.out test75.out
Karsten Hopp de888e
  
Karsten Hopp de888e
  # Known problems:
Karsten Hopp de888e
  # Test 30: a problem around mac format - unknown reason
Karsten Hopp de888e
--- 74,80 ----
Karsten Hopp de888e
  	 test56.out test57.out test60.out \
Karsten Hopp de888e
  	 test61.out test62.out test63.out test64.out test65.out \
Karsten Hopp de888e
  	 test66.out test67.out test68.out test69.out \
Karsten Hopp de888e
! 	 test71.out test72.out test74.out test75.out test76.out
Karsten Hopp de888e
  
Karsten Hopp de888e
  # Known problems:
Karsten Hopp de888e
  # Test 30: a problem around mac format - unknown reason
Karsten Hopp de888e
*** ../vim-7.3.051/src/testdir/Makefile	2010-10-27 18:36:32.000000000 +0200
Karsten Hopp de888e
--- src/testdir/Makefile	2010-11-10 15:47:32.000000000 +0100
Karsten Hopp de888e
***************
Karsten Hopp de888e
*** 25,31 ****
Karsten Hopp de888e
  		test59.out test60.out test61.out test62.out test63.out \
Karsten Hopp de888e
  		test64.out test65.out test66.out test67.out test68.out \
Karsten Hopp de888e
  		test69.out test70.out test71.out test72.out test73.out \
Karsten Hopp de888e
! 		test74.out test75.out
Karsten Hopp de888e
  
Karsten Hopp de888e
  SCRIPTS_GUI = test16.out
Karsten Hopp de888e
  
Karsten Hopp de888e
--- 25,31 ----
Karsten Hopp de888e
  		test59.out test60.out test61.out test62.out test63.out \
Karsten Hopp de888e
  		test64.out test65.out test66.out test67.out test68.out \
Karsten Hopp de888e
  		test69.out test70.out test71.out test72.out test73.out \
Karsten Hopp de888e
! 		test74.out test75.out test76.out
Karsten Hopp de888e
  
Karsten Hopp de888e
  SCRIPTS_GUI = test16.out
Karsten Hopp de888e
  
Karsten Hopp de888e
*** ../vim-7.3.051/src/testdir/test76.in	2010-11-10 16:51:45.000000000 +0100
Karsten Hopp de888e
--- src/testdir/test76.in	2010-11-10 16:38:45.000000000 +0100
Karsten Hopp de888e
***************
Karsten Hopp de888e
*** 0 ****
Karsten Hopp de888e
--- 1,46 ----
Karsten Hopp de888e
+ Tests for completefunc/omnifunc. vim: set ft=vim :
Karsten Hopp de888e
+ 
Karsten Hopp de888e
+ STARTTEST
Karsten Hopp de888e
+ :"Test that nothing happens if the 'completefunc' opens
Karsten Hopp de888e
+ :"a new window (no completion, no crash)
Karsten Hopp de888e
+ :so small.vim
Karsten Hopp de888e
+ :function! DummyCompleteOne(findstart, base)
Karsten Hopp de888e
+ :  if a:findstart
Karsten Hopp de888e
+ :    return 0
Karsten Hopp de888e
+ :  else
Karsten Hopp de888e
+ :    wincmd n
Karsten Hopp de888e
+ :    return ['onedef', 'oneDEF']
Karsten Hopp de888e
+ :  endif
Karsten Hopp de888e
+ :endfunction
Karsten Hopp de888e
+ :setlocal completefunc=DummyCompleteOne
Karsten Hopp de888e
+ /^one
Karsten Hopp de888e
+ A????:q!
Karsten Hopp de888e
+ :function! DummyCompleteTwo(findstart, base)
Karsten Hopp de888e
+ :  if a:findstart
Karsten Hopp de888e
+ :    wincmd n
Karsten Hopp de888e
+ :    return 0
Karsten Hopp de888e
+ :  else
Karsten Hopp de888e
+ :    return ['twodef', 'twoDEF']
Karsten Hopp de888e
+ :  endif
Karsten Hopp de888e
+ :endfunction
Karsten Hopp de888e
+ :setlocal completefunc=DummyCompleteTwo
Karsten Hopp de888e
+ /^two
Karsten Hopp de888e
+ A????:q!
Karsten Hopp de888e
+ :"Test that 'completefunc' works when it's OK.
Karsten Hopp de888e
+ :function! DummyCompleteThree(findstart, base)
Karsten Hopp de888e
+ :  if a:findstart
Karsten Hopp de888e
+ :    return 0
Karsten Hopp de888e
+ :  else
Karsten Hopp de888e
+ :    return ['threedef', 'threeDEF']
Karsten Hopp de888e
+ :  endif
Karsten Hopp de888e
+ :endfunction
Karsten Hopp de888e
+ :setlocal completefunc=DummyCompleteThree
Karsten Hopp de888e
+ /^three
Karsten Hopp de888e
+ A????:/^+++/,/^three/w! test.out
Karsten Hopp de888e
+ :qa!
Karsten Hopp de888e
+ ENDTEST
Karsten Hopp de888e
+ 
Karsten Hopp de888e
+ +++
Karsten Hopp de888e
+ one
Karsten Hopp de888e
+ two
Karsten Hopp de888e
+ three
Karsten Hopp de888e
*** ../vim-7.3.051/src/testdir/test76.ok	2010-11-10 16:51:45.000000000 +0100
Karsten Hopp de888e
--- src/testdir/test76.ok	2010-11-10 16:38:58.000000000 +0100
Karsten Hopp de888e
***************
Karsten Hopp de888e
*** 0 ****
Karsten Hopp de888e
--- 1,4 ----
Karsten Hopp de888e
+ +++
Karsten Hopp de888e
+ 
Karsten Hopp de888e
+ two
Karsten Hopp de888e
+ threeDEF
Karsten Hopp de888e
*** ../vim-7.3.051/src/version.c	2010-11-10 15:37:00.000000000 +0100
Karsten Hopp de888e
--- src/version.c	2010-11-10 16:40:29.000000000 +0100
Karsten Hopp de888e
***************
Karsten Hopp de888e
*** 716,717 ****
Karsten Hopp de888e
--- 716,719 ----
Karsten Hopp de888e
  {   /* Add new patch number below this line */
Karsten Hopp de888e
+ /**/
Karsten Hopp de888e
+     52,
Karsten Hopp de888e
  /**/
Karsten Hopp de888e
Karsten Hopp de888e
-- 
Karsten Hopp de888e
BRIDGEKEEPER: What is the air-speed velocity of an unladen swallow?
Karsten Hopp de888e
ARTHUR:       What do you mean?  An African or European swallow?
Karsten Hopp de888e
BRIDGEKEEPER: Er ...  I don't know that ... Aaaaarrrrrrggghhh!
Karsten Hopp de888e
   BRIDGEKEEPER is cast into the gorge.
Karsten Hopp de888e
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp de888e
Karsten Hopp de888e
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp de888e
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp de888e
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp de888e
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///