* Open the current server log file in a new editor.
(client: AngularLanguageClient)
| 53 | * Open the current server log file in a new editor. |
| 54 | */ |
| 55 | function openLogFile(client: AngularLanguageClient): Command { |
| 56 | return { |
| 57 | id: 'angular.openLogFile', |
| 58 | isTextEditorCommand: false, |
| 59 | async execute() { |
| 60 | const serverOptions: ServerOptions | undefined = client.initializeResult?.serverOptions; |
| 61 | if (!serverOptions?.logFile) { |
| 62 | // Show a MessageItem to help users automatically update the |
| 63 | // configuration option then restart the server. |
| 64 | const selection = await vscode.window.showErrorMessage( |
| 65 | `Angular server logging is off. Please set 'angular.log' and restart the server.`, |
| 66 | 'Enable logging and restart server', |
| 67 | ); |
| 68 | if (selection) { |
| 69 | const isGlobalConfig = false; |
| 70 | await vscode.workspace |
| 71 | .getConfiguration() |
| 72 | .update('angular.log', 'verbose', isGlobalConfig); |
| 73 | // Server will automatically restart because the config is changed |
| 74 | } |
| 75 | return; |
| 76 | } |
| 77 | const document = await vscode.workspace.openTextDocument(serverOptions.logFile); |
| 78 | return vscode.window.showTextDocument(document); |
| 79 | }, |
| 80 | }; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Command getTemplateTcb displays a typecheck block for the template a user has |