Skip to content

Commit 656e9ad

Browse files
committed
cleanup
1 parent 11f285a commit 656e9ad

2 files changed

Lines changed: 34 additions & 18 deletions

File tree

src/DiffEngineTray.Tests/TrackerAcceptOpenTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public async Task AViewerPairIsOpenEvenWithNoProcess()
2121

2222
await tracker.AssertEmpty();
2323
await Assert.That(File.Exists(temp)).IsFalse();
24-
await Assert.That(File.ReadAllText(target)).IsEqualTo("received");
24+
await Assert.That(await File.ReadAllTextAsync(target)).IsEqualTo("received");
2525
}
2626

2727
/// <summary>
@@ -55,9 +55,9 @@ public async Task TheViewerIsRecognisedByNameRatherThanByPath()
5555
"viewer",
5656
OperatingSystem.IsWindows() ? "DiffEngineViewer.exe" : "DiffEngineViewer");
5757

58-
readonly string directory = Path.Combine(Path.GetTempPath(), $"AcceptOpen {Guid.NewGuid():N}");
59-
readonly string temp;
60-
readonly string target;
58+
string directory = Path.Combine(Path.GetTempPath(), $"AcceptOpen {Guid.NewGuid():N}");
59+
string temp;
60+
string target;
6161

6262
public TrackerAcceptOpenTest()
6363
{

src/DiffEngineTray/Tracker.cs

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,17 @@ static TrackedMove BuildTrackedMove(string temp, string? exe, string? arguments,
230230
// Off the resolved executable rather than the resolved tool, because the sender's viewer
231231
// and this tray's are different copies at different paths, so the path lookup above finds
232232
// nothing for the one case that matters most here.
233-
return new(temp, target, exe, arguments, canKill.GetValueOrDefault(false), process, solution, extension, killLockingProcess, PendingFiles.IsViewerExe(exe));
233+
return new(
234+
temp,
235+
target,
236+
exe,
237+
arguments,
238+
canKill.GetValueOrDefault(false),
239+
process,
240+
solution,
241+
extension,
242+
killLockingProcess,
243+
PendingFiles.IsViewerExe(exe));
234244
}
235245

236246
/// <summary>
@@ -296,10 +306,15 @@ bool TryAcceptOne(PendingSnapshot snapshot, out string? message)
296306

297307
// The owner does not always have something to add, and a balloon ending in a bare full stop
298308
// and a space reads as a message that went missing
299-
static string CouldNotAccept(string name, string? message) =>
300-
message is { Length: > 0 }
301-
? $"Could not accept the snapshot for '{name}'. {message}"
302-
: $"Could not accept the snapshot for '{name}'.";
309+
static string CouldNotAccept(string name, string? message)
310+
{
311+
if (message is { Length: > 0 })
312+
{
313+
return $"Could not accept the snapshot for '{name}'. {message}";
314+
}
315+
316+
return $"Could not accept the snapshot for '{name}'.";
317+
}
303318

304319
/// <summary>
305320
/// On a worker, matching <see cref="Accept(PendingSnapshot)"/> and for the same reason. Against
@@ -807,16 +822,17 @@ bool ITrackedFiles.Untrack(string key)
807822
{
808823
if (TrackedKeys.TryStrip(key, TrackedKeys.MovePrefix, out var temp))
809824
{
810-
return moves.TryGetValue(temp, out var move)
811-
? AcceptWithoutPrompting(move)
812-
: (false, null);
825+
if (moves.TryGetValue(temp, out var move))
826+
{
827+
return AcceptWithoutPrompting(move);
828+
}
813829
}
814-
815-
if (TrackedKeys.TryStrip(key, TrackedKeys.DeletePrefix, out var file))
830+
else if (TrackedKeys.TryStrip(key, TrackedKeys.DeletePrefix, out var file))
816831
{
817-
return deletes.TryGetValue(file, out var delete)
818-
? AcceptTracked(delete)
819-
: (false, null);
832+
if (deletes.TryGetValue(file, out var delete))
833+
{
834+
return AcceptTracked(delete);
835+
}
820836
}
821837

822838
return (false, null);
@@ -982,4 +998,4 @@ public ValueTask DisposeAsync()
982998
snapshots = [];
983999
return timer.DisposeAsync();
9841000
}
985-
}
1001+
}

0 commit comments

Comments
 (0)