Vscode: showTextDocument should support to open in the background

Created on 30 Aug 2016  路  15Comments  路  Source: microsoft/vscode

  • VSCode Version: 1.4.0
  • OS Version: OSX 10.11.6

Steps to Reproduce:

  1. Open a document with openTextDocument
  2. Then show the resulting document with the preserveFocus argument set to true showTextDocument(TextDocument, vscode.ViewColumn.One, true)
  3. A new editor opens and still gains focus
*duplicate api editor feature-request

Most helpful comment

I am also waiting for this feature as i want to open the summary page to open in the background so user who is working on other tab should not get disturbed and through API i can add text on that other tab in the background.

When user switch to that api he should see the extension summary.

Extension - code-settings-sync !

All 15 comments

preserveFocus means that the new editor does not take the _current_ focus away (for instance it stays in the 2nd editor or the debug repl etc)

@jrieken I believe we're saying the same thing. Let's say the focus was on editor A. Then I execute a command that opens a document and shows that document in a new editor B with preserveFocus set to true. Shouldn't editor B open but editor A still have focus? If true, then I'm not seeing that behavior, which leads me to believe preserveFocus isn't being observed.

Yeah - seems like it. Tho, I cannot reproduce what you are saying

   let disposable = vscode.commands.registerCommand('extension.sayHello', () => {

        if (vscode.window.activeTextEditor) {
            vscode.window.showTextDocument(vscode.window.activeTextEditor.document, vscode.ViewColumn.Two, true);
        }

    });

aug-31-2016 14-12-43

Try a file that's not opened in any other editor and show it in the same view column.

Try a file that's not opened in any other editor and show it in the same view column.

Is that just a guess because also that works for me? Please provide reproduce steps that allow me to reproduce this

@jrieken

  • Open a folder
  • Open a file in that folder as the active editor
  • Run the sayHello command from the code below (make sure to change the path in the code below to a file in that folder)
  • The newly opened editor takes focus and covers the previously active editor
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
var vscode = require('vscode');

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
function activate(context) {

    // Use the console to output diagnostic information (console.log) and errors (console.error)
    // This line of code will only be executed once when your extension is activated
    console.log('Congratulations, your extension "test-extension" is now active!');

    // The command has been defined in the package.json file
    // Now provide the implementation of the command with  registerCommand
    // The commandId parameter must match the command field in package.json
    var disposable = vscode.commands.registerCommand('extension.sayHello', function () {
        // The code you place here will be executed every time your command is executed

        vscode.workspace.openTextDocument('/full/path/to/file.js').then(function(TextDocument){
            vscode.window.showTextDocument(TextDocument, vscode.ViewColumn.One, true);
        });
    });

    context.subscriptions.push(disposable);
}
exports.activate = activate;

// this method is called when your extension is deactivated
function deactivate() {
}
exports.deactivate = deactivate;

Open a file in that folder as the active editor

You mean 'Open a file in that folder as the active editor _in ViewColumn.One_'?

@jrieken Yes

Ok. What you want is to open an editor in the background for which we currently don't have support

@bpasero Do we have support for the in the underlying API and how would/should it work in noTab mode? You wouldn't see the new editor unless you keep an eye on the open editors section in the explorer, right?

@jrieken that is right, for this behaviour it does not make a difference if you see tabs or not in the main editor area because you could be using the "open editors" view and will notice there how an editor opens "in the background".

Since you have tabs disabled, in this case you would need to close the top most editor until you reach the one that was opened in the background (in the same way as you do when you have tabs enabled).

I'm making a remote pair programming extension and want to allow a remote user to open a file and edit it without interrupting the local user.

Here is the extension I'm using as a base: Motepair
Here is my extension's repo: vscode-motepair

I am also waiting for this feature as i want to open the summary page to open in the background so user who is working on other tab should not get disturbed and through API i can add text on that other tab in the background.

When user switch to that api he should see the extension summary.

Extension - code-settings-sync !

yes

The problem with this is that opening an editor in the background doesn't make an editor in the editor. Only documents that are current shown in an editor-widget are an editor in the API. So, when calling showTextDocument with some background-parameter will not return an editor instance but undefined. I'd say that is a little fuzzy and maybe this is the same feature request as exposing the tab model, because that's what this is, adding another tab (entry in the list of open editors).

Closing this as dupe of #15178 which is about exposing the tab-model

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shanalikhan picture shanalikhan  路  3Comments

VitorLuizC picture VitorLuizC  路  3Comments

villiv picture villiv  路  3Comments

philipgiuliani picture philipgiuliani  路  3Comments

trstringer picture trstringer  路  3Comments