Re: [vim/vim] Regression: completefunc cannot temporarily switch windows any longer (after 8.2.0614) (#6017)

2020-04-30 Thread Yegappan Lakshmanan
Hi,

On Thu, Apr 30, 2020 at 9:02 AM Ingo Karkat 
wrote:

> *Describe the bug*
> :help E840  (under :help
> complete-items
> ) reads
>
> The function is not allowed to move to another window or delete text.
>
> Previously, *move to another window* meant that after the completefunc
> finishes, the current window has to be the same as the original one (where
> the completion was triggered). *Temporarily* switching windows (and going
> back) used to work fine. Since this change:
>
> commit ff06f28
> 
> Author: Bram Moolenaar b...@vim.org
> Date: 2020-04-21 22:01:14 +0200
>
> patch 8.2.0614: get ml_get error when deleting a line in 'completefunc'
>
> *Expected behavior*
> I understand the motivation to prevent unexpected changes during
> completion. However, switching to other windows *temporarily* should be
> harmless, is convenient to implement custom completions [1], and sometimes
> even necessary [2].
>
>1. In an attempt to simplify the implementation of custom completions,
>my CompleteHelper plugin
> searches other
>windows in order to offer the same functionality as :set complete+=w.
>2. In many cases, the matching of completion candidates could be done
>without going to the corresponding window (e.g. using getbufline()),
>but as matching in the current buffer usually is done via search(), it
>is convenient to reuse that simple implementation for other windows as
>well. I have some completions like the MotionComplete plugin
> that uses a
>queried {motion} to obtain matches. That could *not* be emulated via
>low-level string-matching functions, but really has to be executed in that
>buffer. (And in order to use other windows as sources, it has to go there.)
>
>
Instead of switching to the window, if you use the win_execute() function
to run
a command in a particular window from the custom complete function, does
this
error happen?

- Yegappan

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7kRYWYNhSTg94zQFHNEdqLx0F5v2Rb%3DvrckeCZi_TvN7g%40mail.gmail.com.


Patch 8.2.0665

2020-04-30 Thread Bram Moolenaar


Patch 8.2.0665
Problem:Wrongly assuming Python executable is called "python".
Solution:   Use detected python command. (Ken Takata, closes #6016)
Also use CheckFunction if possible.
Files:  src/testdir/test_terminal.vim, src/testdir/check.vim


*** ../vim-8.2.0664/src/testdir/test_terminal.vim   2020-04-26 
15:59:51.206952132 +0200
--- src/testdir/test_terminal.vim   2020-04-30 19:06:52.830349912 +0200
***
*** 715,724 
  endfunc
  
  func Test_terminal_eof_arg()
!   CheckExecutable python
  
call setline(1, ['print("hello")'])
!   1term ++eof=exit(123) python
" MS-Windows echoes the input, Unix doesn't.
if has('win32')
  call WaitFor({-> getline('$') =~ 'exit(123)'})
--- 715,724 
  endfunc
  
  func Test_terminal_eof_arg()
!   call CheckPython(s:python)
  
call setline(1, ['print("hello")'])
!   exe '1term ++eof=exit(123) ' .. s:python
" MS-Windows echoes the input, Unix doesn't.
if has('win32')
  call WaitFor({-> getline('$') =~ 'exit(123)'})
***
*** 733,754 
  
  func Test_terminal_eof_arg_win32_ctrl_z()
CheckMSWindows
!   CheckExecutable python
  
call setline(1, ['print("hello")'])
!   1term ++eof= python
call WaitForAssert({-> assert_match('\^Z', getline(line('$') - 1))})
call assert_match('\^Z', getline(line('$') - 1))
%bwipe!
  endfunc
  
  func Test_terminal_duplicate_eof_arg()
!   CheckExecutable python
  
" Check the last specified ++eof arg is used and should not memory leak.
new
call setline(1, ['print("hello")'])
!   1term ++eof= ++eof=exit(123) python
" MS-Windows echoes the input, Unix doesn't.
if has('win32')
  call WaitFor({-> getline('$') =~ 'exit(123)'})
--- 733,754 
  
  func Test_terminal_eof_arg_win32_ctrl_z()
CheckMSWindows
!   call CheckPython(s:python)
  
call setline(1, ['print("hello")'])
!   exe '1term ++eof= ' .. s:python
call WaitForAssert({-> assert_match('\^Z', getline(line('$') - 1))})
call assert_match('\^Z', getline(line('$') - 1))
%bwipe!
  endfunc
  
  func Test_terminal_duplicate_eof_arg()
!   call CheckPython(s:python)
  
" Check the last specified ++eof arg is used and should not memory leak.
new
call setline(1, ['print("hello")'])
!   exe '1term ++eof= ++eof=exit(123) ' .. s:python
" MS-Windows echoes the input, Unix doesn't.
if has('win32')
  call WaitFor({-> getline('$') =~ 'exit(123)'})
***
*** 1571,1579 
  endfunc
  
  func Test_terminal_ansicolors_default()
!   if !exists('*term_getansicolors')
! throw 'Skipped: term_getansicolors() not supported'
!   endif
let colors = [
\ '#00', '#e0',
\ '#00e000', '#e0e000',
--- 1571,1578 
  endfunc
  
  func Test_terminal_ansicolors_default()
!   CheckFunction term_getansicolors
! 
let colors = [
\ '#00', '#e0',
\ '#00e000', '#e0e000',
***
*** 1606,1614 
  
  func Test_terminal_ansicolors_global()
CheckFeature termguicolors
!   if !exists('*term_getansicolors')
! throw 'Skipped: term_getansicolors() not supported'
!   endif
let g:terminal_ansi_colors = reverse(copy(s:test_colors))
let buf = Run_shell_in_terminal({})
call assert_equal(g:terminal_ansi_colors, term_getansicolors(buf))
--- 1605,1612 
  
  func Test_terminal_ansicolors_global()
CheckFeature termguicolors
!   CheckFunction term_getansicolors
! 
let g:terminal_ansi_colors = reverse(copy(s:test_colors))
let buf = Run_shell_in_terminal({})
call assert_equal(g:terminal_ansi_colors, term_getansicolors(buf))
***
*** 1621,1629 
  
  func Test_terminal_ansicolors_func()
CheckFeature termguicolors
!   if !exists('*term_getansicolors')
! throw 'Skipped: term_getansicolors() not supported'
!   endif
let g:terminal_ansi_colors = reverse(copy(s:test_colors))
let buf = Run_shell_in_terminal({'ansi_colors': s:test_colors})
call assert_equal(s:test_colors, term_getansicolors(buf))
--- 1619,1626 
  
  func Test_terminal_ansicolors_func()
CheckFeature termguicolors
!   CheckFunction term_getansicolors
! 
let g:terminal_ansi_colors = reverse(copy(s:test_colors))
let buf = Run_shell_in_terminal({'ansi_colors': s:test_colors})
call assert_equal(s:test_colors, term_getansicolors(buf))
***
*** 2588,2593 
--- 2585,2591 
  endfunc
  
  func Test_term_nasty_callback()
+   CheckExecutable sh
func OpenTerms()
  set hidden
  let g:buf0 = term_start('sh', #{hidden: 1})
*** ../vim-8.2.0664/src/testdir/check.vim   2020-04-12 17:52:49.429492390 
+0200
--- src/testdir/check.vim   2020-04-30 19:00:37.483570472 +0200
***
*** 52,57 
--- 52,65 
endif
  endfunc
  
+ " Command to check for the presence of python.  Argument should have been
+ " obtained with PythonProg()
+ func CheckPython(name)
+   if a:name == ''
+ throw 'Skipped: python command not available'

Patch 8.2.0666

2020-04-30 Thread Bram Moolenaar


Patch 8.2.0666
Problem:Ruby test fails on MS-Windows.
Solution:   Remove the "maintainer" line. (Ken Takata, closes #6015)
Files:  src/testdir/shared.vim, src/testdir/test_messages.vim,
src/testdir/test_ruby.vim


*** ../vim-8.2.0665/src/testdir/shared.vim  2020-04-04 14:00:34.193098268 
+0200
--- src/testdir/shared.vim  2020-04-30 19:15:28.721517171 +0200
***
*** 338,341 
--- 338,353 
return v:false
  endfunc
  
+ " Get all messages but drop the maintainer entry.
+ func GetMessages()
+   redir => result
+   redraw | messages
+   redir END
+   let msg_list = split(result, "\n")
+   if msg_list->len() > 0 && msg_list[0] =~ 'Messages maintainer:'
+ return msg_list[1:]
+   endif
+   return msg_list
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0665/src/testdir/test_messages.vim   2020-04-25 
17:13:53.248729906 +0200
--- src/testdir/test_messages.vim   2020-04-30 19:15:28.721517171 +0200
***
*** 3,20 
  source shared.vim
  source term_util.vim
  
- " Get all messages but drop the maintainer entry.
- func GetMessages()
-   redir => result
-   redraw | messages
-   redir END
-   let msg_list = split(result, "\n")
-   if msg_list->len() > 0 && msg_list[0] =~ 'Messages maintainer:'
- return msg_list[1:]
-   endif
-   return msg_list
- endfunc
- 
  func Test_messages()
let oldmore = &more
try
--- 3,8 
*** ../vim-8.2.0665/src/testdir/test_ruby.vim   2020-04-14 20:15:45.288566185 
+0200
--- src/testdir/test_ruby.vim   2020-04-30 19:15:28.721517171 +0200
***
*** 378,384 
  
  func Test_ruby_p()
ruby p 'Just a test'
!   let messages = split(execute('message'), "\n")
call assert_equal('"Just a test"', messages[-1])
  
" Check return values of p method
--- 378,384 
  
  func Test_ruby_p()
ruby p 'Just a test'
!   let messages = GetMessages()
call assert_equal('"Just a test"', messages[-1])
  
" Check return values of p method
***
*** 391,397 
messages clear
call assert_equal(v:true, rubyeval('p() == nil'))
  
!   let messages = split(execute('message'), "\n")
call assert_equal(0, len(messages))
  endfunc
  
--- 391,397 
messages clear
call assert_equal(v:true, rubyeval('p() == nil'))
  
!   let messages = GetMessages()
call assert_equal(0, len(messages))
  endfunc
  
*** ../vim-8.2.0665/src/version.c   2020-04-30 19:09:31.750196251 +0200
--- src/version.c   2020-04-30 19:17:03.517284982 +0200
***
*** 748,749 
--- 748,751 
  {   /* Add new patch number below this line */
+ /**/
+ 666,
  /**/

-- 
What a wonderfully exciting cough!  Do you mind if I join you?
-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202004301720.03UHK1E4000540%40masaka.moolenaar.net.


Patch 8.2.0667

2020-04-30 Thread Bram Moolenaar


Patch 8.2.0667
Problem:Cannot install Haiku version from source.
Solution:   Update Makefile and rdef file. (Emir Sari, closes #6013)
Files:  Filelist, READMEdir/README_haiku.txt, runtime/doc/os_haiku.txt,
src/Makefile, src/os_haiku.rdef.in, src/os_haiku.rdef


*** ../vim-8.2.0666/Filelist2020-04-29 21:03:51.115170232 +0200
--- Filelist2020-04-30 19:48:46.898670068 +0200
***
*** 610,616 
  SRC_HAIKU =   \
README_haiku.txt \
src/os_haiku.h \
!   src/os_haiku.rdef \
src/gui_haiku.cc \
src/gui_haiku.h \
src/proto/gui_haiku.pro \
--- 610,616 
  SRC_HAIKU =   \
README_haiku.txt \
src/os_haiku.h \
!   src/os_haiku.rdef.in \
src/gui_haiku.cc \
src/gui_haiku.h \
src/proto/gui_haiku.pro \
*** ../vim-8.2.0666/READMEdir/README_haiku.txt  2020-04-23 15:41:21.867364624 
+0200
--- READMEdir/README_haiku.txt  2020-04-30 19:48:46.898670068 +0200
***
*** 10,13 
  - Open a Terminal and type "pkgman install vim", then follow instructions.
  
  If you prefer to install Vim from source, follow the instructions on
! "runtime/doc/os_haiku.txt", "Compiling Haiku" section.
--- 10,13 
  - Open a Terminal and type "pkgman install vim", then follow instructions.
  
  If you prefer to install Vim from source, follow the instructions on
! "runtime/doc/os_haiku.txt", "Compiling Vim" section.
*** ../vim-8.2.0666/runtime/doc/os_haiku.txt2020-04-23 15:41:21.867364624 
+0200
--- runtime/doc/os_haiku.txt2020-04-30 19:50:08.634340923 +0200
***
*** 1,4 
! *os_haiku.txt*For Vim version 8.2.  Last change: 2020 Mar 19
  
  
  VIM REFERENCE MANUALby Bram Moolenaar
--- 1,4 
! *os_haiku.txt*For Vim version 8.2.  Last change: 2020 Apr 30
  
  
  VIM REFERENCE MANUALby Bram Moolenaar
***
*** 46,56 
  
  Haiku uses "ncurses6" as its terminal library, therefore you need to have
  "ncurses6_devel" package installed from HaikuDepot in order to configure
! the Haiku build.
  
  Now you should use "make" to compile Vim, then "make install" to install it.
  For seamless integration into Haiku, the GUI-less vim binary should be
! additionally installed over the GUI version. Typical build commands are: >
  
./configure --prefix=`finddir B_SYSTEM_NONPACKAGED_DIRECTORY` \
  --datarootdir=`finddir B_SYSTEM_NONPACKAGED_DATA_DIRECTORY` \
--- 46,56 
  
  Haiku uses "ncurses6" as its terminal library, therefore you need to have
  "ncurses6_devel" package installed from HaikuDepot in order to configure
! the Haiku build.  Just append "--with-tlib=ncurses6" to ./configure command
  
  Now you should use "make" to compile Vim, then "make install" to install it.
  For seamless integration into Haiku, the GUI-less vim binary should be
! additionally installed over the GUI version.  Typical build commands are:
  
./configure --prefix=`finddir B_SYSTEM_NONPACKAGED_DIRECTORY` \
  --datarootdir=`finddir B_SYSTEM_NONPACKAGED_DATA_DIRECTORY` \
***
*** 70,94 
  
  Normally Vim starts with the GUI if you start it as gvim or vim -g.  The vim
  version with GUI tries to determine if it was started from the Tracker instead
! of the Terminal, and if so, uses the GUI anyway. However, the current 
detection
  scheme is fooled if you use the command "vim - 
  
:version
  
--- 70,97 
  
  Normally Vim starts with the GUI if you start it as gvim or vim -g.  The vim
  version with GUI tries to determine if it was started from the Tracker instead
! of the Terminal, and if so, uses the GUI anyway.  However, the current 
detection
  scheme is fooled if you use the command "vim - 
  
:set guifont=*
  
--- 166,172 
  
  If the font you specify is unavailable, you get the system fixed font.
  
! GUI Font Selection Dialog is available at giving the:
  
:set guifont=*
  
*** ../vim-8.2.0666/src/Makefile2020-04-29 23:11:29.086909215 +0200
--- src/Makefile2020-04-30 19:53:16.085605791 +0200
***
*** 2885,2891 
  clean celan: testclean
-rm -f *.o core $(VIMTARGET).core $(VIMTARGET) vim xxd/*.o
-rm -rf objects
!   -rm -f $(TOOLS) auto/osdef.h auto/pathdef.c auto/if_perl.c 
auto/gui_gtk_gresources.c auto/gui_gtk_gresources.h
-rm -f conftest* *~ auto/link.sed
-rm -f testdir/opt_test.vim
-rm -f $(UNITTEST_TARGETS)
--- 2885,2891 
  clean celan: testclean
-rm -f *.o core $(VIMTARGET).core $(VIMTARGET) vim xxd/*.o
-rm -rf objects
!   -rm -f $(TOOLS) auto/osdef.h auto/pathdef.c auto/if_perl.c 
auto/gui_gtk_gresources.c auto/gui_gtk_gresources.h auto/os_haiku.rdef
-rm -f conftest* *~ auto/link.sed
-rm -f testdir/opt_test.vim
-rm -f $(UNITTEST_TARGETS)
***
*** 3042,3047 

Re: [vim/vim] In bash syntax you can't escape a backquote in a double-quoted string. (#5991)

2020-04-30 Thread 'Andy Wokula' via vim_dev

Am 26.04.2020 um 18:03 schrieb Charles Campbell:

John Little wrote:

This is a regression, the syntax/sh.vim from 2019-06-16 does not show
this problem.

The maintainer of this syntax script has his own version numbering,
and if you want to report problems he usually will first ask that you
try the latest script from his web site, which is version 190. It has
the problem.  The version on github is 189, dated 2019-10-16.
Version 188, which I have from the Ubuntu 20.04 repository, does not
show the problem. (Neither do versions 125, 133, or 179, which I had
lying around.)


I see the problem.  As you can easily check, putting a space right
before the backslash fixes the highlighting.  From syntax
highlighting's perspective:

* something preceded by an even number of backslashes should not be
  escaped (and thus be normally highlighted)
* something preceded by an odd number of backslashes should be escaped
  (and thus highlighted with special highlighting)

However, in this case the backslash is preceded by the double-quote
which starts a string region.  The attempt to check for an odd/even
number of backslashes fails,


maybe you just assumed this check is needed while it actually isn't?

You probably mean the following rule:

:syn match   shSpecialDQ "[^\\]\zs\%(\)*\\[\\"'`$()#]"


and thus the backquote is recognized incorrectly as beginning an
in-string command rather than being escaped.  Not checking for that
even/odd number of backslashes is obviously going to cause bad
highlighting.


At least for me it isn't obvious.


I need some way to check that a pattern is beginning with a backslash
in a region, and thus can do without the odd-even preceding context
checking.  I've asked Bram for something like a "startgroup=..."
expression (similar to nextgroup=...) wherein I could do just that.


Try this rule instead:

:syn match   shSpecialDQ "\\[\\"'`$()#]"


We'll see what happens...
Chip Campbell


Checking history ...

date:Thu May 10 17:35:54 2007 +
summary: updated for version 7.1b
-" Last Change:Sep 15, 2006
-" Version:88
+" Last Change:Dec 12, 2006
+" Version:89
-syn match   shSpecial  "\\[\\\"\'`$()#]"
+syn match   shStringSpecial"\%(\)*\\[\\"'`$()#]"
+syn match   shSpecial  "[^\\]\zs\%(\)*\\[\\"'`$()#]"
+syn match   shSpecial  "^\%(\)*\\[\\"'`$()#]"

Ok, old code already included what I'm about to suggest.
So there must have been a problem ... but I can't find
a problem report.

--
Andy

--
--
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/5EAB12F3.4030200%40yahoo.de.


Patch 8.2.0668

2020-04-30 Thread Bram Moolenaar


Patch 8.2.0668
Problem:Compiler warning for int/size_t usage.
Solution:   Change "int" to "size_t". (Mike Williams)
Files:  src/vim9execute.c


*** ../vim-8.2.0667/src/vim9execute.c   2020-04-27 22:47:45.186176148 +0200
--- src/vim9execute.c   2020-04-30 20:19:42.444313750 +0200
***
*** 653,659 
case ISN_EXECCONCAT:
{
int count = iptr->isn_arg.number;
!   int len = 0;
int pass;
int i;
char_u  *cmd = NULL;
--- 653,659 
case ISN_EXECCONCAT:
{
int count = iptr->isn_arg.number;
!   size_t  len = 0;
int pass;
int i;
char_u  *cmd = NULL;
*** ../vim-8.2.0667/src/version.c   2020-04-30 19:54:04.837418282 +0200
--- src/version.c   2020-04-30 20:20:46.240151697 +0200
***
*** 748,749 
--- 748,751 
  {   /* Add new patch number below this line */
+ /**/
+ 668,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
29. Your phone bill comes to your doorstep in a box.

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202004301822.03UIMWAa023757%40masaka.moolenaar.net.


Patch 8.2.0669

2020-04-30 Thread Bram Moolenaar


Patch 8.2.0669
Problem:MS-Windows: display in VTP is a bit slow.
Solution:   Optimize the code. (Nobuhiro Takasaki, closes #6014)
Files:  src/os_win32.c, src/screen.c


*** ../vim-8.2.0668/src/os_win32.c  2020-04-28 20:44:38.872258441 +0200
--- src/os_win32.c  2020-04-30 20:55:23.813526617 +0200
***
*** 5579,5590 
  COORD coord,
  DWORD n)
  {
- DWORD dwDummy;
- 
- FillConsoleOutputCharacter(g_hConOut, ' ', n, coord, &dwDummy);
- 
  if (!USE_VTP)
!   FillConsoleOutputAttribute(g_hConOut, g_attrCurrent, n, coord, 
&dwDummy);
  else
  {
set_console_color_rgb();
--- 5579,5592 
  COORD coord,
  DWORD n)
  {
  if (!USE_VTP)
! {
!   DWORD dwDummy;
! 
!   FillConsoleOutputCharacter(g_hConOut, ' ', n, coord, &dwDummy);
!   FillConsoleOutputAttribute(g_hConOut, g_attrCurrent, n, coord,
!&dwDummy);
! }
  else
  {
set_console_color_rgb();
***
*** 6036,6058 
  {
  COORD coord = g_coord;
  DWORD written;
! DWORD n, cchwritten, cells;
  static WCHAR*unicodebuf = NULL;
  static intunibuflen = 0;
! int   length;
  int   cp = enc_utf8 ? CP_UTF8 : enc_codepage;
! 
! length = MultiByteToWideChar(cp, 0, (LPCSTR)pchBuf, cbToWrite, 0, 0);
! if (unicodebuf == NULL || length > unibuflen)
  {
!   vim_free(unicodebuf);
!   unicodebuf = LALLOC_MULT(WCHAR, length);
!   unibuflen = length;
  }
- MultiByteToWideChar(cp, 0, (LPCSTR)pchBuf, cbToWrite,
-   unicodebuf, unibuflen);
- 
- cells = mb_string2cells(pchBuf, cbToWrite);
  
  if (!USE_VTP)
  {
--- 6038,6094 
  {
  COORD coord = g_coord;
  DWORD written;
! DWORD n, cchwritten;
! static DWORDcells;
  static WCHAR*unicodebuf = NULL;
  static intunibuflen = 0;
! static intlength;
  int   cp = enc_utf8 ? CP_UTF8 : enc_codepage;
! static WCHAR*utf8spbuf = NULL;
! static intutf8splength;
! static DWORDutf8spcells;
! static WCHAR**utf8usingbuf = &unicodebuf;
! 
! if (cbToWrite != 1 || *pchBuf != ' ' || !enc_utf8)
! {
!   utf8usingbuf = &unicodebuf;
!   do
!   {
!   length = MultiByteToWideChar(cp, 0, (LPCSTR)pchBuf, cbToWrite,
!   unicodebuf, unibuflen);
!   if (length && length <= unibuflen)
!   break;
!   vim_free(unicodebuf);
!   unicodebuf = length ? LALLOC_MULT(WCHAR, length) : NULL;
!   unibuflen = unibuflen ? 0 : length;
!   } while(1);
!   cells = mb_string2cells(pchBuf, cbToWrite);
! }
! else // cbToWrite == 1 && *pchBuf == ' ' && enc_utf8
  {
!   if (utf8usingbuf != &utf8spbuf)
!   {
!   if (utf8spbuf == NULL)
!   {
!   cells = mb_string2cells((char_u *)" ", 1);
!   length = MultiByteToWideChar(CP_UTF8, 0, " ", 1, NULL, 0);
!   utf8spbuf = LALLOC_MULT(WCHAR, length);
!   if (utf8spbuf != NULL)
!   {
!   MultiByteToWideChar(CP_UTF8, 0, " ", 1, utf8spbuf, length);
!   utf8usingbuf = &utf8spbuf;
!   utf8splength = length;
!   utf8spcells = cells;
!   }
!   }
!   else
!   {
!   utf8usingbuf = &utf8spbuf;
!   length = utf8splength;
!   cells = utf8spcells;
!   }
!   }
  }
  
  if (!USE_VTP)
  {
***
*** 6060,6073 
coord, &written);
// When writing fails or didn't write a single character, pretend one
// character was written, otherwise we get stuck.
!   if (WriteConsoleOutputCharacterW(g_hConOut, unicodebuf, length,
coord, &cchwritten) == 0
|| cchwritten == 0 || cchwritten == (DWORD)-1)
cchwritten = 1;
  }
  else
  {
!   if (WriteConsoleW(g_hConOut, unicodebuf, length, &cchwritten,
NULL) == 0 || cchwritten == 0)
cchwritten = 1;
  }
--- 6096,6109 
coord, &written);
// When writing fails or didn't write a single character, pretend one
// character was written, otherwise we get stuck.
!   if (WriteConsoleOutputCharacterW(g_hConOut, *utf8usingbuf, length,
coord, &cchwritten) == 0
|| cchwritten == 0 || cchwritten == (DWORD)-1)
cchwritten = 1;
  }
  else
  {
!   if (WriteConsoleW(g_hConOut, *utf8usingbuf, length, &cchwritten,
NULL) == 0 || cchwritten == 0)
cchwritten = 1;
 

Re: [vim/vim] Regression: completefunc cannot temporarily switch windows any longer (after 8.2.0614) (#6017)

2020-04-30 Thread Yegappan Lakshmanan
Hi,

On Thu, Apr 30, 2020 at 12:04 PM Ingo Karkat 
wrote:

> Yegappan, win_execute() does not cause an error:
>
> fun! TestComplete(findstart, base)
>
> call win_execute(win_getid((winnr() == 1) + 1), 'let g:line = getline(1)')
>
>
You can do this without using a global variable.

 let line = win_execute(win_getid((winnr() == 1) + 1), 'echon
getline(1)')


>
> return (a:findstart ? col('.') : [g:line])
> endfun
>
> However, it wouldn't be trivial to change the plugin, and both the
> translation of currently open windows to ids and the transfer of the data
> (above done via global variable) don't look very elegant. On the other
> hand, win_execute() seems to have at least one nice property that my
> current implementation has to work around: When entering a window, the
> height may increase from 0 (which can happen with *Rolodex mode*) to 1.
> Too bad that it's only been introduced in version 8.2.
>
> Besides, what's the use of E839: Completion function changed window if
> this is now pre-empted by E565: Not allowed to change text here?!
>
>
>
I will let Bram comment on this change.

Regards,
Yegappan

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7kGZ%3DY0%2B-ZxraFRShnaga5gBrOs8FKzo%3D%3D_f%2BB8JUQk8g%40mail.gmail.com.


Patch 8.2.0670

2020-04-30 Thread Bram Moolenaar


Patch 8.2.0670
Problem:Cannot change window when evaluating 'completefunc'.
Solution:   Make a difference between not changing text or buffers and also
not changing window.
Files:  src/ex_getln.c, src/beval.c, src/change.c, src/edit.c, src/eval.c,
src/ex_docmd.c, src/insexpand.c, src/globals.h, src/indent.c,
src/map.c, src/window.c, src/proto/ex_getln.pro, src/register.c,
src/undo.c, src/testdir/test_edit.vim,
src/testdir/test_ins_complete.vim, src/testdir/test_popup.vim


*** ../vim-8.2.0669/src/ex_getln.c  2020-04-29 22:30:09.313356305 +0200
--- src/ex_getln.c  2020-04-30 22:11:16.889611605 +0200
***
*** 1318,1329 
c = get_expr_register();
if (c == '=')
{
!   // Need to save and restore ccline.  And set "textlock"
// to avoid nasty things like going to another buffer when
// evaluating an expression.
!   ++textlock;
p = get_expr_line();
!   --textlock;
  
if (p != NULL)
{
--- 1318,1329 
c = get_expr_register();
if (c == '=')
{
!   // Need to save and restore ccline.  And set "textwinlock"
// to avoid nasty things like going to another buffer when
// evaluating an expression.
!   ++textwinlock;
p = get_expr_line();
!   --textwinlock;
  
if (p != NULL)
{
***
*** 2548,2564 
  
  /*
   * Return TRUE when the text must not be changed and we can't switch to
!  * another window or buffer.  Used when editing the command line, evaluating
   * 'balloonexpr', etc.
   */
  int
! text_locked(void)
  {
  #ifdef FEAT_CMDWIN
  if (cmdwin_type != 0)
return TRUE;
  #endif
! return textlock != 0;
  }
  
  /*
--- 2548,2564 
  
  /*
   * Return TRUE when the text must not be changed and we can't switch to
!  * another window or buffer.  TRUE when editing the command line, evaluating
   * 'balloonexpr', etc.
   */
  int
! text_and_win_locked(void)
  {
  #ifdef FEAT_CMDWIN
  if (cmdwin_type != 0)
return TRUE;
  #endif
! return textwinlock != 0;
  }
  
  /*
***
*** 2578,2587 
--- 2578,2599 
  if (cmdwin_type != 0)
return e_cmdwin;
  #endif
+ if (textwinlock != 0)
+   return e_textwinlock;
  return e_textlock;
  }
  
  /*
+  * Return TRUE when the text must not be changed and/or we cannot switch to
+  * another window.  TRUE while evaluating 'completefunc'.
+  */
+ int
+ text_locked(void)
+ {
+ return text_and_win_locked() || textlock != 0;
+ }
+ 
+ /*
   * Check if "curbuf_lock" or "allbuf_lock" is set and return TRUE when it is
   * and give an error message.
   */
***
*** 3560,3570 
  regname = may_get_selection(regname);
  #endif
  
! // Need to  set "textlock" to avoid nasty things like going to another
  // buffer when evaluating an expression.
! ++textlock;
  i = get_spec_reg(regname, &arg, &allocated, TRUE);
! --textlock;
  
  if (i)
  {
--- 3572,3582 
  regname = may_get_selection(regname);
  #endif
  
! // Need to  set "textwinlock" to avoid nasty things like going to another
  // buffer when evaluating an expression.
! ++textwinlock;
  i = get_spec_reg(regname, &arg, &allocated, TRUE);
! --textwinlock;
  
  if (i)
  {
*** ../vim-8.2.0669/src/beval.c 2020-04-04 14:50:28.931788970 +0200
--- src/beval.c 2020-04-30 21:33:26.549036219 +0200
***
*** 282,288 
curbuf = save_curbuf;
if (use_sandbox)
++sandbox;
!   ++textlock;
  
vim_free(result);
result = eval_to_string(bexpr, NULL, TRUE);
--- 282,288 
curbuf = save_curbuf;
if (use_sandbox)
++sandbox;
!   ++textwinlock;
  
vim_free(result);
result = eval_to_string(bexpr, NULL, TRUE);
***
*** 299,305 
  
if (use_sandbox)
--sandbox;
!   --textlock;
  
set_vim_var_string(VV_BEVAL_TEXT, NULL, -1);
if (result != NULL && result[0] != NUL)
--- 299,305 
  
if (use_sandbox)
--sandbox;
!   --textwinlock;
  
set_vim_var_string(VV_BEVAL_TEXT, NULL, -1);
if (result != NULL && result[0] != NUL)
*** ../vim-8.2.0669/src/change.c2020-04-02 18:50:42.415773144 +0200
--- src/change.c2020-04-30 21:33:47.824949393 +0200
***
*** 382,388 
  
  argv[4].v_type = VAR_LIST;
  argv[4].vval.v_list = buf->b_recorded_changes;
! ++textlock;
  
  for (lnr = buf->b_listener; lnr != NULL; lnr =

Patch 8.2.0671

2020-04-30 Thread Bram Moolenaar


Patch 8.2.0671
Problem:Haiku: compiler warnings.
Solution:   Avoid the warnings. Drop display_errors() copy. (Emir Sari,
closes #6018)
Files:  .gitignore, src/gui.c, src/gui_haiku.cc


*** ../vim-8.2.0670/.gitignore  2020-01-05 22:10:27.787277609 +0100
--- .gitignore  2020-04-30 22:46:58.037950183 +0200
***
*** 5,10 
--- 5,11 
  src/auto/if_perl.c
  src/auto/gui_gtk_gresources.c
  src/auto/gui_gtk_gresources.h
+ src/auto/os_haiku.rdef
  src/objects/.dirstamp
  src/objects
  src/tags
*** ../vim-8.2.0670/src/gui.c   2020-04-20 19:42:06.594078510 +0200
--- src/gui.c   2020-04-30 22:50:14.037228880 +0200
***
*** 5107,5113 
  # endif
  #endif
  
! #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(PROTO)
  void
  display_errors(void)
  {
--- 5107,5114 
  # endif
  #endif
  
! #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)|| defined(FEAT_GUI_HAIKU) \
!   || defined(PROTO)
  void
  display_errors(void)
  {
*** ../vim-8.2.0670/src/gui_haiku.cc2020-04-24 22:16:09.759981331 +0200
--- src/gui_haiku.cc2020-04-30 22:46:58.037950183 +0200
***
*** 551,557 
  };
  
  #define RGB(r, g, b)  ((char_u)(r) << 16 | (char_u)(g) << 8 | (char_u)(b) << 
0)
! #define GUI_TO_RGB(g) { (g) >> 16, (g) >> 8, (g) >> 0, 255 }
  
  //  end of header part 
  
--- 551,557 
  };
  
  #define RGB(r, g, b)  ((char_u)(r) << 16 | (char_u)(g) << 8 | (char_u)(b) << 
0)
! #define GUI_TO_RGB(g) { (char_u)((g) >> 16), (char_u)((g) >> 8), (char_u)((g) 
>> 0), 255 }
  
  //  end of header part 
  
***
*** 3990,4029 
  return OK;
  }
  
- /*
-  * Display the saved error message(s).
-  */
- #ifdef USE_MCH_ERRMSG
- void
- display_errors(void)
- {
- char*p;
- char_u  pError[256];
- 
- if (error_ga.ga_data == NULL)
- return;
- 
- // avoid putting up a message box with blanks only
- for (p = (char *)error_ga.ga_data; *p; ++p)
- if (!isspace(*p))
- {
-   if (STRLEN(p) > 255)
-   pError[0] = 255;
-   else
-   pError[0] = STRLEN(p);
- 
-   STRNCPY(&pError[1], p, pError[0]);
- //ParamText(pError, nil, nil, nil);
- //Alert(128, nil);
-   break;
-   // TODO: handled message longer than 256 chars
-   //   use auto-sizeable alert
-   //   or dialog with scrollbars (TextEdit zone)
- }
- ga_clear(&error_ga);
- }
- #endif
- 
  void
  gui_mch_getmouse(int *x, int *y)
  {
--- 3990,3995 
*** ../vim-8.2.0670/src/version.c   2020-04-30 22:29:36.630024126 +0200
--- src/version.c   2020-04-30 22:50:29.425172553 +0200
***
*** 748,749 
--- 748,751 
  {   /* Add new patch number below this line */
+ /**/
+ 671,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
31. You code your homework in HTML and give your instructor the URL.

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202004302051.03UKpfWG005970%40masaka.moolenaar.net.


Re: [vim/vim] Add support for customizing the quickfix buffer contents (#5465)

2020-04-30 Thread Yegappan Lakshmanan
Hi,

On Thu, Apr 30, 2020 at 8:19 PM Wang Shidong 
wrote:

> *@wsdjeg* commented on this pull request.
> --
>
> In runtime/doc/quickfix.txt
> :
>
> > +|setloclist()| function. This overrides the 'quickfixtextfunc' option 
> > setting.
> +
> +The example below displays the list of old files (|v:oldfiles|) in a quickfix
> +window. As there is no line, column number and error text information
> +associated with each entry, the 'quickfixtextfunc' function returns only the
> +filename.
> +Example: >
> +" create a quickfix list from v:oldfiles
> +call setqflist([], ' ', {'lines' : v:oldfiles, 'efm' : '%f',
> + \ 'quickfixtextfunc' : 'QfOldFiles'})
> +func QfOldFiles(info)
> + " get information about the specific quickfix entry
> + let e = getqflist({'id' : a:info.id, 'idx' : a:info.idx,
> + \ 'items' : 1}).items[0]
> + " return the simplified file name
> + return fnamemodify(bufname(e.bufnr), ':p:.')
>
> why only return the file name instead of whole line?
>
>
>
The v:oldfiles variable contains only the name of the files. The above
example shows how to
populate the quickfix list from the v:oldfiles variable. So the function
returns only the name
of the file.

- Yegappan

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7mZmMD6msbdif1enhm%2B-W7zwuuijr_f6vVeC_NkPUE3Ow%40mail.gmail.com.