Re: [vim/vim] Fix #1168 completion problem from #875 (#1169)

2016-10-14 Fir de Conversatie h_east
2016-10-15(Sat) 13:58:03 UTC+9 Shougo:
> OK.  I have added the test.
> 
> But it is very hard to simulate the completion wait.
> 
> Because the test omnifunc is asynchronous.

Issue#1168 repro steps doesn't seem to asynchronous for me.
Where is the asynchronous?

> 
> The test fix is wellcome.

--
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.


Re: [vim/vim] Fix #1168 completion problem from #875 (#1169)

2016-10-14 Fir de Conversatie h_east
You should add a test.

--
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.


[patch] Add completion for :messages

2016-10-14 Fir de Conversatie h_east
Hi Bram and list,

Type `:messages ` and push Tab key.

None patched behavior:
- Output Ctrl-I code
  :messages ^I

Patched behavior:
- Complete `clear`
  :messages clear


Attach a patch. (Contains a test)
Check it please.
--
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/ex_docmd.c b/src/ex_docmd.c
index ac7beb7..6802b8b 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -4281,6 +4281,11 @@ set_one_cmd_context(
 	xp->xp_pattern = arg;
 	break;
 
+	case CMD_messages:
+	xp->xp_context = EXPAND_MESSAGES;
+	xp->xp_pattern = arg;
+	break;
+
 #if defined(FEAT_CMDHIST)
 	case CMD_history:
 	xp->xp_context = EXPAND_HISTORY;
@@ -5893,6 +5898,7 @@ static struct
 #endif
 {EXPAND_MAPPINGS, "mapping"},
 {EXPAND_MENUS, "menu"},
+{EXPAND_MESSAGES, "messages"},
 {EXPAND_OWNSYNTAX, "syntax"},
 #if defined(FEAT_PROFILE)
 {EXPAND_SYNTIME, "syntime"},
@@ -11901,6 +11907,18 @@ get_behave_arg(expand_T *xp UNUSED, int idx)
 	return (char_u *)"xterm";
 return NULL;
 }
+
+/*
+ * Function given to ExpandGeneric() to obtain the possible arguments of the
+ * ":messages {clear}" command.
+ */
+char_u *
+get_messages_arg(expand_T *xp UNUSED, int idx)
+{
+if (idx == 0)
+	return (char_u *)"clear";
+return NULL;
+}
 #endif
 
 #ifdef FEAT_AUTOCMD
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 25a12be..5d098cc 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -4832,6 +4832,7 @@ ExpandFromContext(
 	{
 	{EXPAND_COMMANDS, get_command_name, FALSE, TRUE},
 	{EXPAND_BEHAVE, get_behave_arg, TRUE, TRUE},
+	{EXPAND_MESSAGES, get_messages_arg, TRUE, TRUE},
 #ifdef FEAT_CMDHIST
 	{EXPAND_HISTORY, get_history_arg, TRUE, TRUE},
 #endif
diff --git a/src/proto/ex_docmd.pro b/src/proto/ex_docmd.pro
index b92ce80..11a3f71 100644
--- a/src/proto/ex_docmd.pro
+++ b/src/proto/ex_docmd.pro
@@ -61,4 +61,5 @@ int put_eol(FILE *fd);
 int put_line(FILE *fd, char *s);
 void dialog_msg(char_u *buff, char *format, char_u *fname);
 char_u *get_behave_arg(expand_T *xp, int idx);
+char_u *get_messages_arg(expand_T *xp, int idx);
 /* vim: set ft=c : */
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 4bacf57..3718087 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -129,6 +129,11 @@ func Test_getcompletion()
   let l = getcompletion('dark', 'highlight')
   call assert_equal([], l)
 
+  let l = getcompletion('', 'messages')
+  call assert_true(index(l, 'clear') >= 0)
+  let l = getcompletion('not', 'messages')
+  call assert_equal([], l)
+
   if has('cscope')
 let l = getcompletion('', 'cscope')
 let cmds = ['add', 'find', 'help', 'kill', 'reset', 'show']
diff --git a/src/vim.h b/src/vim.h
index a787575..0ac296e 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -793,6 +793,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
 #define EXPAND_SYNTIME		43
 #define EXPAND_USER_ADDR_TYPE	44
 #define EXPAND_PACKADD		45
+#define EXPAND_MESSAGES		46
 
 /* Values for exmode_active (0 is no exmode) */
 #define EXMODE_NORMAL		1


Re: [bug][patch] matchaddpos() may not draw overldapped pos.

2016-10-14 Fir de Conversatie h_east
Hi Bram and Kiichi,

2016-10-15(Sat) 3:41:58 UTC+9 Bram Moolenaar:
> Ozaki Kiichi wrote:
> 
> > This is matchaddpos() problem.
> > 
> > [repro steps]
> > 
> > vim -Nu NONE
> > 
> > i1234567890
> > :call matchaddpos('ErrorMsg', [[1, 1, 5], [1, 3, 5]])
> > 
> > expected: colored 1~7 ("12345" and "34567"; pos [1, 1, 5] and [1, 3, 5], 
> > overlapped "345")
> > 
> > actual: colored 1~5 ("12345"; only first pos [1, 1, 5])
> > 
> > This problem occurs when overlapping more than 1 char.
> > e.g. [[1, 1, 5], [1, 5, 5]] is no problem.
> > 
> > [cause]
> > 
> > https://github.com/vim/vim/blob/fd89d7e/src/screen.c#L7770-L7771
> > 
> > On processing second pos [1, 3, 5], mincol is 5 (end of first pos col).
> > Thus, col (== 3) is less then mincol, and second pos is skipped.
> > 
> > I think that the case of "col < mincol < col + len -1" should be also 
> > processed.
> > 
> > [patch]
> > 
> > https://gist.github.com/ichizok/f34c9018f5e9e452d3bc78cc9026a720
> 
> Can you please add a test that fails without the patch?

Here is a test patch.
I confirmed pass the test with Kiichi's patch, and fails without it.
--
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_match.vim b/src/testdir/test_match.vim
index 9ac1db1..20da0db 100644
--- a/src/testdir/test_match.vim
+++ b/src/testdir/test_match.vim
@@ -181,6 +181,16 @@ func Test_matchaddpos()
   redraw!
   call assert_equal(screenattr(2,2), screenattr(1,6))
 
+  " Check overwrapped pos
+  call clearmatches()
+  call setline(1, ['1234567890', 'NH'])
+  call matchaddpos('Error', [[1,1,5], [1,3,5], [2,2]])
+  redraw!
+  call assert_notequal(screenattr(2,2), 0)
+  call assert_equal(screenattr(2,2), screenattr(1,5))
+  call assert_equal(screenattr(2,2), screenattr(1,7))
+  call assert_notequal(screenattr(2,2), screenattr(1,8))
+
   nohl
   syntax off
   set hlsearch&


Re: [PATCH] syntax: Improve foldlevel on lines where it changes horizontally

2016-10-14 Fir de Conversatie Bram Moolenaar

Brad King wrote:

> I'd like to improve C-syntax folding for a common code format style.
> 
> With `foldmethod=syntax` the code:
> 
> if (...) {
>   ...
> }
> else if (...) {
>   ...
> }
> else {
>   ...
> }
> 
> folds like this:
> 
> +---  3 lines: if (...) {---
> +---  3 lines: else if (...) {--
> +---  3 lines: else {---
> 
> However, the code:
> 
> if (...) {
>   ...
> } else if (...) {
>   ...
> } else {
>   ...
> }
> 
> folds like this:
> 
> +---  7 lines: if (...) {---
> 
> We can make the latter case fold like this:
> 
> +---  2 lines: if (...) {---
> +---  2 lines: } else if (...) {
> +---  3 lines: } else {-
> 
> by choosing on each line the lowest fold level that is followed
> by a higher fold level.
> 
> Please see patch attached.  FWIW I've been running with this patch
> for months to test it.

Making this change in the C code means all folding is affected.
Most likely this will have side effects.

Either this needs to be donein the C syntax, or we need an folding
option to enable this behavior.


-- 
BRIDGEKEEPER: What is your favorite colour?
LAUNCELOT:Blue.
BRIDGEKEEPER: Right.  Off you go.
 "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.


Re: [patch] improve ended-job check

2016-10-14 Fir de Conversatie LCD 47
On 14 October 2016, Bram Moolenaar  wrote:
> 
> Ozaki Kiichi wrote:
> 
> > Currently, vim checks ended-job every 10 second; thus exit_cb is delayed
> > 10 seconds at the maximum.
> > 
> > I propose the following:
> > 
> > https://gist.github.com/ichizok/fe9743f46822a9015ed2f7d65238c5db
> > 
> > os_unix: check by waitpid(-1, _, WNOHANG).
> > os_win32: check by WaitForMultipleObjects(),
> > "the number of active jobs" / MAXIMUM_WAIT_OBJECTS (==64) times.
> > 
> > They suppress the count of calling syscall to be nearly constant regardless
> > of the number of active jobs.
> > 
> > # I set MAX_ENDED_JOB_COUNT (the maximum number of detections
> > # in job_check_ended()) to 8, but this may require consideration.
> 
> Looks useful.
>
> The JOB_WAITED value does not have a clear meaning.  It looks like we
> know the job has ended, but has not been cleaned up yet.  Perhaps call
> it JOB_EXITED ?

On a side note: a Vim function job_wait() that would do a blocking
wait for a given job would be useful, too.

/lcd

-- 
-- 
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] 2 problems about job

2016-10-14 Fir de Conversatie Bram Moolenaar

Yasuhiro Matsumoto wrote:

> Sorry, It was wrong. I updated patch
> 
> https://gist.github.com/mattn/d47e7d3bfe5ade4be86062b565a4bfca
> 
> On Wednesday, October 12, 2016 at 11:19:06 PM UTC+9, Bram Moolenaar wrote:
> > +strsave_for_argv(char_u *string)
> > 
> > I would call the argument "argv" and the escaped result "argv_escaped".
> 
> renamed strsave_for_argv to escape_arg, string to arg, escaped_string to 
> arg_escaped.
> 
> > 
> > +   has_spaces = 1;
> > 
> > Use TRUE and FALSE instead of 1 and 0.
> 
> okay, thank you.
> 
>  
> > +   if (*p == '\n')
> > +   ++length;
> > 
> > But the "\n" is not escaped, thus this is not needed.
> 
> Yes, removed.
> 
> > +if (escaped_string == NULL)
> > +   return escaped_string;
> > 
> > Can return NULL.
> 
> this too.
> 
> > +   else
> > +   if (*p == '\\')
> > 
> > Should be one line.
> 
> ditto
> 
> > Also, there is no test for a backslash in the text.  It would also need
> > to test for two or three backslashes.  And one or two backslashes
> > followed by a double quote.
> > 
> > I would rename "p" to "s" (stands for source).
> 
> ditto
> 
> > +/* add terminating quote and finish with a NUL */
> > +if (has_spaces)
> > +{
> > +   for (i = 0; i < escaping; i++)
> > +   *d++ = '\\';
> > +   *d++ = '"';
> > +}
> > +*d = NUL;
> > 
> > Adding backslashes before the terminating quote looks strange.  If this
> > is correct it should be covered by a test.
> 
> Yes, I was confused. Totally, fixed implementation. But terminating quote is 
> right. See test code.
> 
> > +func s:test_list_args(msg, out)
> > 
> > Use "cmd" instead of "msg".
> 
> fixed too
> 
> > +call job_start([s:python, '-c', a:msg], {'callback': 
> > {ch,msg->execute('let s:out.=msg."\n"')}})
> > 
> > Why append the "\n"?
> 
> For the separator, but not required at least. Then removed.
> 
> > +  call s:test_list_args('print(''hello"world'')', "hello\"world\n")
> > 
> > This seems wrong.  The argument is hello"world but it results in an
> > extra backslash.
> 
> Please look carefully. "hello\"world\n"
> 
> Double quote in the quote should be escaped with backslash on Vim script as 
> you know.

Thanks, I'll look into the updated patch soon.

-- 
ARTHUR:  No, hang on!  Just answer the five questions ...
GALAHAD: Three questions ...
ARTHUR:  Three questions ...  And we shall watch ... and pray.
 "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.


Re: [patch] improve ended-job check

2016-10-14 Fir de Conversatie Bram Moolenaar

Ozaki Kiichi wrote:

> Currently, vim checks ended-job every 10 second; thus exit_cb is delayed
> 10 seconds at the maximum.
> 
> I propose the following:
> 
> https://gist.github.com/ichizok/fe9743f46822a9015ed2f7d65238c5db
> 
> os_unix: check by waitpid(-1, _, WNOHANG).
> os_win32: check by WaitForMultipleObjects(),
> "the number of active jobs" / MAXIMUM_WAIT_OBJECTS (==64) times.
> 
> They suppress the count of calling syscall to be nearly constant regardless
> of the number of active jobs.
> 
> # I set MAX_ENDED_JOB_COUNT (the maximum number of detections
> # in job_check_ended()) to 8, but this may require consideration.

Looks useful.

The JOB_WAITED value does not have a clear meaning.  It looks like we
know the job has ended, but has not been cleaned up yet.  Perhaps call
it JOB_EXITED ?

-- 
Permission is granted to read this message out aloud on Kings Cross Road,
London, under the condition that the orator is properly dressed.

 /// 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: [bug][patch] matchaddpos() may not draw overldapped pos.

2016-10-14 Fir de Conversatie Bram Moolenaar

Ozaki Kiichi wrote:

> This is matchaddpos() problem.
> 
> [repro steps]
> 
> vim -Nu NONE
> 
> i1234567890
> :call matchaddpos('ErrorMsg', [[1, 1, 5], [1, 3, 5]])
> 
> expected: colored 1~7 ("12345" and "34567"; pos [1, 1, 5] and [1, 3, 5], 
> overlapped "345")
> 
> actual: colored 1~5 ("12345"; only first pos [1, 1, 5])
> 
> This problem occurs when overlapping more than 1 char.
> e.g. [[1, 1, 5], [1, 5, 5]] is no problem.
> 
> [cause]
> 
> https://github.com/vim/vim/blob/fd89d7e/src/screen.c#L7770-L7771
> 
> On processing second pos [1, 3, 5], mincol is 5 (end of first pos col).
> Thus, col (== 3) is less then mincol, and second pos is skipped.
> 
> I think that the case of "col < mincol < col + len -1" should be also 
> processed.
> 
> [patch]
> 
> https://gist.github.com/ichizok/f34c9018f5e9e452d3bc78cc9026a720

Can you please add a test that fails without the patch?

-- 
ROBIN:  (warily) And if you get a question wrong?
ARTHUR: You are cast into the Gorge of Eternal Peril.
ROBIN:  Oh ... wacho!
 "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.


Re: [bug][patch] Doing ":redraw" during external command causes strange screen state

2016-10-14 Fir de Conversatie Bram Moolenaar

Ozaki Kiichi wrote:

> > Isn't this a bit too drastic?  When termcap_active it should still be
> > possible to output text (e.g. from another timer command).
> > 
> > Also check msg_use_printf().  Looks like your change overrules its own
> > check for termcap_active.
> 
> Hmm, yes. I think we should suppress updating screen while
> doing stoptermcap() ~ starttermcap() (i.e termcap_active == FALSE).
> 
> Can we check termcap_active only in specific screen-updating functions
> (update_screen, or some), or should not do such?

Check the calls to screen_valid().  An explicit check at some of them
that termcap_active is FALSE should help.

We should perhaps also update must_redraw when bailing out.
It's needed when invoked from ex_redraw().

-- 
To the optimist, the glass is half full.
To the pessimist, the glass is half empty.
To the engineer, the glass is twice as big as it needs to be.

 /// 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: [patch] improve ended-job check

2016-10-14 Fir de Conversatie Christian Brabandt
Hi Ozaki!

On Fr, 14 Okt 2016, Ozaki Kiichi wrote:

> Hi.
> 
> Currently, vim checks ended-job every 10 second; thus exit_cb is delayed
> 10 seconds at the maximum.
> 
> I propose the following:
> 
> https://gist.github.com/ichizok/fe9743f46822a9015ed2f7d65238c5db
> 
> os_unix: check by waitpid(-1, _, WNOHANG).
> os_win32: check by WaitForMultipleObjects(),
> "the number of active jobs" / MAXIMUM_WAIT_OBJECTS (==64) times.
> 
> They suppress the count of calling syscall to be nearly constant regardless
> of the number of active jobs.
> 
> # I set MAX_ENDED_JOB_COUNT (the maximum number of detections
> # in job_check_ended()) to 8, but this may require consideration.
> 
> Thank you.

Does that fix #1155?

Best,
Christian
-- 
Nichts auf der Welt ist so gerecht verteilt wie der Verstand. Denn
jedermann ist überzeugt, daß er genug davon habe.
-- René Descartes (1596-1650) 

-- 
-- 
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] syntax: Improve foldlevel on lines where it changes horizontally

2016-10-14 Fir de Conversatie Brad King
Hi Folks,

I'd like to improve C-syntax folding for a common code format style.

With `foldmethod=syntax` the code:

if (...) {
  ...
}
else if (...) {
  ...
}
else {
  ...
}

folds like this:

+---  3 lines: if (...) {---
+---  3 lines: else if (...) {--
+---  3 lines: else {---

However, the code:

if (...) {
  ...
} else if (...) {
  ...
} else {
  ...
}

folds like this:

+---  7 lines: if (...) {---

We can make the latter case fold like this:

+---  2 lines: if (...) {---
+---  2 lines: } else if (...) {
+---  3 lines: } else {-

by choosing on each line the lowest fold level that is followed
by a higher fold level.

Please see patch attached.  FWIW I've been running with this patch
for months to test it.

Thanks,
-Brad

-- 
-- 
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.
>From 5f1a9107cf9a9732d7f827cd66928b8565fe6a72 Mon Sep 17 00:00:00 2001
Message-Id: <5f1a9107cf9a9732d7f827cd66928b8565fe6a72.1476457236.git.brad.k...@kitware.com>
From: Brad King 
Date: Wed, 11 May 2016 21:51:34 -0400
Subject: [PATCH] syntax: Improve foldlevel on lines where it changes
 horizontally

With `foldmethod=syntax` the code:

if (...) {
  ...
}
else if (...) {
  ...
}
else {
  ...
}

folds like this:

+---  3 lines: if (...) {---
+---  3 lines: else if (...) {--
+---  3 lines: else {---

However, the code:

if (...) {
  ...
} else if (...) {
  ...
} else {
  ...
}

folds like this:

+---  7 lines: if (...) {---

We can make the latter case fold like this:

+---  2 lines: if (...) {---
+---  2 lines: } else if (...) {
+---  3 lines: } else {-

by choosing on each line the lowest fold level that is followed
by a higher fold level.
---
 src/syntax.c | 33 +
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/src/syntax.c b/src/syntax.c
index 75ede36..c0c87f8 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -6537,6 +6537,17 @@ syn_get_stack_item(int i)
 #endif
 
 #if defined(FEAT_FOLDING) || defined(PROTO)
+static int
+syn_cur_foldlevel(void)
+{
+int		level = 0;
+int		i;
+for (i = 0; i < current_state.ga_len; ++i)
+	if (CUR_STATE(i).si_flags & HL_FOLD)
+	++level;
+return level;
+}
+
 /*
  * Function called to get folding level for line "lnum" in window "wp".
  */
@@ -6544,16 +6555,30 @@ syn_get_stack_item(int i)
 syn_get_foldlevel(win_T *wp, long lnum)
 {
 int		level = 0;
-int		i;
+int		low_level;
+int		cur_level;
 
 /* Return quickly when there are no fold items at all. */
 if (wp->w_s->b_syn_folditems != 0)
 {
 	syntax_start(wp, lnum);
 
-	for (i = 0; i < current_state.ga_len; ++i)
-	if (CUR_STATE(i).si_flags & HL_FOLD)
-		++level;
+	/* Start with the fold level at the start of the line. */
+	cur_level = syn_cur_foldlevel();
+	level = cur_level;
+	low_level = cur_level;
+
+	/* Find the lowest fold level that is followed by a higher one. */
+	while (!current_finished)
+	{
+	(void)syn_current_attr(FALSE, FALSE, NULL, FALSE);
+	cur_level = syn_cur_foldlevel();
+	if (cur_level < low_level)
+		low_level = cur_level;
+	else if (cur_level > low_level)
+		level = low_level;
+	++current_col;
+	}
 }
 if (level > wp->w_p_fdn)
 {
-- 
2.9.3





Re: [vim/vim] E924 error (#1167)

2016-10-14 Fir de Conversatie Christ van Willegen
Op 14 okt. 2016 17:21 schreef "Martin Vuille" :
>
> But I am unsure how to incorporate the files "foo" and "bar" into the
test.

You can write them from the test.

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.


[patch] improve ended-job check

2016-10-14 Fir de Conversatie Ozaki Kiichi
Hi.

Currently, vim checks ended-job every 10 second; thus exit_cb is delayed
10 seconds at the maximum.

I propose the following:

https://gist.github.com/ichizok/fe9743f46822a9015ed2f7d65238c5db

os_unix: check by waitpid(-1, _, WNOHANG).
os_win32: check by WaitForMultipleObjects(),
"the number of active jobs" / MAXIMUM_WAIT_OBJECTS (==64) times.

They suppress the count of calling syscall to be nearly constant regardless
of the number of active jobs.

# I set MAX_ENDED_JOB_COUNT (the maximum number of detections
# in job_check_ended()) to 8, but this may require consideration.

Thank you.
- Ozaki Kiichi

-- 
-- 
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][patch] Doing ":redraw" during external command causes strange screen state

2016-10-14 Fir de Conversatie Ozaki Kiichi
> Isn't this a bit too drastic?  When termcap_active it should still be
> possible to output text (e.g. from another timer command).
> 
> Also check msg_use_printf().  Looks like your change overrules its own
> check for termcap_active.

Hmm, yes. I think we should suppress updating screen while
doing stoptermcap() ~ starttermcap() (i.e termcap_active == FALSE).

Can we check termcap_active only in specific screen-updating functions
(update_screen, or some), or should not do such?

-- 
-- 
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] 2 problems about job

2016-10-14 Fir de Conversatie mattn
Sorry, It was wrong. I updated patch

https://gist.github.com/mattn/d47e7d3bfe5ade4be86062b565a4bfca

On Wednesday, October 12, 2016 at 11:19:06 PM UTC+9, Bram Moolenaar wrote:
> +strsave_for_argv(char_u *string)
> 
> I would call the argument "argv" and the escaped result "argv_escaped".

renamed strsave_for_argv to escape_arg, string to arg, escaped_string to 
arg_escaped.

> 
> + has_spaces = 1;
> 
> Use TRUE and FALSE instead of 1 and 0.

okay, thank you.

 
> + if (*p == '\n')
> + ++length;
> 
> But the "\n" is not escaped, thus this is not needed.

Yes, removed.

> +if (escaped_string == NULL)
> + return escaped_string;
> 
> Can return NULL.

this too.

> + else
> + if (*p == '\\')
> 
> Should be one line.

ditto

> Also, there is no test for a backslash in the text.  It would also need
> to test for two or three backslashes.  And one or two backslashes
> followed by a double quote.
> 
> I would rename "p" to "s" (stands for source).

ditto

> +/* add terminating quote and finish with a NUL */
> +if (has_spaces)
> +{
> + for (i = 0; i < escaping; i++)
> + *d++ = '\\';
> + *d++ = '"';
> +}
> +*d = NUL;
> 
> Adding backslashes before the terminating quote looks strange.  If this
> is correct it should be covered by a test.

Yes, I was confused. Totally, fixed implementation. But terminating quote is 
right. See test code.

> +func s:test_list_args(msg, out)
> 
> Use "cmd" instead of "msg".

fixed too

> +call job_start([s:python, '-c', a:msg], {'callback': 
> {ch,msg->execute('let s:out.=msg."\n"')}})
> 
> Why append the "\n"?

For the separator, but not required at least. Then removed.

> +  call s:test_list_args('print(''hello"world'')', "hello\"world\n")
> 
> This seems wrong.  The argument is hello"world but it results in an
> extra backslash.

Please look carefully. "hello\"world\n"

Double quote in the quote should be escaped with backslash on Vim script as you 
know.

Thanks.
- mattn

-- 
-- 
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.