Re: [vim/vim] Add the matchfuzzy() function (#6932)

2020-10-05 Fir de Conversatie ma...@prabir.me
If you are porting might be good to look into comparing and porting other 
libraries. Would be also good to trying in real big projects such as 
chromium.

https://github.com/wincent/command-t  - C (actual search algorithm is in C)
https://github.com/jhawthorn/fzy  - C
https://github.com/lotabout/skim  - Rust  (
https://github.com/lotabout/fuzzy-matcher)
https://github.com/JazzCore/ctrlp-cmatcher/blob/master/autoload/fuzzycomt.c  
- C
https://github.com/garybernhardt/selecta 

Most of these are multi threaded so they are extremely fast.

If really want multithreading could write to file and then have another 
thread look at it. I briefly mentioned this at 
https://github.com/mattn/gof/issues/18


 

On Monday, October 5, 2020 at 1:41:02 PM UTC-7 vim-dev ML wrote:

> Hi,
>
> On Sun, Oct 4, 2020 at 7:10 PM lacygoill  wrote:
>
> > If you have any comments about the function arguments and the return
> > values, please let me know. We cannot change this after some time.
> >
> > I haven't had the time to read all the comments, but I'm using
> > matchfuzzypos(), and I had difficulties using its output for what I
> > wanted. I'm trying to implement a generic fuzzy search plugin. For now, I
> > just wrote a command to fuzzy search through Vim's help tags.I get the 
> help
> > tags via a grep(1)
> > <
> https://github.com/lacygoill/vim-fuzzy/blob/ef8173581e2dfc7ee2b7a04d87815a07927630e9/autoload/fuzzy.vim#L239-L245
> >
> > command, which is formatted by a perl(1)
> > <
> https://github.com/lacygoill/vim-fuzzy/blob/ef8173581e2dfc7ee2b7a04d87815a07927630e9/autoload/fuzzy.vim#L228
> >
> > (or awk(1)) command. Both are started asynchronously via a job. I use
> > perl so that an output line of grep(1) such as this one:
> >
> > /home/user/.fzf/doc/tags:fzf-toc fzf.txt /*fzf-toc*
> >
> > Is transformed into:
> >
> > fzf-toc fzf.txt
> >
> > Between the name of the tag and the name of the file where the tag is,
> > there is some whitespace including a tab. I rely on this tab to ignore 
> the
> > name of the file when fuzzy searching through the tags. I only want to 
> see
> > the names of the files to get some extra info.
> >
> > Here is how I do it
> > <
> https://github.com/lacygoill/vim-fuzzy/blob/ef8173581e2dfc7ee2b7a04d87815a07927630e9/autoload/fuzzy.vim#L394-L434
> >
> > :
> >
> > var str = substitute(filter_text, '\s*', '', 'g')
> > var pos: list>
> > var matchfuzzypos: list> = matchfuzzypos(TAGLIST, str)
> > [taglist_filtered, pos] = matchfuzzypos
> > map(taglist_filtered, {i, v -> [v] + pos[i]})
> > filter(taglist_filtered, {_, v -> v[-1] < match(v[0], "\t")})
> > pos = copy(taglist_filtered)->map({_, v -> v[1:]})
> > map(taglist_filtered, {_, v -> v[0]})
> >
> > I would like to simplify this code by passing the output of
> > matchfuzzypos() directly to filter() so that it removes the entries where
> > a match is located after the tab. But I can't do it, because if filter()
> > removes one tag name from taglist_filtered, the next time pos[i] is
> > evaluated, it will no longer apply to the right item. IOW, I need to 
> filter
> > both lists returned by matchfuzzypos() simultaneously. The only way I
> > found to do that is to temporarily merge the lists into a single one. It
> > works but I think it would be easier and more efficient if 
> matchfuzzypos()
> > returned a single list. Maybe a list of dictionaries:
> >
> > :echo matchfuzzypos(['clay', 'lacy'], 'la')
> > [{'match': 'lacy', 'pos': [0, 1]}, {'match': 'clay', 'pos': [1, 2]}]
> >
> >
> The previous implementation of matchfuzzypos() returned the match position
> along with
> the matched text. But Prabir commented that it will make it easier for
> plugins if all the
> matched stings are returned in a single List. It is a trade-off between
> these two
> approaches. I am not sure which one will be more useful for the plugins:
>
> 1. Returning a list with all the matched strings and another list with the
> matching
> positions (current implementation).
> 2. Return a single list where each item contains both the matched string
> and the
> matching position.
>
> Or a list of lists:
> >
> > :echo matchfuzzypos(['clay', 'lacy'], 'la')
> > [['lacy', 0, 1], ['clay', 1, 2]]
> >
> > This way, we wouldn't need to temporarily merge the lists, then split 
> them
> > back later. I'm a bit concerned by the impact it can have on performance,
> > especially when the operation is repeated frequently (e.g. every keypress
> > when a popup menu is visible), and the source of strings is big.
> > --
> >
> > There is something else which I think would be useful but it's more a
> > feature request. If you use fzf(1) to search through help tags via
> > :Helptags
> > <
> https://github.com/junegunn/fzf.vim/blob/0fe8e198a3a501b54dbc4f9587526c097599f95a/plugin/fzf.vim#L66
> >,
> > you should notice that we can use spaces between tokens. And when you do,
> > fzf(1) does 2 interesting things:
> >
> > - it ignores whitespace
> > - it looks for the tokens in no 

Re: [vim/vim] Add the matchfuzzy() function (#6932)

2020-10-05 Fir de Conversatie Yegappan Lakshmanan
Hi,

On Sun, Oct 4, 2020 at 7:10 PM lacygoill  wrote:

> If you have any comments about the function arguments and the return
> values, please let me know. We cannot change this after some time.
>
> I haven't had the time to read all the comments, but I'm using
> matchfuzzypos(), and I had difficulties using its output for what I
> wanted. I'm trying to implement a generic fuzzy search plugin. For now, I
> just wrote a command to fuzzy search through Vim's help tags.I get the help
> tags via a grep(1)
> 
> command, which is formatted by a perl(1)
> 
> (or awk(1)) command. Both are started asynchronously via a job. I use
> perl so that an output line of grep(1) such as this one:
>
> /home/user/.fzf/doc/tags:fzf-tocfzf.txt /*fzf-toc*
>
> Is transformed into:
>
> fzf-toc fzf.txt
>
> Between the name of the tag and the name of the file where the tag is,
> there is some whitespace including a tab. I rely on this tab to ignore the
> name of the file when fuzzy searching through the tags. I only want to see
> the names of the files to get some extra info.
>
> Here is how I do it
> 
> :
>
> var str = substitute(filter_text, '\s*', '', 'g')
> var pos: list>
> var matchfuzzypos: list> = matchfuzzypos(TAGLIST, str)
> [taglist_filtered, pos] = matchfuzzypos
> map(taglist_filtered, {i, v -> [v] + pos[i]})
> filter(taglist_filtered, {_, v -> v[-1] < match(v[0], "\t")})
> pos = copy(taglist_filtered)->map({_, v -> v[1:]})
> map(taglist_filtered, {_, v -> v[0]})
>
> I would like to simplify this code by passing the output of
> matchfuzzypos() directly to filter() so that it removes the entries where
> a match is located after the tab. But I can't do it, because if filter()
> removes one tag name from taglist_filtered, the next time pos[i] is
> evaluated, it will no longer apply to the right item. IOW, I need to filter
> both lists returned by matchfuzzypos() simultaneously. The only way I
> found to do that is to temporarily merge the lists into a single one. It
> works but I think it would be easier and more efficient if matchfuzzypos()
> returned a single list. Maybe a list of dictionaries:
>
> :echo matchfuzzypos(['clay', 'lacy'], 'la')
> [{'match': 'lacy', 'pos': [0, 1]}, {'match': 'clay', 'pos': [1, 2]}]
>
>
The previous implementation of matchfuzzypos() returned the match position
along with
the matched text. But Prabir commented that it will make it easier for
plugins if all the
matched stings are returned in a single List. It is a trade-off between
these two
approaches. I am not sure which one will be more useful for the plugins:

1. Returning a list with all the matched strings and another list with the
matching
positions (current implementation).
2. Return a single list where each item contains both the matched string
and the
matching position.

 Or a list of lists:
>
> :echo matchfuzzypos(['clay', 'lacy'], 'la')
> [['lacy', 0, 1], ['clay', 1, 2]]
>
> This way, we wouldn't need to temporarily merge the lists, then split them
> back later. I'm a bit concerned by the impact it can have on performance,
> especially when the operation is repeated frequently (e.g. every keypress
> when a popup menu is visible), and the source of strings is big.
> --
>
> There is something else which I think would be useful but it's more a
> feature request. If you use fzf(1) to search through help tags via
> :Helptags
> ,
> you should notice that we can use spaces between tokens. And when you do,
> fzf(1) does 2 interesting things:
>
>- it ignores whitespace
>- it looks for the tokens in no particular order
>
> So if you look for the help tag function-search-undo but only remember
> that there was fun and undo somewhere in the name, and if you type the
> tokens in the wrong order (i.e. undo before fun), fzf(1) will still find
> the tag. That's not the case with matchfuzzypos(). It does not ignore
> whitespace; but this can be easily fixed with a substitute(). However,
> then the issue is to make it look for the tokens in all possible orders. I
> don't know how fzf(1) does it. And I don't know what would be the impact
> on performance; especially since the bigger the number of
> whitespace-separated tokens, the bigger the number of possible
> permutations. Could this feature be one day implemented and maybe enabled
> via an optional dictionary (similar to the final {dict} argument of
> matchadd())?
>
> If that's not possible, it's not a big issue. I'll just write a recursive
> function which computes all possible 

Patch 8.2.1805

2020-10-05 Fir de Conversatie Bram Moolenaar


Patch 8.2.1805
Problem:Unix: terminal mode changed when using ":shell".
Solution:   Avoid calling settmode() when not needed. (issue #7079)
Files:  src/os_unix.c


*** ../vim-8.2.1804/src/os_unix.c   2020-09-13 22:00:08.983392136 +0200
--- src/os_unix.c   2020-10-05 21:29:13.037366702 +0200
***
*** 585,590 
--- 585,591 
  mch_delay(long msec, int flags)
  {
  tmode_T   old_tmode;
+ int   call_settmode;
  #ifdef FEAT_MZSCHEME
  long  total = msec; // remember original value
  #endif
***
*** 596,605 
// shell may produce SIGQUIT).
// Only do this if sleeping for more than half a second.
in_mch_delay = TRUE;
!   old_tmode = mch_cur_tmode;
!   if (mch_cur_tmode == TMODE_RAW
!  && (msec > 500 || (flags & MCH_DELAY_SETTMODE)))
settmode(TMODE_SLEEP);
  
/*
 * Everybody sleeps in a different way...
--- 597,609 
// shell may produce SIGQUIT).
// Only do this if sleeping for more than half a second.
in_mch_delay = TRUE;
!   call_settmode = mch_cur_tmode == TMODE_RAW
!  && (msec > 500 || (flags & MCH_DELAY_SETTMODE));
!   if (call_settmode)
!   {
!   old_tmode = mch_cur_tmode;
settmode(TMODE_SLEEP);
+   }
  
/*
 * Everybody sleeps in a different way...
***
*** 653,659 
while (total > 0);
  #endif
  
!   if (msec > 500 || (flags & MCH_DELAY_SETTMODE))
settmode(old_tmode);
in_mch_delay = FALSE;
  }
--- 657,663 
while (total > 0);
  #endif
  
!   if (call_settmode)
settmode(old_tmode);
in_mch_delay = FALSE;
  }
*** ../vim-8.2.1804/src/version.c   2020-10-05 20:38:02.469117560 +0200
--- src/version.c   2020-10-05 21:32:41.360656449 +0200
***
*** 752,753 
--- 752,755 
  {   /* Add new patch number below this line */
+ /**/
+ 1805,
  /**/

-- 
I wonder how much deeper the ocean would be without sponges.

 /// 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/202010051939.095Jdv6Z2499172%40masaka.moolenaar.net.


Patch 8.2.1804

2020-10-05 Fir de Conversatie Bram Moolenaar


Patch 8.2.1804
Problem:resolve('/') returns an empty string.
Solution:   Don't remove single slash. (closes #7074)
Files:  src/filepath.c, src/testdir/test_functions.vim


*** ../vim-8.2.1803/src/filepath.c  2020-09-25 23:48:58.003938752 +0200
--- src/filepath.c  2020-10-05 20:36:51.261287143 +0200
***
*** 1889,1895 
is_relative_to_current = TRUE;
  
len = STRLEN(p);
!   if (len > 0 && after_pathsep(p, p + len))
{
has_trailing_pathsep = TRUE;
p[len - 1] = NUL; // the trailing slash breaks readlink()
--- 1889,1895 
is_relative_to_current = TRUE;
  
len = STRLEN(p);
!   if (len > 1 && after_pathsep(p, p + len))
{
has_trailing_pathsep = TRUE;
p[len - 1] = NUL; // the trailing slash breaks readlink()
*** ../vim-8.2.1803/src/testdir/test_functions.vim  2020-09-25 
22:42:43.852669232 +0200
--- src/testdir/test_functions.vim  2020-10-05 20:36:05.533395161 +0200
***
*** 339,344 
--- 339,346 
call assert_equal('Xlink2', resolve('Xlink1'))
call assert_equal('./Xlink2', resolve('./Xlink1'))
call delete('Xlink1')
+ 
+   call assert_equal('/', resolve('/'))
  endfunc
  
  func s:normalize_fname(fname)
*** ../vim-8.2.1803/src/version.c   2020-10-05 20:07:14.413414315 +0200
--- src/version.c   2020-10-05 20:35:23.609493584 +0200
***
*** 752,753 
--- 752,755 
  {   /* Add new patch number below this line */
+ /**/
+ 1804,
  /**/

-- 
Those who live by the sword get shot by those who don't.

 /// 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/202010051838.095IcYwF2482870%40masaka.moolenaar.net.


Patch 8.2.1803

2020-10-05 Fir de Conversatie Bram Moolenaar


Patch 8.2.1803
Problem:A few failures are not tested.
Solution:   Test a few failures. (Dominique Pellé, closes #7075)
Files:  src/testdir/test_arglist.vim, src/testdir/test_cmdline.vim,
src/testdir/test_json.vim, src/testdir/test_listdict.vim


*** ../vim-8.2.1802/src/testdir/test_arglist.vim2020-09-23 
22:38:01.503927513 +0200
--- src/testdir/test_arglist.vim2020-10-05 20:06:00.221611722 +0200
***
*** 426,431 
--- 426,432 
call assert_fails('argdelete', 'E610:')
call assert_fails('1,100argdelete', 'E16:')
call assert_fails('argdel /\)/', 'E55:')
+   call assert_fails('1argdel 1', 'E474:')
  
call Reset_arglist()
args a b c d
***
*** 478,490 
new
" redefine arglist; go to Xxx1
next! Xxx1 Xxx2 Xxx3
!   " open window for all args
all
call assert_equal('test file Xxx1', getline(1))
wincmd w
wincmd w
call assert_equal('test file Xxx1', getline(1))
-   " should now be in Xxx2
rewind
call assert_equal('test file Xxx2', getline(1))
  
--- 479,494 
new
" redefine arglist; go to Xxx1
next! Xxx1 Xxx2 Xxx3
!   " open window for all args; Reading Xxx2 will change the arglist and the
!   " third window will get Xxx1:
!   "   win 1: Xxx1
!   "   win 2: Xxx2
!   "   win 3: Xxx1
all
call assert_equal('test file Xxx1', getline(1))
wincmd w
wincmd w
call assert_equal('test file Xxx1', getline(1))
rewind
call assert_equal('test file Xxx2', getline(1))
  
*** ../vim-8.2.1802/src/testdir/test_cmdline.vim2020-09-23 
22:38:01.503927513 +0200
--- src/testdir/test_cmdline.vim2020-10-05 20:06:00.221611722 +0200
***
*** 756,761 
--- 756,765 
call feedkeys(":doautocmd User MyCmd a.c\\\"\", 'xt')
call assert_equal("\"doautocmd User MyCmd a.c\", @:)
  
+   " completion of autocmd group after comma
+   call feedkeys(":doautocmd BufNew,BufEn\\\"\", 'xt')
+   call assert_equal("\"doautocmd BufNew,BufEnter", @:)
+ 
" completion for the :augroup command
augroup XTest
augroup END
*** ../vim-8.2.1802/src/testdir/test_json.vim   2020-08-12 18:50:31.879655802 
+0200
--- src/testdir/test_json.vim   2020-10-05 20:06:00.221611722 +0200
***
*** 196,201 
--- 196,202 
call assert_fails('call json_decode("{[]:42}")', "E491:")
  
call assert_fails('call json_decode("-")', "E491:")
+   call assert_fails('call json_decode("-1x")', "E491:")
call assert_fails('call json_decode("infinit")', "E491:")
  
call assert_fails('call json_decode("\"\\u111Z\"")', 'E491:')
*** ../vim-8.2.1802/src/testdir/test_listdict.vim   2020-09-23 
22:38:01.503927513 +0200
--- src/testdir/test_listdict.vim   2020-10-05 20:06:00.221611722 +0200
***
*** 726,731 
--- 726,733 
call assert_fails("call reduce({}, { acc, val -> acc + val }, 1)", 'E897:')
call assert_fails("call reduce(0, { acc, val -> acc + val }, 1)", 'E897:')
call assert_fails("call reduce('', { acc, val -> acc + val }, 1)", 'E897:')
+   call assert_fails("call reduce([1, 2], 'Xdoes_not_exist')", 'E117:')
+   call assert_fails("echo reduce(0z01, { acc, val -> 2 * acc + val }, '')", 
'E39:')
  
let g:lut = [1, 2, 3, 4]
func EvilRemove()
*** ../vim-8.2.1802/src/version.c   2020-10-05 19:23:56.216436744 +0200
--- src/version.c   2020-10-05 20:06:56.849461132 +0200
***
*** 752,753 
--- 752,755 
  {   /* Add new patch number below this line */
+ /**/
+ 1803,
  /**/

-- 
Seen it all, done it all, can't remember most of it.

 /// 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/202010051809.095I9JpI2472505%40masaka.moolenaar.net.


Re: [vim/vim] Add the matchfuzzy() function (#6932)

2020-10-05 Fir de Conversatie Bram Moolenaar


[...]

> I would like to simplify this code by passing the output of
> `matchfuzzypos()` directly to `filter()` so that it removes the
> entries where a match is located after the tab.  But I can't do it,
> because if `filter()` removes one tag name from `taglist_filtered`,
> the next time `pos[i]` is evaluated, it will no longer apply to the
> right item.  IOW, I need to filter both lists returned by
> `matchfuzzypos()` simultaneously.  The only way I found to do that is
> to temporarily merge the lists into a single one.  It works but I
> think it would be easier and more efficient if `matchfuzzypos()`
> returned a single list.  Maybe a list of dictionaries:

The filter() function passes the index to the lambda.  You can perhaps
use this to filter() one list, and then add the flag to a new list.
Then filter the second list, and compare use the flag from that new
list.  I haven't tried this, but something like:

var flagList = []
def Evaluate(i: number, v: string): bool
  var match = v =~ 'pattern'
  flagList->add(match)
  return match
enddef
filter(matches, {i, v -> Evaluate(i, v) })
filter(positions, {i, _ -> flagList[i] })

Alternatively we would need to implement the Python zip() function.
That might be useful anyway.

-- 
On the other hand, you have different fingers.
  -- Steven Wright

 /// 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/202010051809.095I9J6U2472499%40masaka.moolenaar.net.


Re: [patch] doc fixes

2020-10-05 Fir de Conversatie Bram Moolenaar


Dominique wrote:

> Attached are documentation fixes for vim-8.2.1801.

Thanks!


-- 
The users that I support would double-click on a landmine to find out
what happens.   -- A system administrator

 /// 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/202010051809.095I9JRt2472517%40masaka.moolenaar.net.


Re: [vim/vim] Make popup behave like a normal window (#5639)

2020-10-05 Fir de Conversatie ma...@prabir.me
>From a plugin author there are only two features I would need i.e. allow to 
pass an option for popup for focusable: true/false when creating popup and 
capability to focus on the popup or move focus to another buffer/win. 
Neovim has a win_gotoid() to focus to popup which avoids creating a new api 
since it treats popup as just any other window with buffer. Based on the 
api we might need a third once that says which one currently focused.

As for the experience it is like any other buffer or window. You can only 
be currently focused in a buffer or popup and not multiple. Use / for 
search, jkhl for movements and so on.

Here is how vim-lsp works when trying to show popup for hovering under a 
symbol that gives doc.
nmap  K (lsp-hover)  

lsp-hover is same as preview window concept in vim but instead of using 
preview window it uses popup if it exists.
We have a flag to allow autofocus for lsp-hover. if it is true we autofocus 
to popup window and if false the focus remains in the buffer. By default we 
have set it to false so it doesn't focus in the popup. The popup closes 
when cursor moves since it is not on focus. We then have a concept of 
double tap which means if the user again presses K when the popup is open 
it focus inside the popup. Inside the popup they can use all the features 
of normal buffer and cursor movement doesn't close the popup.

For fuzzy finder style popup it also becomes important. I have tried 
multiple approaches ie. using custom prompt similar to ctrlp, denite style 
where the prompt is a buffer. I'm leaning to denite style pattern but that 
means it won't work in popup. vim-clap already seems to be hitting this 
issue.
(Not related to popup but is there an event similar to InsertCharPre but 
that works in normal code so we can look at v:char and see what character 
is pressed? This would solve the issue of using prompt to work in multibyte 
chars and avoid this 
https://github.com/prabirshrestha/quickpick.vim/blob/68465f4654f83d4a711afe1059a104f9c16f4ac7/autoload/quickpick.vim#L48-L57.
 
getchar() isn't an option since it is blocking. This would solve the prompt 
issue but not popup issue)


On Monday, October 5, 2020 at 9:30:15 AM UTC-7 Blay263 wrote:

> I think the use cases have been detailed above and are limited. Neovim 
> provides a proof of concept. Not having the popup focusable is blocking 
> specific functionality that is already available in Neovim.
>
> On Monday, October 5, 2020 at 10:28:08 AM UTC-4 Bram Moolenaar wrote:
>
>>
>> > +1 I would also like the popup to be focusable so that it can be used 
>> like 
>> > a normal window/buffer. Neovim doesn't have this issue.
>> > 
>> > Here is another use case for me. This is vim-lsp 
>> >  using hover to show 
>> > information about the word under the cursor. Most rust projects have 
>> big 
>> > docs including great examples and I would like to move around and copy 
>> text 
>> > from popup, search inside the popup and use all my vim knowledge there. 
>> > 
>> > Right now the solution for me is to open the website or use neovim.
>>
>> I have been thinking of this, but it raises many questions:
>>
>> - How to focus a popup? I imagine in most cases you want to switch
>> between the current window and the popup, back and forth. This
>> matters especially if you already have a dozen split windows, you
>> don't want to cycle through all of them to reach the popup, and you
>> don't want to cycle through all windows to end up in the one you were
>> coming from.
>>
>> - If there is more than one focusable popup, how to reach each of them?
>> Perhaps some are connected to a specific window (e.g. for completion
>> or anchored to text), or some are unrelated to a specific window (e.g.
>> help).
>>
>> - What if the focused popup window closes? What if it closes while you
>> are typing (since they might be under control of some async plugin)?
>>
>> - How to avoid this turns into an avalanche of more feature requests?
>> Aka creeping featurism.
>>
>> -- 
>> He who laughs last, thinks slowest.
>>
>> /// Bram Moolenaar -- br...@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/da38b161-ae38-4d4a-acf9-825e54451ba0n%40googlegroups.com.


Patch 8.2.1802

2020-10-05 Fir de Conversatie Bram Moolenaar


Patch 8.2.1802
Problem:Vim9: crash with unterminated dict. (Dhiraj Mishra)
Solution:   Return empty string instead of NULL. (closes #7084)
Files:  src/vim9compile.c, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.1801/src/vim9compile.c   2020-10-04 17:24:24.705711322 +0200
--- src/vim9compile.c   2020-10-05 19:22:51.564649502 +0200
***
*** 2822,2828 
--- 2822,2831 
  
  failret:
  if (*arg == NULL)
+ {
semsg(_(e_missing_dict_end), _("[end of lines]"));
+   *arg = (char_u *)"";
+ }
  dict_unref(d);
  return FAIL;
  }
*** ../vim-8.2.1801/src/testdir/test_vim9_expr.vim  2020-10-04 
16:06:00.513884339 +0200
--- src/testdir/test_vim9_expr.vim  2020-10-05 19:22:39.872688359 +0200
***
*** 1819,1824 
--- 1819,1826 
CheckDefExecFailure(['var x: dict = #{a: "x", b: 134}'], 'E1012:', 
1)
CheckDefExecFailure(['var x: dict = #{a: 234, b: "1"}'], 'E1012:', 
1)
CheckDefExecFailure(['var x: dict = #{a: "x", b: 134}'], 'E1012:', 
1)
+ 
+   CheckDefFailure(['var x = ({'], 'E723:', 2)
  enddef
  
  def Test_expr7_dict_vim9script()
*** ../vim-8.2.1801/src/version.c   2020-10-04 19:56:35.163869162 +0200
--- src/version.c   2020-10-05 19:19:49.153270716 +0200
***
*** 752,753 
--- 752,755 
  {   /* Add new patch number below this line */
+ /**/
+ 1802,
  /**/

-- 
A day without sunshine is like, well, night.

 /// 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/202010051724.095HOcsd2461783%40masaka.moolenaar.net.


Re: [vim/vim] Make popup behave like a normal window (#5639)

2020-10-05 Fir de Conversatie Blay263
I think the use cases have been detailed above and are limited. Neovim 
provides a proof of concept. Not having the popup focusable is blocking 
specific functionality that is already available in Neovim.

On Monday, October 5, 2020 at 10:28:08 AM UTC-4 Bram Moolenaar wrote:

>
> > +1 I would also like the popup to be focusable so that it can be used 
> like 
> > a normal window/buffer. Neovim doesn't have this issue.
> > 
> > Here is another use case for me. This is vim-lsp 
> >  using hover to show 
> > information about the word under the cursor. Most rust projects have big 
> > docs including great examples and I would like to move around and copy 
> text 
> > from popup, search inside the popup and use all my vim knowledge there. 
> > 
> > Right now the solution for me is to open the website or use neovim.
>
> I have been thinking of this, but it raises many questions:
>
> - How to focus a popup? I imagine in most cases you want to switch
> between the current window and the popup, back and forth. This
> matters especially if you already have a dozen split windows, you
> don't want to cycle through all of them to reach the popup, and you
> don't want to cycle through all windows to end up in the one you were
> coming from.
>
> - If there is more than one focusable popup, how to reach each of them?
> Perhaps some are connected to a specific window (e.g. for completion
> or anchored to text), or some are unrelated to a specific window (e.g.
> help).
>
> - What if the focused popup window closes? What if it closes while you
> are typing (since they might be under control of some async plugin)?
>
> - How to avoid this turns into an avalanche of more feature requests?
> Aka creeping featurism.
>
> -- 
> He who laughs last, thinks slowest.
>
> /// Bram Moolenaar -- br...@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/865bff3b-7dd9-42b3-8198-cb21e382bf20n%40googlegroups.com.


Re: [vim/vim] Make popup behave like a normal window (#5639)

2020-10-05 Fir de Conversatie Bram Moolenaar


> +1 I would also like the popup to be focusable so that it can be used like 
> a normal window/buffer. Neovim doesn't have this issue.
> 
> Here is another use case for me. This is vim-lsp 
>   using hover to show 
> information about the word under the cursor. Most rust projects have big 
> docs including great examples and I would like to move around and copy text 
> from popup, search inside the popup and use all my vim knowledge there. 
> 
> Right now the solution for me is to open the website or use neovim.

I have been thinking of this, but it raises many questions:

- How to focus a popup?  I imagine in most cases you want to switch
  between the current window and the popup, back and forth.  This
  matters especially if you already have a dozen split windows, you
  don't want to cycle through all of them to reach the popup, and you
  don't want to cycle through all windows to end up in the one you were
  coming from.

- If there is more than one focusable popup, how to reach each of them?
  Perhaps some are connected to a specific window (e.g. for completion
  or anchored to text), or some are unrelated to a specific window (e.g.
  help).

- What if the focused popup window closes?  What if it closes while you
  are typing (since they might be under control of some async plugin)?

- How to avoid this turns into an avalanche of more feature requests?
  Aka creeping featurism.

-- 
He who laughs last, thinks slowest.

 /// 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/202010051427.095ERxUu2417864%40masaka.moolenaar.net.


Re: Vim9: rethinking conditions and boolean expressions

2020-10-05 Fir de Conversatie Ben Jackson
> The "??" operator is used in TypeScript, JavaScript, C# and a few other
> 
> languages.

Oh ok, fair enough, thanks. Shows how much I know :) I’d never seen it before.

> On 5 Oct 2020, at 14:20, Bram Moolenaar  wrote:
> 
> 
>>> var name = Getname() ?? 'unknown' 
>> 
>> This `??` operator seems a bit unique to vim9script. If we're trying to be 
>> more like other languages how about either re-using `else` (as in Getname() 
>> else 'unknown') or using `or` (Like python): `Getname() or "unknown"`
> 
> Python operators are words, which I find making an expression harder to
> understand.  We don't have any operators that are words, I don't see a
> reason to use it here.
> 
> The "??" operator is used in TypeScript, JavaScript, C# and a few other
> languages.
> 
> -- 
> hundred-and-one symptoms of being an internet addict:
> 35. Your husband tells you he's had that beard for 2 months.
> 
> /// 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/D96FFEAA-B17B-4CF5-BB68-2DD836329B24%40gmail.com.


Re: Vim9: rethinking conditions and boolean expressions

2020-10-05 Fir de Conversatie Bram Moolenaar


> > var name = Getname() ?? 'unknown' 
> 
> This `??` operator seems a bit unique to vim9script. If we're trying to be 
> more like other languages how about either re-using `else` (as in Getname() 
> else 'unknown') or using `or` (Like python): `Getname() or "unknown"`

Python operators are words, which I find making an expression harder to
understand.  We don't have any operators that are words, I don't see a
reason to use it here.

The "??" operator is used in TypeScript, JavaScript, C# and a few other
languages.

-- 
hundred-and-one symptoms of being an internet addict:
35. Your husband tells you he's had that beard for 2 months.

 /// 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/202010051320.095DKXB62406083%40masaka.moolenaar.net.


Re: Vim9: rethinking conditions and boolean expressions

2020-10-05 Fir de Conversatie Bram Moolenaar


Dominique wrote:

> Bram Moolenaar  wrote:
> 
> > For the first example, we can use a new operator which is specifically
> > for testing an expression to be falsy and using a replacement:
> >
> > var name = Getname() ?? 'unknown'
> >
> > Let me know if you have comments.
> 
> This is known as the 'elvis operator', which exists
> in several languages.  See:
> 
> https://en.wikipedia.org/wiki/Elvis_operator
> 
> Generally, it is ?: as in:
> 
>   var name = Getname() ?: 'unknown';
> 
> It may be worth saying that it is almost equivalent to
> the longer:
> 
>   var name = Getname() ? Getname() : 'unknown';
> 
> ... except that in the case of the elvis operator,
> Gename() is guaranteed to be invoked only once,
> which may not only be more efficient, but can also
> be different if Getname() had side effects.
> 
> This image explains why it's called the 'elvis operator':
> 
> https://i.stack.imgur.com/bVG64.png

What I intend to do here makes a difference between the two operators,
which is also why I prefer using "??" instead of "?:".  The latter
suggest the equivalence with "cond ? expr : expr", which is not quite
right.

The condition in "cond ? expr : expr" is just like a condition used for
"if": it should evaluate to a boolean.  The ternary expression is a
short way of doing if-then-else, thus using the same semantics for the
condition makes sense.

For the "??" operator, which I prefer calling the falsy-operator, the
expression is not required to evaluate to a boolean.  In fact, it's most
useful if it doesn't.  It can be a string, list, dict, etc.  And
evaluating it will never result in an error, every value is either
truthy or falsy.

A name sometimes used is "nullish coalescing operator", which is not
only hard to type but also not quite the same.  "nullish" and "falsy"
have different semantics.  We could call it the "falsy coalescing
operator", but "falsy operator" works just as well and is a lot easier
to type.  Still, "nullish coalescing operator" comes closest, thus using
"??" as the operator will be recognized by most users. I hope the
different semantics won't cause too much confusion.

-- 
hundred-and-one symptoms of being an internet addict:
34. You laugh at people with a 10 Mbit connection.

 /// 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/202010051320.095DKWlx2406071%40masaka.moolenaar.net.


Re: Vim9: rethinking conditions and boolean expressions

2020-10-05 Fir de Conversatie Dominique Pellé
Bram Moolenaar  wrote:

> For the first example, we can use a new operator which is specifically
> for testing an expression to be falsy and using a replacement:
>
> var name = Getname() ?? 'unknown'
>
> Let me know if you have comments.

This is known as the 'elvis operator', which exists
in several languages.  See:

https://en.wikipedia.org/wiki/Elvis_operator

Generally, it is ?: as in:

  var name = Getname() ?: 'unknown';

It may be worth saying that it is almost equivalent to
the longer:

  var name = Getname() ? Getname() : 'unknown';

... except that in the case of the elvis operator,
Gename() is guaranteed to be invoked only once,
which may not only be more efficient, but can also
be different if Getname() had side effects.

This image explains why it's called the 'elvis operator':

https://i.stack.imgur.com/bVG64.png

Regards
Dominique

-- 
-- 
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/CAON-T_hAu7PD1%2Bx4LW8DZhTtrVf6j7FM%2BCKrKS1moqoTgHd29g%40mail.gmail.com.


Re: Vim9: rethinking conditions and boolean expressions

2020-10-05 Fir de Conversatie puremo...@gmail.com
> var name = Getname() ?? 'unknown' 

This `??` operator seems a bit unique to vim9script. If we're trying to be 
more like other languages how about either re-using `else` (as in Getname() 
else 'unknown') or using `or` (Like python): `Getname() or "unknown"`


On Sunday, October 4, 2020 at 10:47:15 PM UTC+1 Bram Moolenaar wrote:

>
> > In javascript you can use !! operator to always convert it to boolean.
> > 
> > var name = ''
> > var nameExists = !!(name || 'Prabir')
>
> Yes, and I think we should do the same. It should already work like
> that now.
>
> Thus in most places where a condition is expected, such as with ":if"
> and ":while", a boolean is expected. With legacy script you could use a
> string, which was converted to a number and easily leads to mistakes.
> Also numbers could be used. With Vim9 script only the numbers zero and
> one can be used. This avoids making mistakes, but it's a bit strict.
>
> The new "??" operator can be used with any expression. Just like with
> "!" accepts any expression. In these places the expression is tested to
> be "falsy" or "truthy".
>
> I might have missed something, we might need a few more tests.
>
>
> -- 
> hundred-and-one symptoms of being an internet addict:
> 32. You don't know what sex three of your closest friends are, because they
> have neutral nicknames and you never bothered to ask.
>
> /// Bram Moolenaar -- br...@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/b0bcb397-317c-4fa7-b42f-5ac6eebd3402n%40googlegroups.com.