From 3154406471a04fc7e3820a3674b0ec621f48789b Mon Sep 17 00:00:00 2001 From: stricklandrbls Date: Wed, 10 Apr 2024 15:50:43 -0500 Subject: [PATCH] Resolved Windows Lingering OE Server - Pushed DataEditor object to VSCode context subscriptions stack. - Fixed sending of a `serverStop` request when given a predicate. Closes #1005 --- src/dataEditor/dataEditorClient.ts | 6 ++++-- src/dataEditor/include/server/ServerInfo.ts | 10 ++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/dataEditor/dataEditorClient.ts b/src/dataEditor/dataEditorClient.ts index 2520371d8..a96e6ca7c 100644 --- a/src/dataEditor/dataEditorClient.ts +++ b/src/dataEditor/dataEditorClient.ts @@ -84,7 +84,6 @@ import { extractDaffodilEvent } from '../daffodilDebugger/daffodil' import * as editor_config from './config' import { configureOmegaEditPort, - NoSessionsExist, ServerInfo, ServerStopPredicate, } from './include/server/ServerInfo' @@ -177,6 +176,7 @@ export class DataEditorClient implements vscode.Disposable { await this.panel.webview.postMessage(forwardAs) }) ) + context.subscriptions.push(this) this.svelteWebviewInitializer = new SvelteWebviewInitializer(context) this.svelteWebviewInitializer.initialize(this.view, this.panel.webview) @@ -195,7 +195,9 @@ export class DataEditorClient implements vscode.Disposable { // destroy the session and remove it from the list of active sessions removeActiveSession(await destroySession(this.omegaSessionId)) - await serverStopIf(NoSessionsExist) + await serverStopIf(() => { + return activeSessions.length == 0 + }) for (let i = 0; i < this.disposables.length; i++) this.disposables[i].dispose() } diff --git a/src/dataEditor/include/server/ServerInfo.ts b/src/dataEditor/include/server/ServerInfo.ts index 85e24a5bb..db871da8b 100644 --- a/src/dataEditor/include/server/ServerInfo.ts +++ b/src/dataEditor/include/server/ServerInfo.ts @@ -18,7 +18,7 @@ import * as editor_config from '../../config' import * as fs from 'fs' import assert from 'assert' -import { IServerInfo, getSessionCount } from '@omega-edit/client' +import { IServerInfo } from '@omega-edit/client' export class ServerInfo implements IServerInfo { serverHostname: string = 'unknown' @@ -53,10 +53,4 @@ export function configureOmegaEditPort(configVars: editor_config.Config): void { assert(omegaEditPort !== 0, 'omegaEditPort is not set') } } -export type ServerStopPredicate = (context?: any) => Promise -export const NoSessionsExist: ServerStopPredicate = (): Promise => { - return new Promise(async (resolve) => { - const count = await getSessionCount() - resolve(count === 0) - }) -} +export type ServerStopPredicate = (context?: any) => boolean