diff --git a/src/SharpIDE.Application/Features/NavigationHistory/IdeNavigationHistoryService.cs b/src/SharpIDE.Application/Features/NavigationHistory/IdeNavigationHistoryService.cs index 4ef0f05..eac8eb3 100644 --- a/src/SharpIDE.Application/Features/NavigationHistory/IdeNavigationHistoryService.cs +++ b/src/SharpIDE.Application/Features/NavigationHistory/IdeNavigationHistoryService.cs @@ -12,9 +12,13 @@ public class IdeNavigationHistoryService public bool CanGoBack => _backStack.Count > 0; public bool CanGoForward => _forwardStack.Count > 0; public IdeNavigationLocation? Current => _current; + public bool EnableRecording { get; set; } = false; + + public void StartRecording() => EnableRecording = true; public void RecordNavigation(SharpIdeFile file, SharpIdeFileLinePosition linePosition) { + if (EnableRecording is false) return; var location = new IdeNavigationLocation(file, linePosition); if (location == _current) { @@ -29,13 +33,6 @@ public class IdeNavigationHistoryService _forwardStack.Clear(); } - public void ClearHistory() - { - _backStack.Clear(); - _forwardStack.Clear(); - _current = null; - } - public void GoBack() { if (!CanGoBack) throw new InvalidOperationException("Cannot go back, no history available."); @@ -44,7 +41,6 @@ public class IdeNavigationHistoryService _forwardStack.Push(_current); } _current = _backStack.Pop(); - // TODO: Fire event } public void GoForward() @@ -56,10 +52,7 @@ public class IdeNavigationHistoryService } _current = _forwardStack.Pop(); - // TODO: Fire event } } -public record IdeNavigationLocation(SharpIdeFile File, SharpIdeFileLinePosition LinePosition) -{ -} +public record IdeNavigationLocation(SharpIdeFile File, SharpIdeFileLinePosition LinePosition); diff --git a/src/SharpIDE.Godot/Features/Navigation/ForwardBackwardButtonContainer.cs b/src/SharpIDE.Godot/Features/Navigation/ForwardBackwardButtonContainer.cs index 82a2afb..93f2e41 100644 --- a/src/SharpIDE.Godot/Features/Navigation/ForwardBackwardButtonContainer.cs +++ b/src/SharpIDE.Godot/Features/Navigation/ForwardBackwardButtonContainer.cs @@ -29,10 +29,14 @@ public partial class ForwardBackwardButtonContainer : HBoxContainer private void OnBackwardButtonPressed() { _navigationHistoryService.GoBack(); + var current = _navigationHistoryService.Current; + GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(current!.File, current.LinePosition); } private void OnForwardButtonPressed() { _navigationHistoryService.GoForward(); + var current = _navigationHistoryService.Current; + GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelFireAndForget(current!.File, current.LinePosition); } } \ No newline at end of file diff --git a/src/SharpIDE.Godot/IdeRoot.cs b/src/SharpIDE.Godot/IdeRoot.cs index 7fc0ed0..d466000 100644 --- a/src/SharpIDE.Godot/IdeRoot.cs +++ b/src/SharpIDE.Godot/IdeRoot.cs @@ -170,7 +170,7 @@ public partial class IdeRoot : Control { await GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelAsync(file, linePosition); } - _navigationHistoryService.ClearHistory(); + _navigationHistoryService.StartRecording(); // Select the selected tab var selectedFile = filesToOpen.SingleOrDefault(f => f.IsSelected); if (selectedFile.Item1 is not null) await GodotGlobalEvents.Instance.FileExternallySelected.InvokeParallelAsync(selectedFile.Item1, selectedFile.Item2);