2017-05-22 56 views
0

作为同一操作的一部分,从扩展中打开文件夹和文件的正确方法是什么?VSCode:从同一例程中打开文件夹和文件

看起来像一个简单的任务,但我花了相当一段时间,无法解决它。 我可以很容易地做一个或另一个,但不能作为一个单一的操作。

​​

上面的代码打开一个文件夹而不是文件。从调试器中,我看到vscode.open命令被触发但文件未打开。如果'vscode.open`只按预期打开文件。

似乎打开文件夹后,整个执行环境消失了。

我做这种残酷的实验:

setTimeout(() => commands.executeCommand('vscode.open', 
              Uri.file('E:\\dev\\files\\file.json'), 3000); 
commands.executeCommand('vscode.openFolder', 
         Uri.parse('E:\\dev\\proj')) 

它的唾骂,如果在调用vscode.openFolder的setTimeout的回调不会被调用。

将感谢任何帮助/提示。

回答

0

我找到了问题的原因。但不是解决方案。

显然打开的文件夹完全终止执行上下文。这是VSCode文件说什么:

Note that opening in the same window will shutdown the current extension host process and start a new one on the given folder unless the newWindow parameter is set to true.

因此目前似乎没有在当前窗口打开与打开和积极的特定文件夹的方式。

相关问题