Skip to content

Commit f161cff

Browse files
committed
Remove FocusDebug instrumentation added during focus system investigation
Delete FocusDebug.cs and remove all FocusDebug.Log calls from Window.cs, WindowEventDispatcher.cs, FocusStateService.cs, HorizontalGridControl.cs, ScrollablePanelControl.cs, and TabControl.cs.
1 parent e955c80 commit f161cff

6 files changed

Lines changed: 2 additions & 40 deletions

File tree

SharpConsoleUI/Controls/HorizontalGridControl.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// License: MIT
77
// -----------------------------------------------------------------------
88

9-
using SharpConsoleUI.Debugging;
109
using SharpConsoleUI.Helpers;
1110
using SharpConsoleUI.Layout;
1211
using HorizontalAlignment = SharpConsoleUI.Layout.HorizontalAlignment;
@@ -910,7 +909,6 @@ public bool ProcessMouseEvent(MouseEventArgs args)
910909

911910
private void FocusChanged()
912911
{
913-
FocusDebug.Log($"HGC.FocusChanged: _hasFocus={_hasFocus} _focusedContent={_focusedContent?.GetType().Name ?? "null"}");
914912
if (_hasFocus)
915913
{
916914
// Only rebuild interactive contents dictionary when columns have changed
@@ -1215,7 +1213,6 @@ private void SetControlFocus(IInteractiveControl control, bool focus)
12151213
/// <inheritdoc/>
12161214
public void NotifyChildFocusChanged(IInteractiveControl child, bool hasFocus)
12171215
{
1218-
FocusDebug.Log($"HGC.NotifyChildFocusChanged: child={child?.GetType().Name} hasFocus={hasFocus} _focusedContent={_focusedContent?.GetType().Name ?? "null"}");
12191216
if (hasFocus)
12201217
{
12211218
if (_focusedContent != null && _focusedContent != child)

SharpConsoleUI/Controls/ScrollablePanelControl.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// License: MIT
77
// -----------------------------------------------------------------------
88

9-
using SharpConsoleUI.Debugging;
109
using SharpConsoleUI.Events;
1110
using SharpConsoleUI.Extensions;
1211
using SharpConsoleUI.Helpers;
@@ -1112,7 +1111,6 @@ public IReadOnlyList<IWindowControl> GetChildren()
11121111
/// <inheritdoc/>
11131112
public void NotifyChildFocusChanged(IInteractiveControl child, bool hasFocus)
11141113
{
1115-
FocusDebug.Log($"SPC.NotifyChildFocusChanged: child={child?.GetType().Name} hasFocus={hasFocus} _focusedChild={_focusedChild?.GetType().Name ?? "null"}");
11161114
if (hasFocus)
11171115
{
11181116
if (_focusedChild != null && _focusedChild != child && _focusedChild is IFocusableControl oldFc)

SharpConsoleUI/Controls/TabControl.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// License: MIT
77
// -----------------------------------------------------------------------
88

9-
using SharpConsoleUI.Debugging;
109
using SharpConsoleUI.Extensions;
1110
using SharpConsoleUI.Helpers;
1211
using SharpConsoleUI.Layout;
@@ -890,7 +889,6 @@ public bool HasFocus
890889
// propagate to SwitchFocus and land on the active tab's content controls.
891890
public bool ProcessKey(ConsoleKeyInfo key)
892891
{
893-
FocusDebug.Log($"TabControl.ProcessKey: _hasFocus={_hasFocus} key={key.Key} mod={key.Modifiers}");
894892
if (!_hasFocus) return false;
895893

896894
if (key.Key == ConsoleKey.LeftArrow || key.Key == ConsoleKey.RightArrow)

SharpConsoleUI/Core/FocusStateService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
using System.Collections.Concurrent;
1010
using SharpConsoleUI.Controls;
11-
using SharpConsoleUI.Debugging;
1211
using SharpConsoleUI.Logging;
1312

1413
namespace SharpConsoleUI.Core
@@ -113,7 +112,6 @@ public void SetFocus(Window window, IInteractiveControl? control, FocusChangeRea
113112
var previousControl = previousState.FocusedControl;
114113

115114
_logService?.LogTrace($"Focus change: {previousControl?.GetType().Name ?? "None"} -> {control?.GetType().Name ?? "None"} ({reason})", "Focus");
116-
FocusDebug.Log($"FSS.SetFocus: {previousControl?.GetType().Name ?? "None"}{control?.GetType().Name ?? "None"} reason={reason}");
117115

118116
// Update the actual control's HasFocus property
119117
if (previousControl != null && previousControl != control)
@@ -231,7 +229,9 @@ public void ClearFocus(Window window, FocusChangeReason reason = FocusChangeReas
231229
{
232230
// Only clear if this window has focus
233231
if (_currentState.FocusedWindow != window)
232+
{
234233
return;
234+
}
235235

236236
var previousState = _currentState;
237237

SharpConsoleUI/Debugging/FocusDebug.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.

SharpConsoleUI/Windows/WindowEventDispatcher.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
using SharpConsoleUI.Controls;
1010
using SharpConsoleUI.Core;
11-
using SharpConsoleUI.Debugging;
1211
using SharpConsoleUI.Drivers;
1312
using SharpConsoleUI.Events;
1413
using SharpConsoleUI.Layout;
@@ -503,13 +502,10 @@ public bool ProcessInput(ConsoleKeyInfo key)
503502

504503
if (HasActiveInteractiveContent(out var activeInteractiveContent))
505504
{
506-
FocusDebug.Log($"ProcessKey: key={key.Key} mod={key.Modifiers} → dispatching to {activeInteractiveContent!.GetType().Name}");
507505
contentKeyHandled = activeInteractiveContent!.ProcessKey(key);
508-
FocusDebug.Log($"ProcessKey: result contentKeyHandled={contentKeyHandled}");
509506
}
510507
else
511508
{
512-
FocusDebug.Log($"ProcessKey: key={key.Key} mod={key.Modifiers} → no activeInteractiveContent (lastFocused={_window._lastFocusedControl?.GetType().Name ?? "null"} lastDeep={_window._lastDeepFocusedControl?.GetType().Name ?? "null"})");
513509
}
514510

515511
// Continue with key handling only if not handled by the focused interactive content
@@ -631,13 +627,11 @@ public bool HasActiveInteractiveContent(out IInteractiveControl? interactiveCont
631627
{
632628
// First try to find focused control in _interactiveContents (direct children)
633629
interactiveContent = _window._interactiveContents.LastOrDefault(ic => ic.IsEnabled && ic.HasFocus);
634-
if (interactiveContent != null) FocusDebug.Log($"HAIC: priority-1 (interactiveContents) → {interactiveContent.GetType().Name}");
635630

636631
// Fallback to _lastFocusedControl if it has focus (for nested controls in containers)
637632
if (interactiveContent == null && _window._lastFocusedControl != null && _window._lastFocusedControl.HasFocus && _window._lastFocusedControl.IsEnabled)
638633
{
639634
interactiveContent = _window._lastFocusedControl;
640-
FocusDebug.Log($"HAIC: priority-2 (lastFocusedControl) → {interactiveContent.GetType().Name}");
641635
}
642636

643637
// Fallback: container's HasFocus was cleared by FocusService.SetFocus(leaf) in NCGF,
@@ -647,11 +641,8 @@ public bool HasActiveInteractiveContent(out IInteractiveControl? interactiveCont
647641
_window._lastDeepFocusedControl is Controls.IFocusableControl deepFc && deepFc.HasFocus)
648642
{
649643
interactiveContent = _window._lastFocusedControl;
650-
FocusDebug.Log($"HAIC: priority-3 (fallback lastFocusedControl, leaf={_window._lastDeepFocusedControl?.GetType().Name}) → {interactiveContent.GetType().Name}");
651644
}
652645

653-
if (interactiveContent == null)
654-
FocusDebug.Log($"HAIC: no match (lastFocused={_window._lastFocusedControl?.GetType().Name ?? "null"} lastDeep={_window._lastDeepFocusedControl?.GetType().Name ?? "null"})");
655646

656647
return interactiveContent != null;
657648
}

0 commit comments

Comments
 (0)