2017-03-09 9 views
0

workspace.onWillSaveTextDocumentハンドラでコールバックを実行しています。それはvscode.TextDocumentを提供し、これは私がこのイベントでしたい仕事に必要です。vscode - 手動でイベントをトリガする方法はありますか?

特定のケースでは、保存されたばかりの(開いていない)他のファイルも同様に扱いたいと思います。

vscode.TextDocumentの新しいインスタンスを作成できることは十分ですが、それを把握することはできませんでした。

workspace.pretendThisWasSavedJustNow('/path/to/other/file.ts'); 

答えて

1

は私がVSCode上で動作し、私はあなたの正確なユースケースを知らないが、私はあなたがworkspace.openTextDocumentを探していると信じて:

のような何かをする方法はあります。

ような何かしようと、workspace.onWillSaveTextDocumentのために、あなたの拡張トリガいくつかの他のイベントで同じ機能を使用するには:

// Actual save 
workspace.onWillSaveTextDocument(e => onDocumentSave(e.document)) 

// Emulated save 
setInterval(() => { 
    workspace.openTextDocument('path/to/other/file.ts') 
     .then(document => onDocumentSave(document)) 
}, 5000) 

// Common save handling implementation 
function onDocumentSave(document: TextDocument) { ... } 
関連する問題