Skip to content

Commit 40d9ce7

Browse files
tomertecTomer Vaknin
authored andcommitted
Fix pane enumeration and nullable parameter handling
- Fix GetAllLeafNodes to include tabbed panes and avoid duplicates - Make logger parameter nullable in HostProfileManagerViewModel - Make exception parameter nullable in Result.Failure methods
1 parent 43abd1c commit 40d9ce7

3 files changed

Lines changed: 24 additions & 12 deletions

File tree

src/SshManager.App/Services/PaneLayoutManager.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,24 @@ public void CycleFocusPrevious()
373373
/// <inheritdoc />
374374
public IEnumerable<PaneLeafNode> GetAllLeafNodes()
375375
{
376-
if (_rootNode == null)
377-
yield break;
376+
// Include tabbed panes (these may not be in the tree structure)
377+
foreach (var tabbedPane in _tabbedPanes)
378+
{
379+
yield return tabbedPane;
380+
}
378381

379-
foreach (var leaf in GetLeafNodesRecursive(_rootNode))
382+
// Include tree panes if we have a root node
383+
if (_rootNode != null)
380384
{
381-
yield return leaf;
385+
// Get all leaf nodes from tree, excluding any already returned as tabbed panes
386+
var tabbedPaneIds = new HashSet<Guid>(_tabbedPanes.Select(p => p.Id));
387+
foreach (var leaf in GetLeafNodesRecursive(_rootNode))
388+
{
389+
if (!tabbedPaneIds.Contains(leaf.Id))
390+
{
391+
yield return leaf;
392+
}
393+
}
382394
}
383395
}
384396

src/SshManager.App/ViewModels/HostProfileManagerViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public partial class HostProfileManagerViewModel : ObservableObject
3333
public HostProfileManagerViewModel(
3434
IHostProfileRepository profileRepository,
3535
IProxyJumpProfileRepository proxyJumpRepository,
36-
ILogger<HostProfileManagerViewModel> logger)
36+
ILogger<HostProfileManagerViewModel>? logger)
3737
{
3838
_profileRepository = profileRepository;
3939
_proxyJumpRepository = proxyJumpRepository;
40-
_logger = logger;
40+
_logger = logger ?? Microsoft.Extensions.Logging.Abstractions.NullLogger<HostProfileManagerViewModel>.Instance;
4141
}
4242

4343
/// <summary>

src/SshManager.Core/Result.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ public static Result<T> Failure(Exception exception) =>
7070
new(false, default, exception.Message, exception);
7171

7272
/// <summary>
73-
/// Creates a failed result with an error message and exception.
73+
/// Creates a failed result with an error message and optional exception.
7474
/// </summary>
7575
/// <param name="error">The error message describing the failure.</param>
76-
/// <param name="exception">The exception that caused the failure.</param>
76+
/// <param name="exception">The exception that caused the failure, if any.</param>
7777
/// <returns>A failed result with both the error message and exception.</returns>
78-
public static Result<T> Failure(string error, Exception exception) =>
78+
public static Result<T> Failure(string error, Exception? exception) =>
7979
new(false, default, error, exception);
8080

8181
/// <summary>
@@ -222,12 +222,12 @@ public static Result Failure(Exception exception) =>
222222
new(false, exception.Message, exception);
223223

224224
/// <summary>
225-
/// Creates a failed result with an error message and exception.
225+
/// Creates a failed result with an error message and optional exception.
226226
/// </summary>
227227
/// <param name="error">The error message describing the failure.</param>
228-
/// <param name="exception">The exception that caused the failure.</param>
228+
/// <param name="exception">The exception that caused the failure, if any.</param>
229229
/// <returns>A failed result with both the error message and exception.</returns>
230-
public static Result Failure(string error, Exception exception) =>
230+
public static Result Failure(string error, Exception? exception) =>
231231
new(false, error, exception);
232232

233233
/// <summary>

0 commit comments

Comments
 (0)