|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information. |
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
| 6 | +import * as vscode from 'vscode'; |
6 | 7 | import { CancellationToken, MessageSignature } from 'vscode-jsonrpc'; |
7 | | -import { LanguageClient } from 'vscode-languageclient/node'; |
8 | | -import { LanguageClientOptions, ServerOptions } from 'vscode-languageclient'; |
| 8 | +import { LanguageClient, ServerOptions } from 'vscode-languageclient/node'; |
| 9 | +import { LanguageClientOptions } from 'vscode-languageclient'; |
9 | 10 | import CompositeDisposable from '../../compositeDisposable'; |
10 | 11 | import { IDisposable } from '../../disposable'; |
11 | 12 | import { languageServerOptions } from '../../shared/options'; |
12 | 13 | import { RoslynLspErrorCodes } from './roslynProtocol'; |
| 14 | +import { showErrorMessageWithOptions } from '../../shared/observers/utils/showMessage'; |
13 | 15 |
|
14 | 16 | /** |
15 | 17 | * Implementation of the base LanguageClient type that allows for additional items to be disposed of |
@@ -57,7 +59,32 @@ export class RoslynLanguageClient extends LanguageClient { |
57 | 59 | if (languageServerOptions.suppressLspErrorToasts) { |
58 | 60 | return super.handleFailedRequest(type, token, error, defaultValue, false); |
59 | 61 | } |
60 | | - return super.handleFailedRequest(type, token, error, defaultValue, showNotification); |
| 62 | + // test. |
| 63 | + // todo - we need to somehow prevent this from showing toasts for errors when the server crashes, since we already get them below too. |
| 64 | + return super.handleFailedRequest(type, token, error, defaultValue, false); |
| 65 | + } |
| 66 | + |
| 67 | + override error(message: string, data?: any, showNotification?: boolean | 'force'): void { |
| 68 | + // Show custom error toast with report issue command button, the base does not include this. |
| 69 | + // Here we only show toasts for critical errors (when showNotification is 'force'). |
| 70 | + |
| 71 | + // todo - this needs to de-duplicate errors. on crashes we can get multiple errors (slightly diff messages, esp if stopping the server failed). |
| 72 | + // @ts-expect-error dddddd |
| 73 | + const s = this.state; |
| 74 | + if (showNotification === 'force') { |
| 75 | + showErrorMessageWithOptions( |
| 76 | + vscode, |
| 77 | + message, |
| 78 | + { modal: false }, |
| 79 | + { |
| 80 | + title: 'Report Issue', |
| 81 | + command: 'csharp.reportIssue', |
| 82 | + } |
| 83 | + ); |
| 84 | + showNotification = false; // prevent the base class from showing another toast with the same message. |
| 85 | + } |
| 86 | + |
| 87 | + super.error(message, data, showNotification); |
61 | 88 | } |
62 | 89 |
|
63 | 90 | /** |
|
0 commit comments