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

vscode.previewHtml command failing - promise not resolving if preview tab exists in Insiders build #19654

Closed
kevcunnane opened this issue Feb 1, 2017 · 1 comment
Assignees
Labels
invalid Issue identified as not relevant or not valid

Comments

@kevcunnane
Copy link

kevcunnane commented Feb 1, 2017

  • VSCode Version: 1.9.0 Insiders
  • OS Version: Mac OS and Windows OS

Steps to Reproduce:
This is breaking our MSSQL extension - we repeatedly call the vscode.previewHtml method when executing SQL queries, as it updates the results viewer with the latest results. It was working until the most recent Insiders build at which time it stopped resolving the promise and letting us hook in our code to update the result after it's been made visible and focused. Specific steps:

  1. Write an extension that uses vscode.previewHtml, e.g.
if (this.doesResultPaneExist(resultsUri)) {
    // this is called for the 2nd call and all subsequent calls
    // Implicity Use existing results window by not providing a pane
    previewCommandPromise = vscode.commands.executeCommand('vscode.previewHtml', resultsUri, paneTitle);
} else {
    // This is called for the very first call
    resultPaneColumn = this.newResultPaneViewColumn();
    previewCommandPromise = vscode.commands.executeCommand('vscode.previewHtml', resultsUri, resultPaneColumn, paneTitle);
}

previewCommandPromise.then(() => {
    console.log('preview promise returned successfully');
});
  1. Execute this logic more than once

Expected:

  • Each time the command is called, the .then logic gets executed and message is logged to the console

Actual:

  • The .then logic is only called the first time. For all calls when the preview tab is open, no callback happens which means logic meant to happen after it becomes visible is not called. In our case, this means we never update results which blocks our main scenario
@jrieken
Copy link
Member

jrieken commented Feb 1, 2017

The problem here is that subsequent calls go like this: vscode.commands.executeCommand('vscode.previewHtml', resultsUri, paneTitle); and that the last argument is a string whereas it must be a ViewColumn or undefined.

The promise correctly resolves with an argument validation error. Change the code to

 previewCommandPromise.then(() => {
   console.log('preview promise returned successfully');
 }, err => {
   console.log(err);
});

and see this message bring printed to the console: Running the contributed command:'vscode.previewHtml' failed. Illegal argument 'column' - (optional) Column in which to preview.

The argument definition and constraints have not changed in the last 4 months, therefore closing as invalid.

@jrieken jrieken closed this as completed Feb 1, 2017
@jrieken jrieken added invalid Issue identified as not relevant or not valid and removed important Issue identified as high-priority labels Feb 1, 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
invalid Issue identified as not relevant or not valid
Projects
None yet
Development

No branches or pull requests

3 participants