Skip to content

"A request has failed. See the output for more information." dialog always shows output channel, even when being dismissed #786

Closed
@perrinjerome

Description

@perrinjerome

When a request fail, typically because of an error on the language server side, client shows a popup offering to go to output channel to see the error:

image

Problem is when user close the dialog, this open the output channel anyway.


I prepared a reproduction if necessary:

diff --git a/lsp-embedded-language-service/server/src/server.ts b/lsp-embedded-language-service/server/src/server.ts
index 4093561..d9805d4 100644
--- a/lsp-embedded-language-service/server/src/server.ts
+++ b/lsp-embedded-language-service/server/src/server.ts
@@ -85,18 +85,7 @@ async function validateTextDocument(textDocument: TextDocument) {
 }
 
 connection.onCompletion(async (textDocumentPosition, token) => {
-	const document = documents.get(textDocumentPosition.textDocument.uri);
-	if (!document) {
-		return null;
-	}
-
-	const mode = languageModes.getModeAtPosition(document, textDocumentPosition.position);
-	if (!mode || !mode.doComplete) {
-		return CompletionList.create();
-	}
-	const doComplete = mode.doComplete!;
-
-	return doComplete(document, textDocumentPosition.position);
+	throw new Error("💥");
 });
 
 // Make the text document manager listen on the connection
  • build the extension and debug it
  • change file type to html1 (this is what this extension sample uses)
  • trigger a completion
  • the "A request has failed. See the output for more information." dialog popup
  • close the dialog

Expected behaviour:

The Output channel is not opened, focus remain on the current editor pane

Actual behaviour:

The Output channel is opened

Screen.Recording.2021-07-10.at.14.52.38.mov

I believe the problems is here :

private showNotificationMessage() {
void Window.showInformationMessage('A request has failed. See the output for more information.', 'Go to output').then(() => {
this.outputChannel.show(true);
});
}

as we can see in vscode API ( https://code.visualstudio.com/api/references/vscode-api#window.showInformationMessage ) this returns a thenable that resolves to the selected item or undefined when being dismissed.

I believe in case the returned value is undefined the output channel should not be revealed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions