diff --git a/src/Chronos.App/Settings/WorkspaceSettingsRows.cs b/src/Chronos.App/Settings/WorkspaceSettingsRows.cs index 103c06e3..14d8172e 100644 --- a/src/Chronos.App/Settings/WorkspaceSettingsRows.cs +++ b/src/Chronos.App/Settings/WorkspaceSettingsRows.cs @@ -106,7 +106,7 @@ public sealed class WorkspaceSettingsRows(AppSettings settings, Action save, Fun public RelayCommand OpenCommand { get; } = new(open); /// Uses another folder, after its plan (WorkspaceFolderChange); none where the folder cannot change, nor while it moves. - public AsyncRelayCommand ChangeCommand => _change ??= new AsyncRelayCommand(() => ThenReadMoveAsync(change), () => change is not null && !IsMoving); + public AsyncRelayCommand ChangeCommand => _change ??= new AsyncRelayCommand(() => ThenReadMoveAsync(change), () => change is not null && !IsHeld); private AsyncRelayCommand? _change; @@ -116,7 +116,7 @@ public sealed class WorkspaceSettingsRows(AppSettings settings, Action save, Fun public string ChangeToolTip => MoveState ?? Loc.L("Tooltips.Settings.ChangeWorkspace"); /// Moves the folder with its projects, after its plan (WorkspaceFolderChange.MoveAsync); none where it cannot move, nor while it moves. - public AsyncRelayCommand MoveCommand => _move ??= new AsyncRelayCommand(() => ThenReadMoveAsync(services?.Move), () => services?.Move is not null && !IsMoving); + public AsyncRelayCommand MoveCommand => _move ??= new AsyncRelayCommand(() => ThenReadMoveAsync(services?.Move), () => services?.Move is not null && !IsHeld); private AsyncRelayCommand? _move; @@ -430,6 +430,12 @@ public sealed class WorkspaceSettingsRows(AppSettings settings, Action save, Fun /// A move holds the workspace, as read last (read once when not known since the last refresh). private bool IsMoving => _moving ??= services?.IsMoving() ?? false; + /// + /// Change… and Move… wait: a move holds the folder, or one stopped and Resume takes it up (also one that switched here + /// and left part of the folder it came from: another folder now would leave that part with no Resume). + /// + private bool IsHeld => _unfinished || IsMoving; + private async Task ResumeMoveAsync() { if (services?.ResumeMove is not { } resume) return; diff --git a/tests/Chronos.App.Tests/Settings/SettingsLogicTests.cs b/tests/Chronos.App.Tests/Settings/SettingsLogicTests.cs index 654a5ecb..c0ac58c0 100644 --- a/tests/Chronos.App.Tests/Settings/SettingsLogicTests.cs +++ b/tests/Chronos.App.Tests/Settings/SettingsLogicTests.cs @@ -722,6 +722,21 @@ public sealed class SettingsLogicTests Assert.True(rows.MoveCommand.CanExecute(null)); } + [Test] + public async Task AMoveThatSwitchedHereAndLeftPartOfItsOldFolderStillHoldsChangeAndMove() + { + // The folder in use holds no journal (the move switched to it), but the old folder still does: Resume clears it, + // and another folder chosen first would leave that part with no Resume. + var (_, rows, _) = WorkspaceRows(new FakeWorkspace(), move: () => Task.CompletedTask, isMoving: () => false, unfinished: () => true, + resume: () => Task.CompletedTask); + await rows.MeasureAsync(); + + Assert.True(rows.CanResumeMove); + Assert.Equal((Loc.L("Tooltips.Settings.Workspace.MoveUnfinished"), Loc.L("Tooltips.Settings.Workspace.MoveUnfinished")), (rows.ChangeToolTip, rows.MoveToolTip)); + Assert.False(rows.ChangeCommand.CanExecute(null)); + Assert.False(rows.MoveCommand.CanExecute(null)); + } + [Test] public void ADefaultMediaOrOpenPolicySetElsewhereReadsAsEverythingAppliesIt() {