【问题标题】:How to disable switching to explorer activity bar when call openTextDocument? VScode调用openTextDocument时如何禁用切换到资源管理器活动栏?代码
【发布时间】:2019-07-12 11:03:16
【问题描述】:

我正在为 vscode 创建一个扩展。在某些时候,我需要打开一个文件。我为此使用vscode.workspace.openTextDocument,它正在工作,但是将活动栏从自定义切换到资源管理器。我想打开我的自定义活动栏。我该怎么做?

我尝试关闭除我之外的所有活动栏,搜索一些设置(未找到),尝试使用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;
    }); 
}

我希望我的自定义活动栏和必要的文件将在运行选择后打开。现在文件已打开,但活动栏已切换到资源管理器。

【问题讨论】:

    标签: javascript typescript visual-studio-code vscode-extensions


    【解决方案1】:

    不知道问题究竟是如何解决的,但现在它可以正常工作了。

    我可以假设,这里的关键是另一个插件(我们称之为 plugin_2 和 main - plugin_1)。我有另一个插件(plugin_2),它在某些文件打开时运行并将一些结果绘制到轮廓中,所以很可能,当我从资源管理器将plugin_2重新定位到我的自定义活动栏中,并使用主plugin_1打开一个文件时,plugin_2运行并没有让资源管理器打开。

    我相信这是决定。希望它会帮助某人。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-20
      • 1970-01-01
      • 2021-12-30
      • 2021-05-13
      相关资源
      最近更新 更多