This is an automated email from the ASF dual-hosted git repository.

rstrickland pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil-vscode.git


The following commit(s) were added to refs/heads/main by this push:
     new bc86057  Resolved Windows Lingering OE Server
bc86057 is described below

commit bc86057b2638970bf9b38360fb6d66220ab53038
Author: stricklandrbls <[email protected]>
AuthorDate: Wed Apr 10 15:50:43 2024 -0500

    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          | 15 ++++++++++-----
 src/dataEditor/include/server/ServerInfo.ts | 10 ++--------
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/src/dataEditor/dataEditorClient.ts 
b/src/dataEditor/dataEditorClient.ts
index 2520371..9f8ad4b 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)
@@ -187,15 +187,20 @@ export class DataEditorClient implements 
vscode.Disposable {
   addDisposable(dispoable: vscode.Disposable) {
     this.disposables.push(dispoable)
   }
-  async dispose(): Promise<void> {
+  dispose(): void {
     if (this.sendHeartbeatIntervalId) {
       clearInterval(this.sendHeartbeatIntervalId)
       this.sendHeartbeatIntervalId = undefined
     }
 
     // destroy the session and remove it from the list of active sessions
-    removeActiveSession(await destroySession(this.omegaSessionId))
-    await serverStopIf(NoSessionsExist)
+    destroySession(this.omegaSessionId).then((id) => {
+      removeActiveSession(id)
+      serverStopIf(() => {
+        return activeSessions.length == 0
+      })
+    })
+
     for (let i = 0; i < this.disposables.length; i++)
       this.disposables[i].dispose()
   }
@@ -1128,7 +1133,7 @@ function removeDirectory(dirPath: string): void {
   }
 }
 async function serverStopIf(predicate: ServerStopPredicate) {
-  if (await predicate()) await serverStop()
+  if (predicate()) await serverStop()
 }
 async function serverStop() {
   const serverPidFile = getPidFile(omegaEditPort)
diff --git a/src/dataEditor/include/server/ServerInfo.ts 
b/src/dataEditor/include/server/ServerInfo.ts
index 85e24a5..db871da 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<boolean>
-export const NoSessionsExist: ServerStopPredicate = (): Promise<boolean> => {
-  return new Promise(async (resolve) => {
-    const count = await getSessionCount()
-    resolve(count === 0)
-  })
-}
+export type ServerStopPredicate = (context?: any) => boolean

Reply via email to