-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use job for s:system() on vim8 #594
base: master
Are you sure you want to change the base?
Conversation
Thanks, it looks interesting. But there are places we refer to e.g. Also I wonder why bumping up |
I will add code for |
I think we should stop using |
yes, we have better to separate |
added |
@@ -1979,34 +1982,70 @@ endfunction | |||
|
|||
function! s:system(cmd, ...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s:system
can be simplified to s:system_with_error(...)[0]
.
plug.vim
Outdated
\ a:spec.branch), a:spec.dir)), '\t') | ||
if !v:shell_error && ahead | ||
\ a:spec.branch), a:spec.dir) | ||
let [ahead, behind] = split(s:lastline(output), '\t') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this can fail if output
does not have \t
because of an error, right? It was my oversight.
plug.vim
Outdated
@@ -1053,14 +1053,16 @@ function! s:update_finish() | |||
if !pos | |||
continue | |||
endif | |||
let shellerror = 0 | |||
if has_key(spec, 'commit') | |||
call s:log4(name, 'Checking out '.spec.commit) | |||
let out = s:checkout(spec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s:checkout
can fail. It used to set v:shell_error
which is tested at line 1079, but now we have to update shellerror
. The same goes for line 1072 and 1076.
plug.vim
Outdated
\ a:spec.branch), a:spec.dir) | ||
let [ahead; behind] = split(s:lastline(output), '\t') | ||
if !shellerror && ahead | ||
if len(behind) > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
behind
is a list, so line 2060 should be updated accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want the behind is joined with " "
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original code expected exactly two numbers, which is a correct assumption given that git rev-list --count --left-right HEAD...origin/master
works as expected. I think behind[0]
should suffice. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your's is best. will fix soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should test len(behind) == 1
instead?
EDIT: 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
b3e794b
to
352cc75
Compare
plug.vim
Outdated
if !shellerror && ahead | ||
if behind | ||
if len(behind) == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, one more thing, I think we should change these lines to
if !shellerror && ahead && len(behind) == 1
if behind[0]
352cc75
to
5e5bfac
Compare
plug.vim
Outdated
if !shellerror && ahead | ||
if behind | ||
if !shellerror && ahead && len(behind) == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry if I wasn't being clear. What I meant is to change line 2054 and 2055 as follows:
if !shellerror && ahead && len(behind) == 1
if behind[0]
- First if statement checks if the output of the command conforms to the expected format
- Second if statement checks if
behind[0]
is a non-zero value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No prob
5e5bfac
to
7dd874e
Compare
A few test cases are still failing on Vim 8: https://s3.amazonaws.com/archive.travis-ci.org/jobs/204097914/log.txt Looks like the lines in the output of the new system function are not properly separated by newline characters (
|
Sorry, It's difficult to read the test result for me. |
I'll look into those errors when I get some time. By the way, I tested the patched version on my machine.
|
Vim dispose jobs in main thread. So vim stop job operations while calling system(). This use job in s:system().
Left is without this patch. Right is with this patch.