Skip to content

Commit

Permalink
moves client disposal into deactivate method (#891)
Browse files Browse the repository at this point in the history
* moves client disposal into deactivate method

Signed-off-by: Lukas Bockstaller <[email protected]>

* increment extension version

Signed-off-by: Lukas Bockstaller <[email protected]>

---------

Signed-off-by: Lukas Bockstaller <[email protected]>
Co-authored-by: Zabil Cheriya Maliackal <[email protected]>
  • Loading branch information
bockstaller and zabil authored Oct 31, 2023
1 parent 0c88370 commit 2a02753
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"description": "Gauge support for VScode.",
"author": "ThoughtWorks",
"license": "MIT",
"version": "0.1.0",
"version": "0.1.1",
"publisher": "getgauge",
"engines": {
"vscode": "^1.83.1"
Expand Down
17 changes: 13 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ import { ProjectInitializer } from './init/projectInit';
import { ProjectFactory } from './project/projectFactory';
import { hasActiveGaugeDocument } from './util';
import { showInstallGaugeNotification, showWelcomeNotification } from './welcomeNotifications';
import { GaugeClients as GaugeProjectClientMap } from './gaugeClients';

const MINIMUM_SUPPORTED_GAUGE_VERSION = '0.9.6';

const clientsMap: GaugeProjectClientMap = new GaugeProjectClientMap();

export async function activate(context: ExtensionContext) {
let cli = CLI.instance();
if (!cli) {
Expand All @@ -28,10 +31,7 @@ export async function activate(context: ExtensionContext) {
}
showWelcomeNotification(context);
languages.setLanguageConfiguration('gauge', { wordPattern: /^(?:[*])([^*].*)$/g });

let gaugeWorkspace = new GaugeWorkspace(new GaugeState(context), cli);

let clientsMap = gaugeWorkspace.getClientsMap();
let gaugeWorkspace = new GaugeWorkspace(new GaugeState(context), cli, clientsMap);

context.subscriptions.push(
gaugeWorkspace,
Expand All @@ -46,3 +46,12 @@ export async function activate(context: ExtensionContext) {
})
);
}

export function deactivate(): Thenable<void> {
const promises: Thenable<void>[] = [];

for (const {client} of clientsMap.values()) {
promises.push(client.stop());
}
return Promise.all(promises).then(() => undefined);
}
17 changes: 6 additions & 11 deletions src/gaugeWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ const REFERENCE_CONFIG = 'reference';
export class GaugeWorkspace extends Disposable {
private readonly _fileProvider: SpecificationProvider;
private _executor: GaugeExecutor;
private _clientsMap: GaugeProjectClientMap = new GaugeProjectClientMap();
private _clientsMap: GaugeProjectClientMap;
private _clientLanguageMap: Map<string, string> = new Map();
private _outputChannel: OutputChannel = window.createOutputChannel('gauge');
private _launchConfig: WorkspaceConfiguration;
private _codeLensConfig: WorkspaceConfiguration;
private _disposable: Disposable;
private _specNodeProvider: SpecNodeProvider;
constructor(private state: GaugeState, private cli: CLI) {

constructor(private state: GaugeState, private cli: CLI, clientsMap: GaugeProjectClientMap) {
super(() => this.dispose());

this._clientsMap = clientsMap
this._executor = new GaugeExecutor(this, cli);

if (workspace.workspaceFolders) {
Expand Down Expand Up @@ -227,13 +230,5 @@ export class GaugeWorkspace extends Disposable {
});
}

dispose(): Thenable<void> {
let promises: Thenable<void>[] = [];
for (let cp of this._clientsMap.values()) {
promises.push(cp.client.stop());
}
return Promise.all(promises).then((f) => {
this._disposable.dispose();
});
}

}

0 comments on commit 2a02753

Please sign in to comment.