Skip to content

Commit 84ed8a1

Browse files
committed
Fixed Runtime margin for SqfVmDebugger & if no sqf document is available, active document will be used to run now.
1 parent c9a0f89 commit 84ed8a1

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

Arma.Studio.SqfVmDebugger/PluginMain.cs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,30 +160,39 @@ await Task.Run(() =>
160160
Logger.Warning($"No config file located for PBO {pbo.Name}.");
161161
}
162162
}
163-
if (!hasConfig)
164-
{
165-
Logger.Error("No config files available.");
166-
break;
167-
}
168163
// Apply Breakpoints
169164
foreach (var breakpoint in this.GetApplication().MainWindow.BreakpointManager.Breakpoints)
170165
{
171166
this.SetBreakpoint(breakpoint);
172167
}
173-
// Run CfgFunctions script
168+
if (hasConfig)
174169
{
170+
// Run CfgFunctions script
175171
var text = this.CfgFunctionsScript;
176172
var preprocessed = this.Virtualmachine.PreProcess(text, "SqfVmDebugger/CfgFunctions.sqf");
177173
this.Virtualmachine.ParseSqf(preprocessed, "SqfVmDebugger/CfgFunctions.sqf");
178174
this.State = EDebugState.Running;
179175
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+
}
180195
}
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}");
187196
break;
188197
case EDebugAction.Stop:
189198
execResult = this.Virtualmachine.Abort();
@@ -247,7 +256,7 @@ public IEnumerable<HaltInfo> GetHaltInfos()
247256
{
248257
if (this.Virtualmachine == null)
249258
{
250-
throw new InvalidOperationException();
259+
return Array.Empty<HaltInfo>();
251260
}
252261
Logger.Diagnostic($"IEnumerable<HaltInfo> GetHaltInfos()");
253262
var callstack = this.Virtualmachine.GetCallstack();

Arma.Studio/UI/RuntimeBackgroundRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void Draw(TextView textView, DrawingContext drawingContext)
4848
{
4949
if (this.Editor.Document == null ||
5050
App.MWContext.Debugger is null ||
51-
App.MWContext.Debugger.State == Data.Debugging.EDebugState.Running)
51+
App.MWContext.Debugger.State != Data.Debugging.EDebugState.Halted)
5252
{
5353
return;
5454
}

0 commit comments

Comments
 (0)