Patch 8.2.4485

2022-02-28 Fir de Conversatie Bram Moolenaar


Patch 8.2.4485
Problem:Compiler warning for uninitialized variable.
Solution:   Initialize the variable. (John Marriott)
Files:  src/cmdexpand.c


*** ../vim-8.2.4484/src/cmdexpand.c 2022-02-28 13:28:34.540563790 +
--- src/cmdexpand.c 2022-02-28 21:01:52.687000237 +
***
*** 3003,3009 
  garray_T  ga;
  int   fuzzy;
  int   match;
! int   score;
  
  fuzzy = cmdline_fuzzy_complete(pat);
  *matches = NULL;
--- 3003,3009 
  garray_T  ga;
  int   fuzzy;
  int   match;
! int   score = 0;
  
  fuzzy = cmdline_fuzzy_complete(pat);
  *matches = NULL;
*** ../vim-8.2.4484/src/version.c   2022-02-28 20:54:58.129239044 +
--- src/version.c   2022-02-28 21:02:02.943023684 +
***
*** 756,757 
--- 756,759 
  {   /* Add new patch number below this line */
+ /**/
+ 4485,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
126. You brag to all of your friends about your date Saturday night...but
 you don't tell them it was only in a chat room.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///  \\\
\\\sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\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/20220228210437.8A71E1C007F%40moolenaar.net.


Re: Patch 8.2.4482

2022-02-28 Fir de Conversatie Bram Moolenaar


John Marriott wrote:

> On 28-Feb-2022 08:03, Bram Moolenaar wrote:
> > Patch 8.2.4482
> > Problem:No fuzzy cmdline completion for user defined completion.
> > Solution:   Add fuzzy completion for user defined completion. (Yegappan
> >  Lakshmanan, closes #9858)
> > Files:  src/cmdexpand.c, src/testdir/test_cmdline.vim
> >
> >
> >
> After this patch, mingw64 (gcc 11.2.0) throws this warning:
> 
> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO 
> -pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return 
> -fpie -fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD cmdexpand.c -o 
> gobjnative/cmdexpand.o
> cmdexpand.c: In function 'ExpandFromContext':
> cmdexpand.c:3056:33: warning: 'score' may be used uninitialized in this 
> function [-Wmaybe-uninitialized]
>   3056 | fuzmatch->score = score;
>    | ^~~
> cmdexpand.c:3006:17: note: 'score' was declared here
>   3006 | int score;
>    | ^
> 
> 
> The attached patch tries to fix it.

I'll include it, thanks.

-- 
Statistics say that you can have a baby per month on average:
Just get nine women pregnant.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///  \\\
\\\sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\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/20220228210437.8861B1C02B3%40moolenaar.net.


Patch 8.2.4484

2022-02-28 Fir de Conversatie Bram Moolenaar


Patch 8.2.4484
Problem:Vim9: some error messages are not tested.
Solution:   Add a few more test cases.  Delete dead code.
Files:  src/vim9execute.c, src/testdir/test_vim9_assign.vim,
src/testdir/test_vim9_expr.vim, src/testdir/test_vim9_func.vim


*** ../vim-8.2.4483/src/vim9execute.c   2022-02-22 19:39:07.590366896 +
--- src/vim9execute.c   2022-02-28 20:35:21.586573789 +
***
*** 1027,1033 
  {
int func_idx = find_internal_func(name);
  
!   if (func_idx < 0)
return FAIL;
if (check_internal_func(func_idx, argcount) < 0)
return FAIL;
--- 1027,1033 
  {
int func_idx = find_internal_func(name);
  
!   if (func_idx < 0)  // Impossible?
return FAIL;
if (check_internal_func(func_idx, argcount) < 0)
return FAIL;
***
*** 1452,1459 
  char_u*p;
  char_u*line;
  
- if (*sp->nextline == NUL)
-   return NULL;
  p = vim_strchr(sp->nextline, '\n');
  if (p == NULL)
  {
--- 1452,1457 
***
*** 1911,1921 
else
n2 = (long)tv_get_number_chk(tv_idx2, );
if (error)
!   status = FAIL;
else
{
listitem_T *li1 = check_range_index_one(
!   tv_dest->vval.v_list, , FALSE);
  
if (li1 == NULL)
status = FAIL;
--- 1909,1919 
else
n2 = (long)tv_get_number_chk(tv_idx2, );
if (error)
!   status = FAIL; // cannot happen?
else
{
listitem_T *li1 = check_range_index_one(
!tv_dest->vval.v_list, , FALSE);
  
if (li1 == NULL)
status = FAIL;
*** ../vim-8.2.4483/src/testdir/test_vim9_assign.vim2022-02-22 
20:42:50.382992530 +
--- src/testdir/test_vim9_assign.vim2022-02-28 20:38:31.445869269 +
***
*** 550,555 
--- 550,562 
bl[-2] = 0x66
assert_equal(0z77226644, bl)
  
+   lines =<< trim END
+   g:val = '22'
+   var bl = 0z11
+   bl[1] = g:val
+   END
+   v9.CheckDefExecAndScriptFailure(lines, 'E1030: Using a String as a Number: 
"22"')
+ 
# should not read the next line when generating "a.b"
var a = {}
a.b = {}
***
*** 1233,1244 
--- 1240,1257 
var lines =<< trim END
vim9script
var l: list
+   var li = [1, 2]
var bl: blob
+   var bli = 0z12
var d: dict
+   var di = {'a': 1, 'b': 2}
def Echo()
  assert_equal([], l)
+ assert_equal([1, 2], li)
  assert_equal(0z, bl)
+ assert_equal(0z12, bli)
  assert_equal({}, d)
+ assert_equal({'a': 1, 'b': 2}, di)
enddef
Echo()
END
***
*** 1502,1507 
--- 1515,1544 
END
v9.CheckDefAndScriptSuccess(lines)
  
+   lines =<< trim END
+   var l = [1, 2]
+   g:idx = 'x'
+   l[g:idx : 1] = [0]
+   echo l
+   END
+   v9.CheckDefExecAndScriptFailure(lines, 'E1030: Using a String as a Number: 
"x"')
+ 
+   lines =<< trim END
+   var l = [1, 2]
+   g:idx = 3
+   l[g:idx : 1] = [0]
+   echo l
+   END
+   v9.CheckDefExecAndScriptFailure(lines, 'E684: list index out of range: 3')
+ 
+   lines =<< trim END
+   var l = [1, 2]
+   g:idx = 'y'
+   l[1 : g:idx] = [0]
+   echo l
+   END
+   v9.CheckDefExecAndScriptFailure(lines, ['E1012: Type mismatch; expected 
number but got string', 'E1030: Using a String as a Number: "y"'])
+ 
v9.CheckDefFailure(["var l: list = ['', true]"], 'E1012: Type 
mismatch; expected list but got list', 1)
v9.CheckDefFailure(["var l: list> = [['', true]]"], 'E1012: 
Type mismatch; expected list> but got list>', 1)
  enddef
*** ../vim-8.2.4483/src/testdir/test_vim9_expr.vim  2022-02-26 
11:46:09.510212631 +
--- src/testdir/test_vim9_expr.vim  2022-02-28 19:13:35.770634230 +
***
*** 2782,2787 
--- 2782,2804 
  
v9.CheckDefAndScriptSuccess(lines)
  
+   lines =<< trim END
+   vim9script
+ 
+   def PosIdx(s: string): string
+ return s[1]
+   enddef
+   def NegIdx(s: string): string
+ return s[-1]
+   enddef
+ 
+   set enc=latin1
+   assert_equal("\xe4", PosIdx("a\xe4\xe5"))
+   assert_equal("\xe5", NegIdx("a\xe4\xe5"))
+   set enc=utf-8
+   END
+   v9.CheckScriptSuccess(lines)
+ 
v9.CheckDefExecAndScriptFailure(['echo g:testblob[2]'], 'E979:', 1)
v9.CheckDefExecAndScriptFailure(['echo g:testblob[-3]'], 'E979:', 1)
  
*** ../vim-8.2.4483/src/testdir/test_vim9_func.vim  2022-02-23 
22:11:58.778087741 +
--- src/testdir/test_vim9_func.vim  2022-02-28 18:49:12.172334279 +
***
*** 550,555 
--- 550,593 
unlet g:counter
  enddef
  
+ def 

plugin best practice/vim-python debug

2022-02-28 Fir de Conversatie Ernie Rael

Greetings all,

I recently picked up a new DirDiff, went to modify the source to install 
my preferred keybindings/mapping. I saw a new scheme in DirDiff so I 
don't have to modify the source code. One part is that it doesn't do 
mappings by default. It says "preferable to not change people's mappings 
by default"


I'm going to modify Splice to use a similar scheme so I can set mappings 
from vimrc file. Splice is a vim-python plugin. I've never done 
vimscript (other than my simple vimrc files) Given this context, I'm asking:


Should there be an "enable setting up mappings" flag and false by 
default? Since Splice is usually invoke from SCM, e.g. hg/git, there's 
nothing for it's mappings to compete with, AFAICT. Splice changes a few 
mappings back and forth in normal operation, it doesn't seem to make 
sense to have that disabled.


For debugging, at least for now, I think print to a file would be 
sufficient for me. Any problems mixing vim/python print to file 
statements? I'll have to learn how to print variables... to a file from 
vim script.  Need unbuffered, append mode.


Python interface is nice; magic variable/lists/ to affect behavior. Does 
vim have anything like that? Is there a good intro to vim scripting, I 
know there's tons of functions and saw as chaining became pervasive. For 
this project I have few needs: call a function from python (maybe pass 
some arguments, but maybe not), do some nnoremap commands. But I would 
like to know more than I need to know.


Since I'm getting my toes wet, might as well do some vim9 as well.

TLDR,
but thanks for any feedback,
-ernie

--
--
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/fbd7f5bd-4c08-9e0f-1f0d-93a217ec7a41%40raelity.com.


Re: [vim/vim] Add "fc" filetype when vim is opened from "fc" command (Issue #9861)

2022-02-28 Fir de Conversatie Gary Johnson
On 2022-02-28, SuperCuber wrote:
> Does this really require using a different filetype? When using "fc"
> from bash, shouldn't the filetype be "bash"?
> 
> I would like to add the more specific filetype as well (as far as I can
> understand filetype=fc.zsh would trigger both of the filetypes) for making
> plugins when launched by fc specifically, not just for a generic shell script.
> (think for example one that would preview output of the command)
> 
> other shells
> 
> Zsh opens /tmp/zshXX where X is some random letters (which is correctly
> recognized as zsh).
> Seems like sh doesn't have fc.
> Ksh creates a /tmp/ast.XX file which doesn't get recognized as any
> filetype.
> Tcsh doesn't have a fc builtin
> Fish doesn't appear to either
> 
> Also it seems like bash's fc file gets recognized as sh even though https://
> github.com/vim/vim/blob/5de4c4372d4366bc85cb66efb3e373439b9471c5/runtime/
> filetype.vim#L2444 looks like it should set it to bash

The filetype for bash files is sh.  If Vim determines that it is
a bash file, then it sets b:is_bash = 1.  (See
$VIMRUNTIME/autoload/dist/ft.vim.)

What I use for doing special things in fc buffers is this in my
~/.vim/after/ftplugin/sh.vim file:

if argv(0) =~ '^/tmp/bash-fc[-.]\w\+$'
" Stuff for fc buffers
endif

I use only bash, so I don't need to identify the shell or allow for
other shells.

Regards,
Gary

-- 
-- 
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/20220228192125.GB18373%40phoenix.


Re: Patch 8.2.4482

2022-02-28 Fir de Conversatie John Marriott


On 28-Feb-2022 08:03, Bram Moolenaar wrote:

Patch 8.2.4482
Problem:No fuzzy cmdline completion for user defined completion.
Solution:   Add fuzzy completion for user defined completion. (Yegappan
 Lakshmanan, closes #9858)
Files:  src/cmdexpand.c, src/testdir/test_cmdline.vim




After this patch, mingw64 (gcc 11.2.0) throws this warning:

gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO 
-pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return 
-fpie -fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD cmdexpand.c -o 
gobjnative/cmdexpand.o

cmdexpand.c: In function 'ExpandFromContext':
cmdexpand.c:3056:33: warning: 'score' may be used uninitialized in this 
function [-Wmaybe-uninitialized]

 3056 | fuzmatch->score = score;
  | ^~~
cmdexpand.c:3006:17: note: 'score' was declared here
 3006 | int score;
  | ^


The attached patch tries to fix it.
Cheers
John

--
--
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/3d9eba67-11c9-2f42-abb5-45cb756b7e4a%40internode.on.net.
--- cmdexpand.c.orig2022-03-01 05:56:52.611353000 +1100
+++ cmdexpand.c 2022-03-01 06:17:08.904664100 +1100
@@ -3003,7 +3003,7 @@
 garray_T   ga;
 intfuzzy;
 intmatch;
-intscore;
+intscore = 0;
 
 fuzzy = cmdline_fuzzy_complete(pat);
 *matches = NULL;


Patch 8.2.4483

2022-02-28 Fir de Conversatie Bram Moolenaar


Patch 8.2.4483
Problem:Command completion makes two rounds to collect matches.
Solution:   Use a growarray to collect matches. (Yegappan Lakshmanan,
closes #9860)
Files:  src/buffer.c, src/cmdexpand.c, src/map.c,
src/testdir/test_cmdline.vim


*** ../vim-8.2.4482/src/buffer.c2022-02-24 13:28:36.570222354 +
--- src/buffer.c2022-02-28 13:20:51.285350690 +
***
*** 2814,2851 
}
}
  
!   if (p != NULL)
{
!   if (round == 1)
!   ++count;
!   else
!   {
!   if (options & WILD_HOME_REPLACE)
!   p = home_replace_save(buf, p);
!   else
!   p = vim_strsave(p);
  
!   if (!fuzzy)
!   {
  #ifdef FEAT_VIMINFO
!   if (matches != NULL)
!   {
!   matches[count].buf = buf;
!   matches[count].match = p;
!   count++;
!   }
!   else
! #endif
!   (*file)[count++] = p;
!   }
!   else
!   {
!   fuzmatch[count].idx = count;
!   fuzmatch[count].str = p;
!   fuzmatch[count].score = score;
!   count++;
!   }
}
}
}
if (count == 0) // no match found, break here
--- 2814,2852 
}
}
  
!   if (p == NULL)
!   continue;
! 
!   if (round == 1)
{
!   ++count;
!   continue;
!   }
! 
!   if (options & WILD_HOME_REPLACE)
!   p = home_replace_save(buf, p);
!   else
!   p = vim_strsave(p);
  
!   if (!fuzzy)
!   {
  #ifdef FEAT_VIMINFO
!   if (matches != NULL)
!   {
!   matches[count].buf = buf;
!   matches[count].match = p;
!   count++;
}
+   else
+ #endif
+   (*file)[count++] = p;
+   }
+   else
+   {
+   fuzmatch[count].idx = count;
+   fuzmatch[count].str = p;
+   fuzmatch[count].score = score;
+   count++;
}
}
if (count == 0) // no match found, break here
*** ../vim-8.2.4482/src/cmdexpand.c 2022-02-27 21:03:17.937471865 +
--- src/cmdexpand.c 2022-02-28 13:25:48.676936485 +
***
*** 2633,2748 
  int   escaped)
  {
  int   i;
! int   count = 0;
! int   round;
  char_u*str;
  fuzmatch_str_T*fuzmatch = NULL;
! int   score = 0;
  int   fuzzy;
- int   funcsort = FALSE;
  int   match;
  
  fuzzy = cmdline_fuzzy_complete(pat);
  
! // do this loop twice:
! // round == 0: count the number of matching names
! // round == 1: copy the matching names into allocated memory
! for (round = 0; round <= 1; ++round)
  {
!   for (i = 0; ; ++i)
!   {
!   str = (*func)(xp, i);
!   if (str == NULL)// end of list
!   break;
!   if (*str == NUL)// skip empty strings
!   continue;
  
if (!fuzzy)
!  match = vim_regexec(regmatch, str, (colnr_T)0);
else
{
score = fuzzy_match_str(str, pat);
match = (score != 0);
}
  
!   if (!match)
!   continue;
  
!   if (round)
!   {
!   if (escaped)
!   str = vim_strsave_escaped(str, (char_u *)" \t\\.");
!   else
!   str = vim_strsave(str);
!   if (str == NULL)
!   {
!   if (fuzzy)
!   fuzmatch_str_free(fuzmatch, count);
!   else if (count > 0)
!   FreeWild(count, *matches);
!   *numMatches = 0;
!   *matches = NULL;
!   return FAIL;
!   }
!   if (fuzzy)
!   {
!   fuzmatch[count].idx = count;
!   fuzmatch[count].str = str;
!   fuzmatch[count].score = score;
!   }
!   else
!   (*matches)[count] = str;
! # ifdef FEAT_MENU
!   if (func ==