Re: test popupmenu question
Hi ChrisBra, Bram and list! 2016-9-12(Mon) 2:56:04 UTC+9 Christian Brabandt: > On So, 11 Sep 2016, h_east wrote: > > > Hi ChrisBra, Bram and list, > > 2016-7-24(Sun) 0:36:14 UTC+9 Christian Brabandt: > > > On Sa, 23 Jul 2016, Bram Moolenaar wrote: > > > > Christian Brabandt wrote: > > > I think I also found a bug, and this makes the test currently fail. > > > Take this example from the test: > > > > > > (The popupmenu is the one from the help for all months) > > > The initial state of the buffer is this: > > > , > > > | D > > > | December2015 > > > ` > > > > I have investigated this behavior. > > > > Related vim_dev threads: > > - Patch 7.4.2146 > > https://groups.google.com/d/msg/vim_dev/75ZXlRlBzl4/DDnqvSn9BgAJ > > - [vim/vim] VIM 7.4: Possible regression via patch 2146? (#972) > > https://groups.google.com/d/msg/vim_dev/mQ2YacpOKvo/vOsgkU-2AQAJ > > - Patch 7.4.2188 > > https://groups.google.com/d/msg/vim_dev/e2Rr8Px3qkQ/1XWiAQ0LAgAJ > > > > I think the series of behavior is correct. > > okay. > > > > , > > > | Dece > > > | > > > | December2015 > > > ` > > > (because after inserting the match is still in popupmenu mode and > > > "ends completion and goes back to what was there before selecting a > > > match") > > > > > > However, a total mystery is to me, when the test is run, it will > > > complete to > > > > > > , > > > | December2015 > > > | December2015 > > > | December2015 > > > ` > > > > Hmm?, I got the following result. (make test_popup in 7.4.2358) > > > > 1 FAILED: > > Found errors in Test_popup_complete2(): > > function RunTheTest[9]..Test_popup_complete2 line 10: Expected > > ['December2015', '', 'December2015'] but got ['Dece', '', 'December2015'] > > > > I think `['Dece', '', 'December2015']` is right. > > Okay then we can enable the test again and need to change the test > assert. I changed test_popup.vim I was wondering if you can check an attached patch? I would like you to check the mainly English sentence Thank you -- Best regards, Hirohito Higashi (a.k.a. h_east) -- -- 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. For more options, visit https://groups.google.com/d/optout. diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim index 6e07393..eae8bc3 100644 --- a/src/testdir/test_popup.vim +++ b/src/testdir/test_popup.vim @@ -17,16 +17,18 @@ func! ListMonths() endfunc func! Test_popup_complete2() - " Insert match immediately, if there is only one match - " Should select a character from the line below - " TODO: test disabled because the code change has been reverted. - throw "Skipped: Bug with and popupmenu not fixed yet" + " 'the popup menu is not visible' is not equivalent to 'the completion mode + " is not active'. + " After the type , Vim still stay in the first state of the completion + " mode. It is not related to the visible of popup. + " So that, the first behavior is `complete_CTRL-E`, and the second and + " more is `i_CTRL_E` new inoremap =ListMonths() call append(1, ["December2015"]) :1 call feedkeys("aD\\\", 'tx') - call assert_equal(["December2015", "", "December2015"], getline(1,3)) + call assert_equal(["Dece", "", "December2015"], getline(1,3)) %d bw! endfu
Re: [bug] lambda expressions
Hi Bram, 2016/9/22 Thu 2:37:29 UTC+9 Bram Moolenaar wrote: > Christian Brabandt wrote: > > > Am 2016-09-21 00:00, schrieb Ken Takata: > > > Hi Christian, > > > > > > 2016/9/21 Wed 5:31:26 UTC+9 Christian Brabandt wrote: > > >> Hi, > > >> I think I found a bug with lambda expressions. > > >> > > >> I was looking into writing some automated tests and was trying to use > > >> the new lambda expressions. However this does not work as expected: > > >> > > >> Here is an example: > > >> #v+ > > >> let a = ['FOOBAR"word"', 'FOOBAR"word2"'] > > >> let pat='^FOOBAR\s\+\zs"[^"]\+"' > > >> let pat2='^FOOBAR\s\+\("[^"]\+"\)' > > >> :echo map(copy(a), 'matchstr(v:val, g:pat)') > > >> -> result ['"word"', '"word2"'] > > >> :echo map(copy(a), {val -> matchstr(val, g:pat)}) > > >> -> BUG: result ['""', '""'], expected ['"word"', '"word2"'] > > >> :echo map(copy(a), 'substitute(v:val, g:pat2, > > >> ''\=submatch(1)'',"")') > > >> -> result ['"word"', '"word2"'] > > >> :echo map(copy(a), {val -> substitute(val, g:pat2, '\=submatch(1)', > > >> '')}) > > >> -> BUG: result ['0', '1'], expected ['"word", '"word2"'] > > >> #v- > > > > > > This is not a bug. map() always passes two arguments (key and val) to > > > the > > > specified Funcref. So, > > > > > >> :echo map(copy(a), {val -> matchstr(val, g:pat)}) > > > > > > this should be: > > > > > > :echo map(copy(a), {key, val -> matchstr(val, g:pat)}) > > > > > > Or you can still use v:val: > > > > > > :echo map(copy(a), {-> matchstr(v:val, g:pat)}) > > > > Hm, should there be an error when only one argument is given? > > Or at least it should be more stressed in the documentatio, that two > > arguments are expected. > > How about extending the example in the help: > > If {expr2} is a |Funcref| it is called with two arguments: > 1. The key or the index of the current item. > 2. the value of the current item. > The function must return the new value of the item. Example > that changes each value by "key-value": > > func KeyValue(key, val) > return a:key . '-' . a:val > endfunc > call map(myDict, function('KeyValue')) > < It is shorter when using a |lambda|: > > call map(myDict, {key, val -> key . '-' . val}) > < If you do not use "val" you can leave it out: > > call map(myDict, {key -> 'item: ' . key}) A similar update might be needed for `:help filter()`. Regards, Ken Takata -- -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [vim/vim] filetype plugin not loaded when file opened from within vim rather than from command line (#326)
Op 21 sep. 2016 23:40 schreef "Marty Chang": > > Actually I ran :scriptnames inside Vim as suggested on another thread and found that the py.vim file I put inside ~/.vim/ftplugin didn't even execute. Shouldn't it be called python.vim then? Christ van Willegen -- -- 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. For more options, visit https://groups.google.com/d/optout.
Re: conflicts with in windows console vim (vim.exe), bug ?
* skywind3000[160921 14:18]: > has been mapped to something in my vimrc, which works fine in > win32-gvim/macvim and linux/mac terminal vim (with backspace set to > 127/ctrl-? ) > > but in windows console vim, mapping will cause unable to > work properly (it appears that backspace also get mapped), > > After reading a lot of docs, I still can't figure out how to fix it . > > Is that a bug ? or something misconfiguration ? > > Can console behave exactly in the same way like other platforms ? , the ASCII character, is exactly Ctrl-h. , the keyboard key, in a terminal emulator (windows console, i.e. cmd.exe, is a terminal emulator) sends to the program whatever the terminal emulator decides, which is usually , but sometimes (the ASCII character). Many terminal emulators allow you to configure this to some degree. Most terminal emulators use VT102 or VT220 key codes and escape sequences by default. If you can configure the terminal emulator to send your own escape sequence, you can set the t_kb option to recognize it. I am pretty sure that Vim will treat this escape sequence separately from Ctrl-h in mappings. I don't know if you can get cmd.exe to send anything other than an ASCII character. ...Marvin -- -- 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. For more options, visit https://groups.google.com/d/optout.
Re: Vim 8 for Windows uninstaller
Eugene Mikhantiev wrote: > Do you know that Vim 8 Windows uninstaller (vim was downloaded from > official site) remove all from C:\Program files\ directory? > I had kill the process until it reached the Emacs directory. But it > was a nice try, Vim developers! Haven't heard about this before. No idea what would trigger this. -- ARTHUR: Who are you? TALL KNIGHT: We are the Knights Who Say "Ni"! BEDEVERE:No! Not the Knights Who Say "Ni"! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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. For more options, visit https://groups.google.com/d/optout.
Patch 8.0.0007
Patch 8.0.0007 Problem:Vim 7.4 is still mentioned in a few places. Solution: Update to Vim 8. (Uncle Bill, closes #1094) Files: src/INSTALLpc.txt, src/vimtutor, uninstal.txt *** ../vim-8.0.0006/src/INSTALLpc.txt 2016-09-06 21:57:36.0 +0200 --- src/INSTALLpc.txt 2016-09-21 22:36:29.535664962 +0200 *** *** 722,761 After you've built the Vim binaries as described above, you're ready to install Vim on your system. However, if you've obtained the Vim sources using Git, Mercurial or by downloading them as a unix tar file, you must ! first create a "vim74" directory. If you instead downloaded the sources as zip files, you can skip this setup as the zip archives already have the correct directory structure. ! A. Create a Vim "runtime" subdirectory named "vim74" - If you obtained your Vim sources as zip files, you can skip this step. Otherwise, continue reading. Go to the directory that contains the Vim "src" and "runtime" ! directories and create a new subdirectory named "vim74". ! Copy the "runtime" files into "vim74": ! copy runtime\* vim74 ! B. Copy the new binaries into the "vim74" directory Regardless of how you installed the Vim sources, you need to copy the ! new binaries you created above into "vim74": ! copy src\*.exe vim74 ! copy src\GvimExt\gvimext.dll vim74 ! copy src\xxd\xxd.exe vim74 ! C. Move the "vim74" directory into the Vim installation subdirectory - ! Move the "vim74" subdirectory into the subdirectory where you want Vim to be installed. Typically, this subdirectory will be named "vim". ! If you already have a "vim74" subdirectory in "vim", delete it first by running its uninstal.exe program. D. Install Vim --- ! "cd" to your Vim installation subdirectory "vim\vim74" and run the "install.exe" program. It will ask you a number of questions about how you would like to have your Vim setup. Among these are: - You can tell it to write a "_vimrc" file with your preferences in the --- 722,761 After you've built the Vim binaries as described above, you're ready to install Vim on your system. However, if you've obtained the Vim sources using Git, Mercurial or by downloading them as a unix tar file, you must ! first create a "vim80" directory. If you instead downloaded the sources as zip files, you can skip this setup as the zip archives already have the correct directory structure. ! A. Create a Vim "runtime" subdirectory named "vim80" - If you obtained your Vim sources as zip files, you can skip this step. Otherwise, continue reading. Go to the directory that contains the Vim "src" and "runtime" ! directories and create a new subdirectory named "vim80". ! Copy the "runtime" files into "vim80": ! copy runtime\* vim80 ! B. Copy the new binaries into the "vim80" directory Regardless of how you installed the Vim sources, you need to copy the ! new binaries you created above into "vim80": ! copy src\*.exe vim80 ! copy src\GvimExt\gvimext.dll vim80 ! copy src\xxd\xxd.exe vim80 ! C. Move the "vim80" directory into the Vim installation subdirectory - ! Move the "vim80" subdirectory into the subdirectory where you want Vim to be installed. Typically, this subdirectory will be named "vim". ! If you already have a "vim80" subdirectory in "vim", delete it first by running its uninstal.exe program. D. Install Vim --- ! "cd" to your Vim installation subdirectory "vim\vim80" and run the "install.exe" program. It will ask you a number of questions about how you would like to have your Vim setup. Among these are: - You can tell it to write a "_vimrc" file with your preferences in the *** ../vim-8.0.0006/src/vimtutor2010-05-15 13:04:10.0 +0200 --- src/vimtutor2016-09-21 22:37:47.659112782 +0200 *** *** 11,22 # Vim could be called "vim" or "vi". Also check for "vimN", for people who # have Vim installed with its version number. ! # We anticipate up to a future Vim 8 version :-). ! seq="vim vim8 vim75 vim74 vim73 vim72 vim71 vim70 vim7 vim6 vi" if test "$1" = "-g"; then # Try to use the GUI version of Vim if possible, it will fall back # on Vim if Gvim is not installed. ! seq="gvim gvim8 gvim75 gvim74 gvim73 gvim72 gvim71 gvim70 gvim7 gvim6 $seq" shift fi --- 11,22 # Vim could be called "vim" or "vi". Also check for "vimN", for people who # have Vim installed with
highlighting text
Hello, For a project I have to import some markings into vim and for that I'm writing a plugin. These markings are in the form of: line start, coloumn start, //the start character index line end, coloumn end, //the end character index message over the signs I have managed to mark the lines and display the message when the cursor is on the line. But now I need to highlight the characters, like a search does it when hlsearch is enabled, and the only thing i found is the matchadd() methode and commands like :match, but all of these work with a pattern. But i just need a straight forward mark exactly that mechanism which works on a line coloumn basis. I would much apriciate it if someone could point me in the right direction. Kind Regards Markus Knecht -- -- 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. For more options, visit https://groups.google.com/d/optout.
conflicts with in windows console vim (vim.exe), bug ?
has been mapped to something in my vimrc, which works fine in win32-gvim/macvim and linux/mac terminal vim (with backspace set to 127/ctrl-? ) but in windows console vim, mapping will cause unable to work properly (it appears that backspace also get mapped), After reading a lot of docs, I still can't figure out how to fix it . Is that a bug ? or something misconfiguration ? Can console behave exactly in the same way like other platforms ? -- -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [bug] lambda expressions
Christian Brabandt wrote: > Am 2016-09-21 00:00, schrieb Ken Takata: > > Hi Christian, > > > > 2016/9/21 Wed 5:31:26 UTC+9 Christian Brabandt wrote: > >> Hi, > >> I think I found a bug with lambda expressions. > >> > >> I was looking into writing some automated tests and was trying to use > >> the new lambda expressions. However this does not work as expected: > >> > >> Here is an example: > >> #v+ > >> let a = ['FOOBAR"word"', 'FOOBAR"word2"'] > >> let pat='^FOOBAR\s\+\zs"[^"]\+"' > >> let pat2='^FOOBAR\s\+\("[^"]\+"\)' > >> :echo map(copy(a), 'matchstr(v:val, g:pat)') > >> -> result ['"word"', '"word2"'] > >> :echo map(copy(a), {val -> matchstr(val, g:pat)}) > >> -> BUG: result ['""', '""'], expected ['"word"', '"word2"'] > >> :echo map(copy(a), 'substitute(v:val, g:pat2, > >> ''\=submatch(1)'',"")') > >> -> result ['"word"', '"word2"'] > >> :echo map(copy(a), {val -> substitute(val, g:pat2, '\=submatch(1)', > >> '')}) > >> -> BUG: result ['0', '1'], expected ['"word", '"word2"'] > >> #v- > > > > This is not a bug. map() always passes two arguments (key and val) to > > the > > specified Funcref. So, > > > >> :echo map(copy(a), {val -> matchstr(val, g:pat)}) > > > > this should be: > > > > :echo map(copy(a), {key, val -> matchstr(val, g:pat)}) > > > > Or you can still use v:val: > > > > :echo map(copy(a), {-> matchstr(v:val, g:pat)}) > > Hm, should there be an error when only one argument is given? > Or at least it should be more stressed in the documentatio, that two > arguments are expected. How about extending the example in the help: If {expr2} is a |Funcref| it is called with two arguments: 1. The key or the index of the current item. 2. the value of the current item. The function must return the new value of the item. Example that changes each value by "key-value": > func KeyValue(key, val) return a:key . '-' . a:val endfunc call map(myDict, function('KeyValue')) < It is shorter when using a |lambda|: > call map(myDict, {key, val -> key . '-' . val}) < If you do not use "val" you can leave it out: > call map(myDict, {key -> 'item: ' . key}) -- Eight Megabytes And Continually Swapping. /// 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. For more options, visit https://groups.google.com/d/optout.
Re: Strange ENOENT error caused by vim.basic
Thank you, that sorted it out! I was expecting it will be sth of this kind, and since i'm new to vim, didnt know where to search. thanks again, gnd/ On 09/21/2016 01:48 PM, James McCoy wrote: > On Wed, Sep 21, 2016 at 02:19:04AM +0200, gnd wrote: >> However i noticed there is some trouble with the way vim.basic handles >> file writes as compared to vim.tiny. The application i am using for >> live-coding, constantly checks a file for modifications, and if the file >> was modified, renders it to screen. Everything works well using >> vim.tiny, however after i started using vim.basic i noticed that i get >> very often a EOENT error from the application, which sometimes results >> in the code not being rendered. > > vim.tiny runs with 'compatible' set, so 'backupcopy' is set to "yes". > However, vim.basic runs with 'nocompatible' set, so 'backupcopy' is > "auto". It sounds like Vim is deciding that it can use the "no" > behavior of 'backupcopy' in the situation where you encounter ENOENT. > > When 'backupcopy' is effectively "no", the original file is renamed and > a new file is written when you save a buffer, so there is a window where > the original file name doesn't exist. > > When 'backupcoy' is effectively "yes", a copy of the original file is > made and the original is then overwritten, so the file path always > exists. > > Cheers, > -- -- 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. For more options, visit https://groups.google.com/d/optout.
Re: Strange ENOENT error caused by vim.basic
On Wed, Sep 21, 2016 at 02:19:04AM +0200, gnd wrote: > However i noticed there is some trouble with the way vim.basic handles > file writes as compared to vim.tiny. The application i am using for > live-coding, constantly checks a file for modifications, and if the file > was modified, renders it to screen. Everything works well using > vim.tiny, however after i started using vim.basic i noticed that i get > very often a EOENT error from the application, which sometimes results > in the code not being rendered. vim.tiny runs with 'compatible' set, so 'backupcopy' is set to "yes". However, vim.basic runs with 'nocompatible' set, so 'backupcopy' is "auto". It sounds like Vim is deciding that it can use the "no" behavior of 'backupcopy' in the situation where you encounter ENOENT. When 'backupcopy' is effectively "no", the original file is renamed and a new file is written when you save a buffer, so there is a window where the original file name doesn't exist. When 'backupcoy' is effectively "yes", a copy of the original file is made and the original is then overwritten, so the file path always exists. Cheers, -- James GPG Key: 4096R/91BF BF4D 6956 BD5D F7B7 2D23 DFE6 91AE 331B A3DB -- -- 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. For more options, visit https://groups.google.com/d/optout.
Strange ENOENT error caused by vim.basic
Hello, I recently switched to vim.basic on Xubuntu 16.10. Apart from many things i use it as a editing tool while doing live-coding performances. However i noticed there is some trouble with the way vim.basic handles file writes as compared to vim.tiny. The application i am using for live-coding, constantly checks a file for modifications, and if the file was modified, renders it to screen. Everything works well using vim.tiny, however after i started using vim.basic i noticed that i get very often a EOENT error from the application, which sometimes results in the code not being rendered. After many hours spent on this i realized it occurs only and only if i use vim.basic for editing of the file. The application checks the file modification time inside a infite loop using stat like this: --snip-- struct stat sb; if (stat(file_path, ) == -1) { int errsv = errno; if (errsv == ENOENT ){ printf("ENOENT: %s\r\n", file_path); } return 1; } *out_mod_time = sb.st_mtime; --snip-- Checking for all possible errnums i found the one returning is ENOENT and put a printf to capture the file_path as seen above. What is strange, whenever this happens i get a correct file_path from the application: ENOENT: shaders/tunnel.glsl I wonder what might be the cause, and also what makes up the difference between vim.tiny and vim.basic. I suppose it must be some special way of writing the file to disk and modifying the st_mtime, that triggers my error. Maybe i am doing the st_mtime check in a bad way. I am using VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 16 2016 10:50:38) and checked this behavior on two machines with freshly installed Xubuntu 16.10. It only happens when i edit the file with vim.basic never with vim.tiny, or if i use sed to edit the file. Maybe someone here can help me ? Im not sure if this is a bug, for me it is, but it might also be my application. thanks for any reply, gnd/ -- -- 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. For more options, visit https://groups.google.com/d/optout.
Vim 8 for Windows uninstaller
Hi! Do you know that Vim 8 Windows uninstaller (vim was downloaded from official site) remove all from C:\Program files\ directory? I had kill the process until it reached the Emacs directory. But it was a nice try, Vim developers! Best regards, Eugene -- -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [bug] lambda expressions
Am 2016-09-21 00:00, schrieb Ken Takata: Hi Christian, 2016/9/21 Wed 5:31:26 UTC+9 Christian Brabandt wrote: Hi, I think I found a bug with lambda expressions. I was looking into writing some automated tests and was trying to use the new lambda expressions. However this does not work as expected: Here is an example: #v+ let a = ['FOOBAR"word"', 'FOOBAR"word2"'] let pat='^FOOBAR\s\+\zs"[^"]\+"' let pat2='^FOOBAR\s\+\("[^"]\+"\)' :echo map(copy(a), 'matchstr(v:val, g:pat)') -> result ['"word"', '"word2"'] :echo map(copy(a), {val -> matchstr(val, g:pat)}) -> BUG: result ['""', '""'], expected ['"word"', '"word2"'] :echo map(copy(a), 'substitute(v:val, g:pat2, ''\=submatch(1)'',"")') -> result ['"word"', '"word2"'] :echo map(copy(a), {val -> substitute(val, g:pat2, '\=submatch(1)', '')}) -> BUG: result ['0', '1'], expected ['"word", '"word2"'] #v- This is not a bug. map() always passes two arguments (key and val) to the specified Funcref. So, :echo map(copy(a), {val -> matchstr(val, g:pat)}) this should be: :echo map(copy(a), {key, val -> matchstr(val, g:pat)}) Or you can still use v:val: :echo map(copy(a), {-> matchstr(v:val, g:pat)}) Hm, should there be an error when only one argument is given? Or at least it should be more stressed in the documentatio, that two arguments are expected. Best, Christian -- -- 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. For more options, visit https://groups.google.com/d/optout.