fix(settings): hold Change and Move while a switched move awaits Resume

A move that switched to the folder in use but left part of its old folder
showed Resume and a "resume it first" tooltip on Change… and Move…, yet both
stayed enabled because no journal lies in the folder in use. Choosing another
folder then would hide the Resume for good and leave the old folder's copy
on disk. Change… and Move… now wait whenever a stopped move is found.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-04 17:43:40 +01:00
1 parent 2654683a12
commit e0644e5304
2 files changed
+23 -2

No files matched your search

@@ -106,7 +106,7 @@ public sealed class WorkspaceSettingsRows(AppSettings settings, Action save, Fun
public RelayCommand OpenCommand { get; } = new(open);
/// <summary>Uses another folder, after its plan (WorkspaceFolderChange); none where the folder cannot change, nor while it moves.</summary>
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");
/// <summary>Moves the folder with its projects, after its plan (WorkspaceFolderChange.MoveAsync); none where it cannot move, nor while it moves.</summary>
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
/// <summary>A move holds the workspace, as read last (read once when not known since the last refresh).</summary>
private bool IsMoving => _moving ??= services?.IsMoving() ?? false;
/// <summary>
/// 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).
/// </summary>
private bool IsHeld => _unfinished || IsMoving;
private async Task ResumeMoveAsync()
{
if (services?.ResumeMove is not { } resume) return;
@@ -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()
{