@@ -4,7 +4,7 @@ import * as vscode from 'vscode';
44import { WorkspaceFolder , DebugConfiguration , CancellationToken , ProviderResult } from 'vscode' ;
55import { savedContext } from '../extension' ;
66import * as cp from "child_process" ;
7- import { basename } from 'path' ;
7+ import { basename , normalize } from 'path' ;
88
99var 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
2125export 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