-
Notifications
You must be signed in to change notification settings - Fork 64
Added System.AsyncProcess. #838
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
base: master
Are you sure you want to change the base?
Conversation
c2bdd67 to
da0b2af
Compare
0556520 to
e165c1d
Compare
|
draft 時は1コミットずつテストOKしないとだめだった、たぶん今は平気 だめだった……再度実行はしました |
| " v8.2.238 or earlier, job_stop() exit status is 0. | ||
| " See: https://github.com/vim/vim/commit/b3e195cca7b3201b188c1713b64012b1bef4f61f | ||
| if v:version == 802 && !has('patch238') || v:version < 802 | ||
| Assert True(g:exit_code == 0) | ||
| else | ||
| Assert True(g:exit_code != 0) | ||
| endif |
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.
えっと、パッチされたのは Windows だけな気がするので、Windowsとそれ以外では違う処理にしないとではないかと
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.
ご指摘の通り...
コミット 1e9054b で修正しました。
|
別PRでサポートバージョンの変更をやってたのを忘れていました。 |
|
一応多めにレビュアー設定しましたが、+1名くらいレビューしてくださって、マージしていただければ、かなと。 |
tsuyoshicho
left a comment
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.
一度いいかなと思いましたが、再レビューしてコメントします。
https://github.com/tsuyoshicho/vital.vim/blob/master/autoload/vital/__vital__/Bitwise.vim
とかも参考になるかもです
すくなくとも、露出するIFの制御はしないとまずそうです
| if s:is_windows | ||
| " iconv() wrapper for safety. | ||
| function! s:iconv(expr, from, to) abort |
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.
-
処理重複
https://github.com/tsuyoshicho/vital.vim/blob/master/autoload/vital/__vital__/Process.vim
との処理重複がありそう
モジュールに depend して、s:iconv を使うでいいかもしれない -
呼び出しの正規化
処理に都度 if s:is_windows 書くのであれば、 s:_ensure_buffer_string を if s:is_windows else 両方で定義して、無条件呼び出しでいいかもしれない
非 Windows はそのまま返す関数で -
内部関数
s:hoge と関数を定義すると、モジュールの公開IFになるので、 s:_hoge として陰蔽したほうがいいのでは
(変数は平気)
モジュールの依存は
参考
vital.vim/autoload/vital/__vital__/System/Process.vim
Lines 7 to 22 in a93f5d3
| function! s:_vital_loaded(V) abort | |
| let s:V = a:V | |
| let s:Prelude = a:V.import('Prelude') | |
| let s:String = a:V.import('Data.String') | |
| call s:register('System.Process.Vimproc') | |
| call s:register('System.Process.System') | |
| endfunction | |
| function! s:_vital_depends() abort | |
| return [ | |
| \ 'Prelude', | |
| \ 'Data.String', | |
| \ 'System.Process.System', | |
| \ 'System.Process.Vimproc', | |
| \] | |
| endfunction |
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.
👍 > review comments
(とくに3、お願いします!)
| if !s:is_nvim | ||
| " inner callbacks for Vim | ||
| function! s:inner_out_cb(user_out_cb, ch, msg) abort | ||
| let result = a:msg | ||
| if s:is_windows | ||
| let result = s:iconv(a:msg, 'char', &encoding) | ||
| endif | ||
|
|
||
| call a:user_out_cb(result) | ||
| endfunction | ||
|
|
||
| function! s:inner_exit_cb(user_exit_cb, job, exit_code) abort | ||
| call a:user_exit_cb(a:exit_code) | ||
| endfunction | ||
|
|
||
| function! s:inner_err_cb(user_err_cb, ch, msg) abort | ||
| let result = a:msg | ||
| if s:is_windows | ||
| let result = s:iconv(a:msg, 'char', &encoding) | ||
| endif | ||
|
|
||
| call a:user_err_cb(result) | ||
| endfunction | ||
| else | ||
| " inner callbacks for Neovim | ||
| function! s:inner_out_cb(user_out_cb, job_id, data, event) abort | ||
| for line in a:data | ||
| if line !=# '' | ||
| call a:user_out_cb(line) | ||
| endif | ||
| endfor | ||
| endfunction | ||
|
|
||
| function! s:inner_exit_cb(user_exit_cb, job_id, exit_code, event) abort | ||
| call a:user_exit_cb(a:exit_code) | ||
| endfunction | ||
|
|
||
| function! s:inner_err_cb(user_err_cb, job_id, data, event) abort | ||
| for line in a:data | ||
| if line !=# '' | ||
| call a:user_err_cb(line) | ||
| endif | ||
| endfor | ||
| endfunction | ||
| endif |
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.
ここらへん、見える必要ないはずなので、これも陰蔽で
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.
内部関数の名前を変更しました。
commit: ea7cad9
| if s:is_windows | ||
| let args = args + ['/c'] | ||
| else | ||
| let args = args + ['-c'] | ||
| endif |
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.
どちらかというと、シェル、そしてさらにOSとの組み合せで決りそうですが、大丈夫そう?
Linuxで pwsh とか
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.
ただ無理はしなくていいので、とりあえずいい感じの初期値でいいかとは思います。
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.
指摘の通りです。
cmd.exe が /c で、それ以外が -c となるように修正しました。
Commit: 7a6ce6d
| let args = args + [command] | ||
|
|
||
| let job_id = -1 | ||
| if s:is_nvim |
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.
いまはしなくていいですが、vim/nvimでサブモジュール相当(内部クラス分けでもいいかもですが)
していいくらいに、記述が共通じゃなく、分けて書いたほうが管理がよいかも
| let options = {} | ||
| let options['out_cb'] = function('s:inner_out_cb', [a:options.out_cb]) | ||
| let options['err_cb'] = function('s:inner_err_cb', [a:options.err_cb]) | ||
| let options['exit_cb'] = function('s:inner_exit_cb', [a:options.exit_cb]) |
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.
他もですが、まとめて辞書定義してもいいのではないかと
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.
辞書定義をまとめて行うように修正しました。
commit: 3ff69df
|
偉業 |
|
レビュー、コメント、ありがとうございます。 |
tsuyoshicho
left a comment
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.
L, G, T, M!!
#836 の実装を行っています。
現時点でツッコミどころなど、指摘いただけると幸いです。
TODO:
-cor pwsh or powershell :-Cor cmd.exe :/c)