简体   繁体   English

调用openTextDocument时如何禁用切换到资源管理器活动栏? VScode

[英]How to disable switching to explorer activity bar when call openTextDocument? VScode

I'm creating an extension for vscode. 我正在为vscode创建扩展。 At some point I need to open a file. 在某个时候,我需要打开一个文件。 I use vscode.workspace.openTextDocument for that and it's working, but switchs activity bar from custom to Explorer. vscode.workspace.openTextDocument使用vscode.workspace.openTextDocument ,它正在工作,但是将活动栏从定制切换到资源管理器。 I want to leave my custom activity bar opened. 我想打开自定义活动栏。 How can I do that? 我怎样才能做到这一点?

I have tried closing all activity bars except mine, searching for some settings(nothing found), tried to use vscode.commands.executeCommand with workbench.view , but there are only workbenck.view.explorer and workbench.view.extensions . 我尝试关闭除我的以外的所有活动栏,搜索一些设置(未找到任何内容),尝试将vscode.commands.executeCommandworkbench.view一起使用,但是只有workbenck.view.explorerworkbench.view.extensions

select(node: json.Node) {
    var setting: vscode.Uri = vscode.Uri.parse('file:///home/user/some_file');
    vscode.workspace.openTextDocument(setting).then((a: vscode.TextDocument) => {
        vscode.window.showTextDocument(a, 1, false).then(e => {
            // move to 96 line in the file. Just for example.
            let range_n = e.document.lineAt(96).range;
            e.selection =  new vscode.Selection(range_n.start, range_n.end);
            e.revealRange(range_n);
        })
    }, (error: any) => {
        console.error(error);
        debugger;
    }); 
}

I expect that my custom activity bar and necessary file will be open after running select. 我希望我的自定义活动栏和必要的文件将在运行select之后打开。 Now file is opened, but activity bar is switched to explorer. 现在,文件已打开,但活动栏已切换到资源管理器。

Have no idea, how exactly the problem was solved, but now it works as it should be. 完全不知道解决问题的方式,但是现在它可以正常工作了。

I can assume, that the key here is another plugin (let's call it plugin_2, and main - plugin_1). 我可以假设,这里的键是另一个插件(我们称其为plugin_2,主叫-plugin_1)。 I have another plugin (plugin_2), which runs when some file opens and draw some result into outline, so probably, when I relocate plugin_2 into my custom activity bar from explorer, and open a file with main plugin_1, plugin_2 ran and didn't let explorer open. 我还有另一个插件(plugin_2),它在打开某些文件并将某些结果绘制到轮廓时运行,因此,大概是在我将插件_2从资源管理器中移至我的自定义活动栏中,并使用主插件_1打开文件时,插件_2运行了,但没有打开资源管理器。

I believe that is the decision. 我相信那是决定。 Hope it will help someone. 希望它会帮助某人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM