Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showTextDocument should support to open in the background #11247

Closed
drew-wallace opened this issue Aug 30, 2016 · 15 comments
Closed

showTextDocument should support to open in the background #11247

drew-wallace opened this issue Aug 30, 2016 · 15 comments
Assignees
Labels
api *duplicate Issue identified as a duplicate of another issue(s) feature-request Request for new features or functionality

Comments

@drew-wallace
Copy link

  • 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
@dbaeumer dbaeumer added the api label Aug 30, 2016
@jrieken jrieken added *question Issue represents a question, should be posted to StackOverflow (VS Code) and removed api labels Aug 31, 2016
@jrieken
Copy link
Member

jrieken commented Aug 31, 2016

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 jrieken closed this as completed Aug 31, 2016
@drew-wallace
Copy link
Author

drew-wallace commented Aug 31, 2016

@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.

@jrieken
Copy link
Member

jrieken commented Aug 31, 2016

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

@jrieken jrieken reopened this Aug 31, 2016
@jrieken jrieken added info-needed Issue requires more information from poster and removed *question Issue represents a question, should be posted to StackOverflow (VS Code) labels Aug 31, 2016
@drew-wallace
Copy link
Author

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

@jrieken
Copy link
Member

jrieken commented Aug 31, 2016

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

@drew-wallace
Copy link
Author

@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;

@jrieken
Copy link
Member

jrieken commented Aug 31, 2016

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'?

@drew-wallace
Copy link
Author

@jrieken Yes

@jrieken
Copy link
Member

jrieken commented Aug 31, 2016

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

@jrieken jrieken added feature-request Request for new features or functionality and removed info-needed Issue requires more information from poster labels Aug 31, 2016
@jrieken jrieken changed the title preserveFocus argument isn't being observed in showTextDocument showTextDocument should support to open in the background Aug 31, 2016
@jrieken
Copy link
Member

jrieken commented Aug 31, 2016

@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?

@bpasero
Copy link
Member

bpasero commented Aug 31, 2016

@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).

@drew-wallace
Copy link
Author

drew-wallace commented Aug 31, 2016

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

@shanalikhan
Copy link

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 !

@miyoosan
Copy link

yes

@jrieken
Copy link
Member

jrieken commented May 28, 2017

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

@jrieken jrieken added the *duplicate Issue identified as a duplicate of another issue(s) label May 28, 2017
@jrieken jrieken closed this as completed May 28, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api *duplicate Issue identified as a duplicate of another issue(s) feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

6 participants