Skip to content

Commit 599dd08

Browse files
committed
Move restart command into extension.ts
It's a bit hairy passing about a map
1 parent 3ccfd01 commit 599dd08

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

src/commands/restartHie.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/extension.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
'use strict';
22
import * as os from 'os';
33
import * as path from 'path';
4-
import { ExtensionContext, OutputChannel, TextDocument, Uri, window, workspace, WorkspaceFolder } from 'vscode';
4+
import {
5+
commands,
6+
ExtensionContext,
7+
OutputChannel,
8+
TextDocument,
9+
Uri,
10+
window,
11+
workspace,
12+
WorkspaceFolder,
13+
} from 'vscode';
514
import {
615
ExecutableOptions,
716
LanguageClient,
@@ -10,8 +19,8 @@ import {
1019
ServerOptions,
1120
TransportKind,
1221
} from 'vscode-languageclient';
22+
import { CommandNames } from './commands/constants';
1323
import { ImportIdentifier } from './commands/importIdentifier';
14-
import { RestartHie } from './commands/restartHie';
1524
import { DocsBrowser } from './docsBrowser';
1625
import { downloadServer } from './hlsBinaries';
1726
import { executableExists } from './utils';
@@ -38,7 +47,14 @@ export async function activate(context: ExtensionContext) {
3847
});
3948

4049
// Register editor commands for HIE, but only register the commands once at activation.
41-
context.subscriptions.push(RestartHie.registerCommand(clients));
50+
const restartCmd = commands.registerCommand(CommandNames.RestartHieCommandName, async () => {
51+
for (const langClient of clients.values()) {
52+
await langClient.stop();
53+
langClient.start();
54+
}
55+
});
56+
context.subscriptions.push(restartCmd);
57+
4258
context.subscriptions.push(ImportIdentifier.registerCommand());
4359

4460
// Set up the documentation browser.
@@ -220,6 +236,8 @@ async function activateHieNoCheck(context: ExtensionContext, uri: Uri, folder?:
220236
langClient.start();
221237
if (folder) {
222238
clients.set(folder.uri.toString(), langClient);
239+
} else {
240+
clients.set(uri.toString(), langClient);
223241
}
224242
}
225243

0 commit comments

Comments
 (0)