nav history v2

This commit is contained in:
Matt Parker
2025-10-29 20:40:13 +10:00
parent 45946bce8c
commit c3069b0e41
5 changed files with 33 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
using Godot;
using R3;
using SharpIDE.Application.Features.NavigationHistory;
namespace SharpIDE.Godot.Features.Navigation;
@@ -14,5 +15,24 @@ public partial class ForwardBackwardButtonContainer : HBoxContainer
{
_backwardButton = GetNode<Button>("BackwardButton");
_forwardButton = GetNode<Button>("ForwardButton");
_backwardButton.Pressed += OnBackwardButtonPressed;
_forwardButton.Pressed += OnForwardButtonPressed;
Observable.EveryValueChanged(_navigationHistoryService, navigationHistoryService => navigationHistoryService.Current)
.Where(s => s is not null)
.Subscribe(s =>
{
_backwardButton.Disabled = !_navigationHistoryService.CanGoBack;
_forwardButton.Disabled = !_navigationHistoryService.CanGoForward;
}).AddTo(this);
}
private void OnBackwardButtonPressed()
{
_navigationHistoryService.GoBack();
}
private void OnForwardButtonPressed()
{
_navigationHistoryService.GoForward();
}
}

View File

@@ -5,12 +5,12 @@
[node name="ForwardBackwardButtonContainer" type="HBoxContainer"]
script = ExtResource("1_vep4b")
[node name="ForwardButton" type="Button" parent="."]
[node name="BackwardButton" type="Button" parent="."]
layout_mode = 2
size_flags_vertical = 4
text = " < "
[node name="BackwardButton" type="Button" parent="."]
[node name="ForwardButton" type="Button" parent="."]
layout_mode = 2
size_flags_vertical = 4
text = " > "

View File

@@ -104,7 +104,6 @@ public partial class SolutionExplorerPanel : MarginContainer
_tree.QueueRedraw();
});
}
_navigationHistoryService.RecordNavigation(file, fileLinePosition ?? new SharpIdeFileLinePosition(0, 0));
await task.ConfigureAwait(false);
}