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

shanedell 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 ca6171c  Fix program and data commands issue
ca6171c is described below

commit ca6171ce09fabb9c3545ec78d1611aecb40d9f33
Author: Shane Dell <[email protected]>
AuthorDate: Mon Aug 7 09:43:21 2023 -0400

    Fix program and data commands issue
    
    - Fix program and data name commands not setting the proper values.
      - This was because after getting the value we weren't setting the current 
config to the proper config
    
    Closes #733
---
 src/adapter/activateDaffodilDebug.ts |  8 +++---
 src/daffodilDebugger/debugger.ts     | 47 +++++++++++++++---------------------
 src/daffodilDebugger/utils.ts        |  2 +-
 3 files changed, 24 insertions(+), 33 deletions(-)

diff --git a/src/adapter/activateDaffodilDebug.ts 
b/src/adapter/activateDaffodilDebug.ts
index 0ef34c4..3d2e927 100644
--- a/src/adapter/activateDaffodilDebug.ts
+++ b/src/adapter/activateDaffodilDebug.ts
@@ -467,14 +467,14 @@ class DaffodilConfigurationProvider
     ) {
       return getDataFileFromFolder(dataFolder).then((dataFile) => {
         config.data = dataFile
-        return getDebugger(this.context, config).then((_) => {
-          return setCurrentConfig(config)
+        return getDebugger(this.context, config).then((updatedConfig) => {
+          return setCurrentConfig(updatedConfig ?? config)
         })
       })
     }
 
-    return getDebugger(this.context, config).then((_) => {
-      return setCurrentConfig(config)
+    return getDebugger(this.context, config).then((updatedConfig) => {
+      return setCurrentConfig(updatedConfig ?? config)
     })
   }
 }
diff --git a/src/daffodilDebugger/debugger.ts b/src/daffodilDebugger/debugger.ts
index a7fb514..129cee2 100644
--- a/src/daffodilDebugger/debugger.ts
+++ b/src/daffodilDebugger/debugger.ts
@@ -53,29 +53,6 @@ async function getTDMLConfig(
     // Might need to add `program` here if we move the `Execute TDML` command
     //   away from the detected dfdl language in VSCode.
     config.data = ''
-  } else {
-    // Get program file before debugger starts to avoid timeout
-    if (config.program.includes('${command:AskForProgramName}')) {
-      config.program = await vscode.commands.executeCommand(
-        'extension.dfdl-debug.getProgramName'
-      )
-    }
-
-    if (config.program === '') {
-      // need to invalidate a variable data file so the 
DebugConfigurationProvider doesn't try to resolve it after we return
-      if (config.data.includes('${command:AskForDataName}')) {
-        config.data = ''
-      }
-
-      return false
-    }
-
-    // Get data file before debugger starts to avoid timeout
-    if (config.data.includes('${command:AskForDataName}')) {
-      config.data = await vscode.commands.executeCommand(
-        'extension.dfdl-debug.getDataName'
-      )
-    }
   }
 
   if (
@@ -172,20 +149,32 @@ async function getDaffodilDebugClasspath(
 export async function getDebugger(
   context: vscode.ExtensionContext,
   config: vscode.DebugConfiguration
-) {
+): Promise<vscode.DebugConfiguration | undefined> {
   config = getConfig(config) // make sure all config attributes are set
 
   if (!config.useExistingServer) {
     if (vscode.workspace.workspaceFolders !== undefined) {
       await stopDebugger()
 
+      // Get program file before debugger starts to avoid timeout
+      if (config.program.includes('${command:AskForProgramName}')) {
+        config.program = await vscode.commands.executeCommand(
+          'extension.dfdl-debug.getProgramName'
+        )
+      }
+
+      // Get data file before debugger starts to avoid timeout
+      if (config.data.includes('${command:AskForDataName}')) {
+        config.data = await vscode.commands.executeCommand(
+          'extension.dfdl-debug.getDataName'
+        )
+      }
+
       if (!(await getTDMLConfig(config))) {
-        return await stopDebugging()
+        return await stopDebugging().then((_) => undefined)
       }
 
-      let workspaceFolder = vscode.workspace.workspaceFolders
-        ? vscode.workspace.workspaceFolders[0].uri.fsPath
-        : vscode.Uri.parse('').fsPath
+      let workspaceFolder = vscode.workspace.workspaceFolders[0].uri.fsPath
 
       // Get daffodilDebugger class paths to be added to the debugger
       const daffodilDebugClasspath = await getDaffodilDebugClasspath(
@@ -202,4 +191,6 @@ export async function getDebugger(
       )
     }
   }
+
+  return config
 }
diff --git a/src/daffodilDebugger/utils.ts b/src/daffodilDebugger/utils.ts
index 93af30d..0898c37 100644
--- a/src/daffodilDebugger/utils.ts
+++ b/src/daffodilDebugger/utils.ts
@@ -33,7 +33,7 @@ export const daffodilArtifact = (version: string): Artifact 
=> {
   return new Artifact('daffodil-debugger', version, 'daffodil-debugger')
 }
 
-export const stopDebugger = (id: number | undefined = undefined) =>
+export const stopDebugger = async (id: number | undefined = undefined) =>
   child_process.exec(osCheck(`taskkill /F /PID ${id}`, `kill -9 ${id}`))
 
 export const shellArgs = (port: number) => ['--listenPort', `${port}`]

Reply via email to