Re: Inserting a blank line in a large Ruby file (inside a big array def) takes a long time

2017-05-04 Thread Christian Brabandt

On Mi, 03 Mai 2017, Kelvin Lawrence wrote:

> So I ran two sets of profile data. One with syntax turned off and one with 
> syntax turned on. In both cases the opening of a new line took a long time. 
> With Syntax off it took around 12 seconds. With Syntax on it took 
> considerably longer. Neither  was ideal. Here are the respective sets of 
> results. It seems almost all of the time is spent in GetRubyIndent() and 
> GetMSL(). Note that if I open a line near the start of this huge array things 
> are a lot faster than if I do it near the end. It is the tracking back up the 
> array that seems to be relevant here.
> 
> WITH SYNTAX OFF
> FUNCTIONS SORTED ON TOTAL TIME
> count  total (s)   self (s)  function
> 1  11.429995   0.000433  GetRubyIndent()
> 1  11.428750   2.905020  31_GetMSL()
> 242303   6.722091   5.662566  31_Match()
> 40382   1.802138   1.301368  31_PrevNonBlankNonString()
> 121145   1.560333 31_IsInStringOrComment()
> 6   0.000524 18_Highlight_Matching_Pair()
> 1   0.000281   0.000255  31_ExtraBrackets()
> 1   0.000113 19_LocalBrowse()
> 1   0.11 31_IsInStringOrDocumentation()
> 1   0.08 31_IsInString()
> 
> 
> WITH SYNTAX ON
> FUNCTIONS SORTED ON TOTAL TIME
> count  total (s)   self (s)  function
> 2 380.583226   0.000717  GetRubyIndent()
> 2 380.576016   7.012970  28_GetMSL()
> 242281 355.479600 28_IsInStringOrComment()
> 80761 333.381260   3.834304  28_PrevNonBlankNonString()
> 484588  40.187259  14.255150  28_Match()
>67   0.011742 18_Highlight_Matching_Pair()
> 1   0.008798   0.003935  10_LoadFTPlugin()
> 1   0.005508   0.001476  5_SynSet()
> 2   0.001664   0.001185  8_BMMunge()
> 1   0.001389   0.001338  11_LoadIndent()
> 1   0.001269   0.000272  8_BMAdd()
> 1   0.001183   0.000353  8_BMRemove()
>10   0.001163 19_LocalBrowse()
> 1   0.000996   0.000128  8_BMFilename()
> 2   0.000521   0.000316  28_ExtraBrackets()
> 2   0.000479 8_BMTruncName()
>15   0.000417 27_map()
> 2   0.000144 28_IsInString()
>22   0.64 26_foldable()
> 1   0.42 27_build_path()

Thanks that clears things up. The problem is clearly the indent script. 
You can work around it by temporarily disabling it `:setl indentexpr=`

You might want to report this findings to the upstream repository:
https://github.com/vim-ruby/vim-ruby

and it looks like there is already an issue for:
https://github.com/vim-ruby/vim-ruby/issues/287


Best,
Christian
-- 
Gestorbne Freunde sind Ketten, die uns von der Erde ziehen und fester
mit einer bessern Welt verknüpfen.
-- Jean Paul

-- 
-- 
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: RFE: 'listchars' entry for soft-hyphen

2017-05-04 Thread Tony Mechelynck
On Thu, May 4, 2017 at 8:27 AM, Christian Brabandt  wrote:
[...]
> Is this really necessary? You can now use concealing to show arbitrary
> code points differently.
>
> :call matchadd('Conceal', '\%uad', 10, -1, {'conceal': '↔'})
> :set conceallevel=2 concealcursor=nv
[...]

Hmm... All this is per-window...
OK, I'll see how it works in ~/.vim/after/syntax/html.vim

I still feel it would belong more logically in 'listchars' which
already has entries for nbsp: tab: etc. Would you want to kill these
too and replace them by the conceal feature?

Best regards,
Tony.

-- 
-- 
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: wrong command-line redraw when using 'out_io': 'buffer' with job_start()

2017-05-04 Thread Ramel Eshed
On Monday, May 1, 2017 at 3:32:04 PM UTC+3, Bram Moolenaar wrote:
> Ramel Eshed wrote:
> 
> > On Sunday, April 30, 2017 at 9:24:13 PM UTC+3, Bram Moolenaar wrote:
> > > Ramel Eshed wrote:
> > > 
> > > > On Sunday, April 30, 2017 at 5:25:08 PM UTC+3, Bram Moolenaar wrote:
> > > > > Ramel Eshed wrote:
> > > > > 
> > > > > > This is not the case with every job, but redirecting the following
> > > > > > script output to a buffer causes messages to disappear from command
> > > > > > line:
> > > > > >  
> > > > > > -- loop.sh --
> > > > > > #!/bin/bash
> > > > > > for i in `seq 1 1000`;
> > > > > > do
> > > > > > echo $i
> > > > > > sleep 0.008s
> > > > > > done
> > > > > > 
> > > > > > vim -u NONE -N
> > > > > > :call job_start('loop.sh', {'out_io': 'buffer', 'out_buf':1})
> > > > > > 
> > > > > > while the numbers are running try to do :pwd -this command's output
> > > > > > will disappear.
> > > > > > 
> > > > > > Also (not related to this issue), the buffer (which the job output 
> > > > > > was
> > > > > > redirected to) is only updated in normal and insert mode but not 
> > > > > > while
> > > > > > typing in command-line mode. Is it possible to update the buffer 
> > > > > > also
> > > > > > for command-line?
> > > > > 
> > > > > I suspect these are opposite requests.  Vim can only update the whole
> > > > > screen, because the redraw causes any output from commands to be
> > > > > cleared. When looking at the output of :pwd, Vim is probably in Normal
> > > > > mode, thus redraws to show the new buffer content.
> > > >
> > > > If I use
> > > > :call job_start('ls -lR /', {'out_io': 'buffer', 'out_buf':1})
> > > > instead of the above script, I can still see the :pwd command output.
> > > > How come it's not cleared as well?
> > > >
> > > > > I could check if we can update the window only. This probably only 
> > > > > works
> > > > > when the command line has not scrolled.
> > > 
> > > I have sent out patch 8.0.0592.  This attempts to update the buffer that
> > > shows job output as often as possible.  And it tries to keep the command
> > > line and command output.  Please check it out.  It does update the
> > > buffer more often than before, and should keep the output of commands
> > > like ":pwd".  It may cause new problems, I only tested a few things.
> > > 
> > I tested this patch with my plugins and it seems that both issues are
> > solved now. There is a minor issue with text and cursor flickering in
> > the command line, you can play with the sleep delay in the script
> > above and see if there is something you can do.
> > Many thanks!
> 
> It is unlikely the cursor flickering can be fixed.  It has to be
> switched off to be able to redraw the window for the modified buffer.
> 
Besides of the cursor, the part of the command that has already been typed 
flickers as well, can you see that?

Also, I found a problem with the command line completion menu - it is cleared 
while the buffer is updated. You can see that by running my example above after 
:set wildmode=list. While the buffer is updated try to type :set and then hit 
tab -the completion menu will be cleared.

> -- 
> Veni, Vidi, VW -- I came, I saw, I drove around in a little car.
> 
>  /// 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: RFE: 'listchars' entry for soft-hyphen

2017-05-04 Thread Christian Brabandt

On Do, 04 Mai 2017, Tony Mechelynck wrote:

> On Thu, May 4, 2017 at 8:27 AM, Christian Brabandt  wrote:
> [...]
> > Is this really necessary? You can now use concealing to show arbitrary
> > code points differently.
> >
> > :call matchadd('Conceal', '\%uad', 10, -1, {'conceal': '↔'})
> > :set conceallevel=2 concealcursor=nv
> [...]
> 
> Hmm... All this is per-window...

as is 'list' option.

> OK, I'll see how it works in ~/.vim/after/syntax/html.vim
> 
> I still feel it would belong more logically in 'listchars' which
> already has entries for nbsp: tab: etc.

Of course Bram has the final say here.

> Would you want to kill these too and replace them by the conceal
> feature?

I have no such intention and it would be backwards incompatible.

Best,
Christian
-- 
Mit nichts ist man freigiebiger als mit Ratschlägen, und mit nichts
sollte man zurückhaltender sein.
-- François de La Rochefoucauld

-- 
-- 
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: RFE: 'listchars' entry for soft-hyphen

2017-05-04 Thread Tony Mechelynck
Something must have gone wrong.

After adding that custom syntax script, the string ''
present in register x, register /, and as the whole contents of the
cursor line, is shown as <↔↔↔> instead. After removing the syntax
script, it is (spontaneously) displayed normally again. Apart from
comments, I had written that html.vim syntax file as (IIRC)

if &enc =~? '^u' && has('conceal') && exists('*matchadd')
  call matchadd('Conceal', "\%uad", 10, -1, {'conceal': '↔'})
  set conceallevel=2 concealcursor=nvic
endif

I didn't try to move the cursor away from that line but I noticed that
actual soft-hyphens some lines down did not appear as ↔

Next trime I try (if I do) I'll use :setlocal rather than :set but
apart from that...
Oh, could it be the difference between single and double quotes around
that \%uad item?


Best regards,
Tony.

On Thu, May 4, 2017 at 12:08 PM, Christian Brabandt  wrote:
>
> On Do, 04 Mai 2017, Tony Mechelynck wrote:
>
>> On Thu, May 4, 2017 at 8:27 AM, Christian Brabandt  
>> wrote:
>> [...]
>> > Is this really necessary? You can now use concealing to show arbitrary
>> > code points differently.
>> >
>> > :call matchadd('Conceal', '\%uad', 10, -1, {'conceal': '↔'})
>> > :set conceallevel=2 concealcursor=nv
>> [...]
>>
>> Hmm... All this is per-window...
>
> as is 'list' option.
>
>> OK, I'll see how it works in ~/.vim/after/syntax/html.vim
>>
>> I still feel it would belong more logically in 'listchars' which
>> already has entries for nbsp: tab: etc.
>
> Of course Bram has the final say here.
>
>> Would you want to kill these too and replace them by the conceal
>> feature?
>
> I have no such intention and it would be backwards incompatible.
>
> Best,
> Christian
> --
> Mit nichts ist man freigiebiger als mit Ratschlägen, und mit nichts
> sollte man zurückhaltender sein.
> -- François de La Rochefoucauld
>
> --
> --
> 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.

-- 
-- 
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: RFE: 'listchars' entry for soft-hyphen

2017-05-04 Thread Christian Brabandt

On Do, 04 Mai 2017, Tony Mechelynck wrote:

> Something must have gone wrong.
> 
> After adding that custom syntax script, the string ''
> present in register x, register /, and as the whole contents of the
> cursor line, is shown as <↔↔↔> instead. After removing the syntax
> script, it is (spontaneously) displayed normally again. Apart from
> comments, I had written that html.vim syntax file as (IIRC)
> 
> if &enc =~? '^u' && has('conceal') && exists('*matchadd')
>   call matchadd('Conceal', "\%uad", 10, -1, {'conceal': '↔'})

"\uad"
>   set conceallevel=2 concealcursor=nvic
> endif
> 
> I didn't try to move the cursor away from that line but I noticed that
> actual soft-hyphens some lines down did not appear as ↔

Best,
Christian
-- 
Wie man sein Kind nicht nennen sollte: 
  Ben Zin 

-- 
-- 
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: RFE: 'listchars' entry for soft-hyphen

2017-05-04 Thread Tony Mechelynck
On Thu, May 4, 2017 at 12:58 PM, Christian Brabandt  wrote:
>
> On Do, 04 Mai 2017, Tony Mechelynck wrote:
>
>> Something must have gone wrong.
>>
>> After adding that custom syntax script, the string ''
>> present in register x, register /, and as the whole contents of the
>> cursor line, is shown as <↔↔↔> instead. After removing the syntax
>> script, it is (spontaneously) displayed normally again. Apart from
>> comments, I had written that html.vim syntax file as (IIRC)
>>
>> if &enc =~? '^u' && has('conceal') && exists('*matchadd')
>>   call matchadd('Conceal', "\%uad", 10, -1, {'conceal': '↔'})
>
> "\uad"
>>   set conceallevel=2 concealcursor=nvic
>> endif
>>
>> I didn't try to move the cursor away from that line but I noticed that
>> actual soft-hyphens some lines down did not appear as ↔

Same result with '\%uad' or '\%xad' (both with single quotes) or
"\xad" (with double quotes). The problem disappears, of course, when I
manually do :setlocal conceallevel=0. There already is a 3match (by
<:> added to 'matchpairs') at the cursor where the problem happens;
moving the cursor away hides the < and > but the double-arrows remain.

The conceal character is U+2194, or UTF-8 E2 86 94. Might explain the
fact that the apparent length of the string (which uses ASCII and
Cyrillic characters requiring only 1 or 2 bytes ech) is reduced but
not the fact that the match happens where it shouldn't, or that id
doesn't happen where it should.

Since this is an after-syntax script, maybe I should use :syntax match
rather than :call matchadd() ?

See you later, I have to go.


Best regards,
Tony.

-- 
-- 
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: Inserting a blank line in a large Ruby file (inside a big array def) takes a long time

2017-05-04 Thread Kelvin Lawrence
Thanks Christian, I added my findings to that open issue. Sadly that issue is 
two years old. I think they may need help from someone on this list who might 
have suggestions on how to fix the issue. Having just read the comments in the 
issue the implication is they don't know how to fix it.

Kelvin

-- 
-- 
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] setfiletype does not work in packages (#1679)

2017-05-04 Thread Ben Fritz
On Thursday, May 4, 2017 at 10:56:21 AM UTC-5, Andy Stewart wrote:
> 
> I believe this is because vim's filetype detection uses:
> 
> runtime! ftdetect/*.vim
> 
> I think that when that line is executed, the plugins in 
> ~/.vim/pack/stuff/start/ are not on the runtimepath.  So Vim falls back to 
> its generic configuration file.
> 
> When I change that line to:
> 
> runtime! ALL ftdetect/*.vim
> 
> – the filetype is set as expected.
> 
> Vim 8.0.586.
> 


Hmm, that will also search in "opt" packages. I don't think that's wanted 
unless the user has used packadd already in which case it will be in the 
runtimepath. Probably it should just search the "start" packages and then the 
runtime. How is this done? Does it need two runtime commands, first "runtime! 
START ftdetect/*.vim" followed by "runtime! ftdetect/*.vim" to pick up the 
runtimepath files?

-- 
-- 
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: Patch 8.0.0590

2017-05-04 Thread Yegappan Lakshmanan
Hi,

On Wed, May 3, 2017 at 1:25 PM, Yegappan Lakshmanan  wrote:
> Hi Bram,
>
> On Sun, Apr 30, 2017 at 5:21 AM, Bram Moolenaar  wrote:
>>
>> Patch 8.0.0590
>> Problem:Cannot add a context to locations.
>> Solution:   Add the "context" entry in location entries. (Yegappan 
>> Lakshmanan,
>> closes #1012)
>> Files:  src/eval.c, src/proto/quickfix.pro, src/quickfix.c,
>> src/testdir/test_quickfix.vim
>>
>
> The setqflist() function only sets the context for the current quickfix list.
> Even if the quickfix list number in the stack is specified, it sets the
> context for the current list instead of the specified list. I am attaching a
> patch to fix this bug. It also includes additional tests.
>
> Note that the getqflist() function works correctly by returning the
> context for the specified quickfix list.
>

An updated patch is attached.

- 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.
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/quickfix.c b/src/quickfix.c
index 7b07f9358..0aca4ad0c 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -4877,7 +4877,9 @@ qf_set_properties(qf_info_T *qi, dict_T *what, int action)
/* Use the specified quickfix/location list */
if (di->di_tv.v_type == VAR_NUMBER)
{
-   qf_idx = di->di_tv.vval.v_number - 1;
+   /* for zero use the current list */
+   if (di->di_tv.vval.v_number != 0)
+   qf_idx = di->di_tv.vval.v_number - 1;
if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
return FAIL;
}
@@ -4908,11 +4910,11 @@ qf_set_properties(qf_info_T *qi, dict_T *what, int 
action)
 if ((di = dict_find(what, (char_u *)"context", -1)) != NULL)
 {
typval_T*ctx;
-   free_tv(qi->qf_lists[qi->qf_curlist].qf_ctx);
+   free_tv(qi->qf_lists[qf_idx].qf_ctx);
ctx =  alloc_tv();
if (ctx != NULL)
copy_tv(&di->di_tv, ctx);
-   qi->qf_lists[qi->qf_curlist].qf_ctx = ctx;
+   qi->qf_lists[qf_idx].qf_ctx = ctx;
 }
 
 return retval;
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index f1fd3c97a..b0a873dc3 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -1804,6 +1804,36 @@ func Xproperty_tests(cchar)
call setloclist(0, [], 'f')
call assert_equal({}, getloclist(0, {'context':1}))
 endif
+
+" Test for changing the context of previous quickfix lists
+call g:Xsetlist([], 'f')
+Xexpr "One"
+Xexpr "Two"
+Xexpr "Three"
+call g:Xsetlist([], ' ', {'context' : [1], 'nr' : 1})
+call g:Xsetlist([], ' ', {'context' : [2], 'nr' : 2})
+call g:Xsetlist([], ' ', {'context' : [3], 'nr' : 3})
+call test_garbagecollect_now()
+let l = g:Xgetlist({'nr' : 1, 'context' : 1})
+call assert_equal([1], l.context)
+let l = g:Xgetlist({'nr' : 2, 'context' : 1})
+call assert_equal([2], l.context)
+let l = g:Xgetlist({'nr' : 3, 'context' : 1})
+call assert_equal([3], l.context)
+
+" Test for changing the context through reference and for garbage
+" collection of quickfix context
+let l = ["red"]
+call g:Xsetlist([], ' ', {'context' : l})
+call add(l, "blue")
+let x = g:Xgetlist({'context' : 1})
+call add(x.context, "green")
+call assert_equal(["red", "blue", "green"], l)
+call assert_equal(["red", "blue", "green"], x.context)
+unlet l
+call test_garbagecollect_now()
+let m = g:Xgetlist({'context' : 1})
+call assert_equal(["red", "blue", "green"], m.context)
 endfunc
 
 func Test_qf_property()