Skip to content

Commit 6f824c3

Browse files
committed
default configurations
1 parent 3d32932 commit 6f824c3

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/debugger/AttachDebugSession.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,11 @@ export class AttachDebugSession extends LoggingDebugSession implements ExprEvalu
7272
const isX86 = stdout === "1";
7373
const arch = isX86 ? "x86" : "x64";
7474
const toolExe = `${args.extensionPath}/server/windows/${arch}/emmy.tool.exe`;
75-
const cmd = `${toolExe} -m run --cmd ${args.program} -e ${emmyLua} -w ${args.workingDir} --console true -a ${args.arguments.join(" ")}`;
76-
const ls = this.runDebugger(cmd, args, response);
75+
const argList = [toolExe, "-m", "run", "-c", args.program, "-e", emmyLua, '-w', args.workingDir, "--console", "true"];
76+
if (args.arguments.length > 0) {
77+
argList.push("-a", args.arguments.join(" "));
78+
}
79+
const ls = this.runDebugger(argList.join(" "), args, response);
7780
this.once("initialized", () => {
7881
ls.stdin.write("resume\n");
7982
});

src/debugger/AttachDebuggerProvider.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as vscode from 'vscode';
44
import { WorkspaceFolder, DebugConfiguration, CancellationToken, ProviderResult } from 'vscode';
55
import { savedContext } from '../extension';
66
import * as cp from "child_process";
7-
import { basename } from 'path';
7+
import { basename, normalize } from 'path';
88

99
var parseString = require('xml2js').parseString;
1010

@@ -16,9 +16,22 @@ interface AttachDebugConfiguration extends DebugConfiguration {
1616
pid: number;
1717
extensionPath: string;
1818
sourcePaths: string[];
19+
20+
program?: string;
21+
arguments?: string[];
22+
workingDir?: string;
1923
}
2024

2125
export class AttachDebuggerProvider implements vscode.DebugConfigurationProvider {
26+
private isNullOrEmpty(s?: string): boolean {
27+
return !s || s.trim().length === 0;
28+
}
29+
30+
private getSourceRoots(): string[] {
31+
var list = vscode.workspace.workspaceFolders!.map(f => { return f.uri.fsPath; });
32+
var config = <Array<string>> vscode.workspace.getConfiguration("emmylua").get("source.roots");
33+
return list.concat(config.map(item => { return normalize(item); }));
34+
}
2235

2336
provideDebugConfigurations(folder: WorkspaceFolder | undefined, token?: CancellationToken): ProviderResult<DebugConfiguration[]> {
2437
var config: DebugConfiguration = {
@@ -32,8 +45,14 @@ export class AttachDebuggerProvider implements vscode.DebugConfigurationProvider
3245

3346
resolveDebugConfiguration(folder: WorkspaceFolder | undefined, debugConfiguration: AttachDebugConfiguration, token?: CancellationToken): ProviderResult<DebugConfiguration> {
3447
debugConfiguration.extensionPath = savedContext.extensionPath;
35-
debugConfiguration.sourcePaths = vscode.workspace.workspaceFolders!.map(f => { return f.uri.fsPath; });
48+
debugConfiguration.sourcePaths = this.getSourceRoots();
3649
if (debugConfiguration.type === "emmylua_launch") {
50+
if (this.isNullOrEmpty(debugConfiguration.workingDir)) {
51+
debugConfiguration.workingDir = "%workspaceRoot%";
52+
}
53+
if (!debugConfiguration.arguments) {
54+
debugConfiguration.arguments = [];
55+
}
3756
return debugConfiguration;
3857
}
3958
if (debugConfiguration.pid > 0) {

0 commit comments

Comments
 (0)