Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/diff-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ DiffTools.UseOrder(DiffTool.DiffEngineViewer);
"tempFile.txt" "targetFile.txt"
```
* Scanned paths:
* `$HOME/.dotnet/tools/DiffEngineViewer`
* `%HOME%/.dotnet/tools/DiffEngineViewer`
* `%PATH%DiffEngineViewer`

#### Linux settings:
Expand All @@ -330,7 +330,7 @@ DiffTools.UseOrder(DiffTool.DiffEngineViewer);
"tempFile.txt" "targetFile.txt"
```
* Scanned paths:
* `$HOME/.dotnet/tools/DiffEngineViewer`
* `%HOME%/.dotnet/tools/DiffEngineViewer`
* `%PATH%DiffEngineViewer`

### [Diffinity](https://truehumandesign.se/s_diffinity.php)
Expand Down
41 changes: 41 additions & 0 deletions src/DiffEngine.Tests/SearchDirectoryExpansionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/// <summary>
/// Search directories are written in the one syntax that gets expanded.
/// <para>
/// WildcardFileFinder expands with Environment.ExpandEnvironmentVariables, which only understands
/// %NAME%. A directory written shell style with $HOME was passed through untouched, so it named a
/// literal directory called "$HOME" and never matched - which is why a globally installed
/// DiffEngineViewer was invisible on Linux and macOS whenever the bundled copy was absent.
/// </para>
/// </summary>
public class SearchDirectoryExpansionTests
{
[Test]
public async Task NoDefinitionUsesShellStyleExpansion()
{
var shellStyle = Definitions.Tools
.SelectMany(
definition => Directories(definition)
.Where(_ => _.Contains('$'))
.Select(_ => $"{definition.Tool}: {_}"))
.ToList();

await Assert.That(shellStyle).IsEmpty();
}

static IEnumerable<string> Directories(Definition definition)
{
var support = definition.OsSupport;
foreach (var settings in new[] { support.Windows, support.Linux, support.Osx })
{
if (settings == null)
{
continue;
}

foreach (var directory in settings.SearchDirectories)
{
yield return directory;
}
}
}
}
4 changes: 2 additions & 2 deletions src/DiffEngine.Tests/diffTools.include.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ DiffTools.UseOrder(DiffTool.DiffEngineViewer);
"tempFile.txt" "targetFile.txt"
```
* Scanned paths:
* `$HOME/.dotnet/tools/DiffEngineViewer`
* `%HOME%/.dotnet/tools/DiffEngineViewer`
* `%PATH%DiffEngineViewer`

#### Linux settings:
Expand All @@ -195,7 +195,7 @@ DiffTools.UseOrder(DiffTool.DiffEngineViewer);
"tempFile.txt" "targetFile.txt"
```
* Scanned paths:
* `$HOME/.dotnet/tools/DiffEngineViewer`
* `%HOME%/.dotnet/tools/DiffEngineViewer`
* `%PATH%DiffEngineViewer`

### [Diffinity](https://truehumandesign.se/s_diffinity.php)
Expand Down
4 changes: 2 additions & 2 deletions src/DiffEngine/Implementation/DiffEngineViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public static Definition DiffEngineViewer()
Linux: new(
"DiffEngineViewer",
launchArguments,
SearchDirectories("$HOME/.dotnet/tools/")),
SearchDirectories("%HOME%/.dotnet/tools/")),
Osx: new(
"DiffEngineViewer",
launchArguments,
SearchDirectories("$HOME/.dotnet/tools/"))),
SearchDirectories("%HOME%/.dotnet/tools/"))),
UseShellExecute: false,
// Console subsystem, so without this a window flashes on every launch.
CreateNoWindow: true,
Expand Down
Loading