@@ -160,30 +160,39 @@ await Task.Run(() =>
160
160
Logger . Warning ( $ "No config file located for PBO { pbo . Name } .") ;
161
161
}
162
162
}
163
- if ( ! hasConfig )
164
- {
165
- Logger . Error ( "No config files available." ) ;
166
- break ;
167
- }
168
163
// Apply Breakpoints
169
164
foreach ( var breakpoint in this . GetApplication ( ) . MainWindow . BreakpointManager . Breakpoints )
170
165
{
171
166
this . SetBreakpoint ( breakpoint ) ;
172
167
}
173
- // Run CfgFunctions script
168
+ if ( hasConfig )
174
169
{
170
+ // Run CfgFunctions script
175
171
var text = this . CfgFunctionsScript ;
176
172
var preprocessed = this . Virtualmachine . PreProcess ( text , "SqfVmDebugger/CfgFunctions.sqf" ) ;
177
173
this . Virtualmachine . ParseSqf ( preprocessed , "SqfVmDebugger/CfgFunctions.sqf" ) ;
178
174
this . State = EDebugState . Running ;
179
175
execResult = this . Virtualmachine . Start ( ) ;
176
+ Logger . Diagnostic ( $ "Result of Start: { execResult } ") ;
177
+ }
178
+ else
179
+ {
180
+ Logger . Warning ( "No config files available. Trying to use currently open document." ) ;
181
+ var editorDocument = this . GetApplication ( ) . MainWindow . ActiveDockable as Data . UI . IEditorDocument ;
182
+ if ( editorDocument != null && editorDocument . File . Extension == ".sqf" )
183
+ {
184
+ var text = editorDocument . GetContents ( ) ;
185
+ var preprocessed = this . Virtualmachine . PreProcess ( text , editorDocument . TextEditorInstance . File . FullPath ) ;
186
+ this . Virtualmachine . ParseSqf ( preprocessed , editorDocument . TextEditorInstance . File . FullPath ) ;
187
+ this . State = EDebugState . Running ;
188
+ execResult = this . Virtualmachine . Start ( ) ;
189
+ Logger . Diagnostic ( $ "Result of Start: { execResult } ") ;
190
+ }
191
+ else
192
+ {
193
+ Logger . Error ( "Found nothing to run." ) ;
194
+ }
180
195
}
181
- //var text = textEditorDocuments.GetContents();
182
- //var preprocessed = this.Virtualmachine.PreProcess(text, textEditorDocuments.TextEditorInstance.File.FullPath);
183
- //this.Virtualmachine.ParseSqf(preprocessed, textEditorDocuments.TextEditorInstance.File.FullPath);
184
- //this.State = EDebugState.Running;
185
- //execResult = this.Virtualmachine.Start();
186
- Logger . Diagnostic ( $ "Result of Start: { execResult } ") ;
187
196
break ;
188
197
case EDebugAction . Stop :
189
198
execResult = this . Virtualmachine . Abort ( ) ;
@@ -247,7 +256,7 @@ public IEnumerable<HaltInfo> GetHaltInfos()
247
256
{
248
257
if ( this . Virtualmachine == null )
249
258
{
250
- throw new InvalidOperationException ( ) ;
259
+ return Array . Empty < HaltInfo > ( ) ;
251
260
}
252
261
Logger . Diagnostic ( $ "IEnumerable<HaltInfo> GetHaltInfos()") ;
253
262
var callstack = this . Virtualmachine . GetCallstack ( ) ;
0 commit comments