Skip to content

Commit

Permalink
Editor: fix Watchpanel auto-local var checkbox
Browse files Browse the repository at this point in the history
when checked back it now shows the variables in the watch panel properly
  • Loading branch information
ericoporto committed Nov 12, 2024
1 parent 0d4f4a1 commit d719aff
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions Editor/AGS.Editor/GUI/WatchVariablesPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public partial class WatchVariablesPanel : DockContent
private readonly object _updateItemLock = new object();
private readonly List<ListViewItem> _itemsToUpdate = new List<ListViewItem>();
private bool _autoWatchLocalVars = true;
private string _currentScriptName;
private int _currentLineNumber;

public WatchVariablesPanel()
{
Expand Down Expand Up @@ -290,11 +292,21 @@ private void ClearAllAutoLocalVariables()

public void SetAutoLocalVariables(DebugCallStack callStack)
{
if (!AGSEditor.Instance.Debugger.IsActive || !_autoWatchLocalVars)
if (callStack.Lines.Count == 0)
return;

string scriptName = callStack.Lines[0].ScriptName;
int lineNumber = callStack.Lines[0].LineNumber;
_currentScriptName = scriptName;
_currentLineNumber = lineNumber;
SetAutoLocalVariables(scriptName, lineNumber);
}

private void SetAutoLocalVariables(string scriptName, int lineNumber)
{
if (!AGSEditor.Instance.Debugger.IsActive || !_autoWatchLocalVars)
return;

ScintillaWrapper scintilla = Factory.GUIController.GetScriptEditorControl(scriptName, true) as ScintillaWrapper;
if (scintilla == null)
return;
Expand Down Expand Up @@ -352,12 +364,19 @@ public void SetAutoLocalVariables(DebugCallStack callStack)

private bool AutoWatchLocalVariables
{
get { return _autoWatchLocalVars; }
set {
_autoWatchLocalVars = value;
if(!_autoWatchLocalVars)
ClearAllAutoLocalVariables();
}
get
{
return _autoWatchLocalVars;
}

set
{
_autoWatchLocalVars = value;
if (_autoWatchLocalVars)
SetAutoLocalVariables(_currentScriptName, _currentLineNumber);
else
ClearAllAutoLocalVariables();
}
}

public void UpdateAllWatches()
Expand Down

0 comments on commit d719aff

Please # to comment.