Skip to content

Conversation

@mikoto2000
Copy link
Contributor

@mikoto2000 mikoto2000 commented Nov 25, 2025

#836 の実装を行っています。
現時点でツッコミどころなど、指摘いただけると幸いです。

TODO:

  • : Neovim 対応
  • : OS でなく、 shell の種類でオプションを分ける(linux shell : -c or pwsh or powershell : -C or cmd.exe : /c)
  • : Windows での文字化け対応
  • : doc

@mikoto2000 mikoto2000 marked this pull request as ready for review November 30, 2025 02:49
@mikoto2000 mikoto2000 changed the title WIP: Added System.AsyncProcess. Added System.AsyncProcess. Dec 1, 2025
@tsuyoshicho
Copy link
Contributor

tsuyoshicho commented Dec 1, 2025

draft 時は1コミットずつテストOKしないとだめだった、たぶん今は平気

だめだった……再度実行はしました

Comment on lines 101 to 107
" 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

えっと、パッチされたのは Windows だけな気がするので、Windowsとそれ以外では違う処理にしないとではないかと

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ご指摘の通り...
コミット 1e9054b で修正しました。

@tsuyoshicho
Copy link
Contributor

別PRでサポートバージョンの変更をやってたのを忘れていました。
マージされた場合、テストでケアしていた箇所は不要になるかもしれません。

@tsuyoshicho
Copy link
Contributor

一応多めにレビュアー設定しましたが、+1名くらいレビューしてくださって、マージしていただければ、かなと。

Copy link
Contributor

@tsuyoshicho tsuyoshicho left a 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の制御はしないとまずそうです

Comment on lines 11 to 13
if s:is_windows
" iconv() wrapper for safety.
function! s:iconv(expr, from, to) abort
Copy link
Contributor

@tsuyoshicho tsuyoshicho Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 処理重複
    https://github.com/tsuyoshicho/vital.vim/blob/master/autoload/vital/__vital__/Process.vim
    との処理重複がありそう
    モジュールに depend して、s:iconv を使うでいいかもしれない

  2. 呼び出しの正規化
    処理に都度 if s:is_windows 書くのであれば、 s:_ensure_buffer_string を if s:is_windows else 両方で定義して、無条件呼び出しでいいかもしれない
    非 Windows はそのまま返す関数で

  3. 内部関数
    s:hoge と関数を定義すると、モジュールの公開IFになるので、 s:_hoge として陰蔽したほうがいいのでは
    (変数は平気)

モジュールの依存は
参考

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 > review comments

(とくに3、お願いします!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. コミット: 11011f7 and 65ee768 で修正しました
  2. コミット: 54ff73b and 65ee768 で修正しました
  3. コミット: ea7cad9 で修正しました

Comment on lines 22 to 66
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここらへん、見える必要ないはずなので、これも陰蔽で

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

内部関数の名前を変更しました。
commit: ea7cad9

Comment on lines 92 to 96
if s:is_windows
let args = args + ['/c']
else
let args = args + ['-c']
endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

どちらかというと、シェル、そしてさらにOSとの組み合せで決りそうですが、大丈夫そう?

Linuxで pwsh とか

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ただ無理はしなくていいので、とりあえずいい感じの初期値でいいかとは思います。

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

いまはしなくていいですが、vim/nvimでサブモジュール相当(内部クラス分けでもいいかもですが)

していいくらいに、記述が共通じゃなく、分けて書いたほうが管理がよいかも

Comment on lines 118 to 121
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])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

他もですが、まとめて辞書定義してもいいのではないかと

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

辞書定義をまとめて行うように修正しました。
commit: 3ff69df

@ujihisa
Copy link
Member

ujihisa commented Dec 8, 2025

偉業

@mikoto2000
Copy link
Contributor Author

レビュー、コメント、ありがとうございます。
一通り直したと思いますので、ご確認をお願いいたします。

Copy link
Contributor

@tsuyoshicho tsuyoshicho left a 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!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants