File tree Expand file tree Collapse file tree 3 files changed +18
-17
lines changed Expand file tree Collapse file tree 3 files changed +18
-17
lines changed Original file line number Diff line number Diff line change @@ -132,15 +132,20 @@ class IotjsDebugSession extends LoggingDebugSession {
132
132
this . sendEvent ( new TerminatedEvent ( ) ) ;
133
133
} ;
134
134
135
- const onWaitForSource = ( ) => {
135
+ const onWaitForSource = async ( ) => {
136
136
this . log ( 'onWaitForSource' ) ;
137
+
137
138
if ( args . program !== '' ) {
138
139
if ( Fs . existsSync ( `${ args . localRoot } /${ args . program } ` ) ) {
139
140
const content = Fs . readFileSync ( `${ args . localRoot } /${ args . program } ` , {
140
141
encoding : 'utf8' ,
141
142
flag : 'r'
142
143
} ) ;
143
- this . _protocolhandler . sendClientSource ( args . program , content ) ;
144
+ await this . _protocolhandler . sendClientSource ( args . program , content )
145
+ . then ( ( ) => this . log ( 'Source has been sended to the engine.' ) )
146
+ . catch ( error => {
147
+ this . sendErrorResponse ( response , 0 , error ) ;
148
+ } ) ;
144
149
} else {
145
150
this . sendErrorResponse ( response , 0 , 'You must provide a valid path to source' ) ;
146
151
}
Original file line number Diff line number Diff line change @@ -711,9 +711,9 @@ export class JerryDebugProtocolHandler {
711
711
return result ;
712
712
}
713
713
714
- sendClientSource ( fileName , fileSourceCode ) {
714
+ public sendClientSource ( fileName : string , fileSourceCode : string ) : Promise < any > {
715
715
if ( ! this . waitForSourceEnabled ) {
716
- throw new Error ( 'wait-for-source not enabled' ) ;
716
+ return Promise . reject ( 'wait-for-source not enabled' ) ;
717
717
}
718
718
719
719
this . waitForSourceEnabled = false ;
@@ -723,21 +723,20 @@ export class JerryDebugProtocolHandler {
723
723
array [ 0 ] = SP . CLIENT . JERRY_DEBUGGER_CLIENT_SOURCE ;
724
724
725
725
if ( byteLength <= this . maxMessageSize ) {
726
- this . debuggerClient . send ( array ) ;
727
- return true ;
726
+ return this . sendSimpleRequest ( array ) ;
728
727
}
729
728
730
- this . debuggerClient . send ( array . slice ( 0 , this . maxMessageSize ) ) ;
729
+ let result = this . sendSimpleRequest ( array . slice ( 0 , this . maxMessageSize ) ) ;
731
730
732
731
let offset = this . maxMessageSize - 1 ;
733
732
734
733
while ( offset < byteLength ) {
735
734
array [ offset ] = SP . CLIENT . JERRY_DEBUGGER_CLIENT_SOURCE_PART ;
736
- this . debuggerClient . send ( array . slice ( offset , offset + this . maxMessageSize ) ) ;
735
+ result = this . sendSimpleRequest ( array . slice ( offset , offset + this . maxMessageSize ) ) ;
737
736
offset += this . maxMessageSize - 1 ;
738
737
}
739
738
740
- return true ;
739
+ return result ;
741
740
}
742
741
743
742
onWaitForSource ( ) {
Original file line number Diff line number Diff line change @@ -46,14 +46,9 @@ const provideInitialConfigurations = (): string => {
46
46
} ;
47
47
48
48
const getListOfFiles = ( ) : Array < string > => {
49
- let wsFolders = Array < string > ( ) ;
50
49
let wsFiles = Array < string > ( ) ;
51
50
52
- vscode . workspace . workspaceFolders . forEach ( folder => {
53
- wsFolders . push ( folder . uri . fsPath ) ;
54
- } ) ;
55
-
56
- wsFolders . forEach ( entry => {
51
+ vscode . workspace . workspaceFolders . map ( folder => folder . uri . fsPath ) . forEach ( entry => {
57
52
fs . readdirSync ( entry ) . forEach ( file => {
58
53
if ( ( fs . statSync ( `${ entry } /${ file } ` ) ) . isFile ( ) ) {
59
54
if ( path . extname ( file ) . toLowerCase ( ) . match ( / \. ( j s ) $ / i) ) {
@@ -62,12 +57,14 @@ const getListOfFiles = (): Array<string> => {
62
57
}
63
58
} ) ;
64
59
} ) ;
65
- return wsFiles ;
60
+
61
+ return [ '' , ...wsFiles ] ;
66
62
} ;
67
63
68
64
const getProgramName = ( ) : Thenable < string > => {
69
65
return vscode . window . showQuickPick ( getListOfFiles ( ) , {
70
- placeHolder : 'Select a file you want to debug or press Enter if you are in normal mode'
66
+ placeHolder : 'Select a file you want to debug or press Enter if you are in normal mode' ,
67
+ ignoreFocusOut : true
71
68
} ) ;
72
69
} ;
73
70
You can’t perform that action at this time.
0 commit comments