diff --git a/src/RepoM.ActionMenu.Core/ActionMenu/Context/FileFunctions.cs b/src/RepoM.ActionMenu.Core/ActionMenu/Context/FileFunctions.cs
index 63e74dc2..2cef4c09 100644
--- a/src/RepoM.ActionMenu.Core/ActionMenu/Context/FileFunctions.cs
+++ b/src/RepoM.ActionMenu.Core/ActionMenu/Context/FileFunctions.cs
@@ -13,11 +13,20 @@ namespace RepoM.ActionMenu.Core.ActionMenu.Context;
using Scriban.Syntax;
///
-/// Provides file related action menu functions and variables accessable through `file`.
+/// Provides file related action menu functions and variables accessible through `file`.
///
[ActionMenuContext("file")]
internal partial class FileFunctions : ScribanModuleWithFunctions
{
+ private static readonly EnumerationOptions _findFilesOptions = new()
+ {
+ RecurseSubdirectories = true,
+ AttributesToSkip = FileAttributes.Hidden | FileAttributes.System | FileAttributes.Device | FileAttributes.Directory,
+ IgnoreInaccessible = true,
+ MatchType = MatchType.Simple,
+ ReturnSpecialDirectories = false,
+ };
+
public FileFunctions()
{
RegisterFunctions();
@@ -46,7 +55,7 @@ public FileFunctions()
[ActionMenuContextMember("find_files")]
public static string[] FindFiles(ActionMenuGenerationContext /*IMenuContext*/ context, SourceSpan span, string rootPath, string searchPattern)
{
- return FindFilesInner(context as IMenuContext, span, rootPath, searchPattern);
+ return FindFilesInner(context, span, rootPath, searchPattern);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -123,11 +132,6 @@ internal static bool DirectoryExistsInner(IMenuContext context, string path)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static IEnumerable GetFileEnumerator(IFileSystem fileSystem, string path, string searchPattern)
{
- // prefer EnumerateFileSystemInfos() over EnumerateFiles() to include packaged folders like
- // .app or .xcodeproj on macOS
- return fileSystem.DirectoryInfo.New(path)
- .EnumerateFileSystemInfos(searchPattern, SearchOption.AllDirectories)
- .Select(f => f.FullName)
- .Where(f => !f.StartsWith('.'));
+ return fileSystem.Directory.EnumerateFileSystemEntries(path, searchPattern, _findFilesOptions);
}
}
\ No newline at end of file
diff --git a/src/RepoM.App/MainWindow.xaml.cs b/src/RepoM.App/MainWindow.xaml.cs
index 847fec59..8fa3e373 100644
--- a/src/RepoM.App/MainWindow.xaml.cs
+++ b/src/RepoM.App/MainWindow.xaml.cs
@@ -282,15 +282,7 @@ private async Task LstRepositoriesContextMenuOpeningAsync(ContextMenu ctxM
items.Add(new Separator());
}
}
- else if (action is DeferredSubActionsUserInterfaceRepositoryAction deferredAction)
- {
- Control? controlItem = CreateMenuItemNewStyleAsync(action, vm);
- if (controlItem != null)
- {
- items.Add(controlItem);
- }
- }
- else if (action is UserInterfaceRepositoryAction uiAction)
+ else if (action is DeferredSubActionsUserInterfaceRepositoryAction or UserInterfaceRepositoryAction)
{
Control? controlItem = CreateMenuItemNewStyleAsync(action, vm);
if (controlItem != null)
diff --git a/tests/RepoM.ActionMenu.Core.Tests/ActionMenu/Context/FileFunctionsTests.cs b/tests/RepoM.ActionMenu.Core.Tests/ActionMenu/Context/FileFunctionsTests.cs
index 69587aad..48006036 100644
--- a/tests/RepoM.ActionMenu.Core.Tests/ActionMenu/Context/FileFunctionsTests.cs
+++ b/tests/RepoM.ActionMenu.Core.Tests/ActionMenu/Context/FileFunctionsTests.cs
@@ -35,21 +35,18 @@ public FileFunctionsTests()
public void FindFiles_ShouldReturnEmpty_WhenNoFilesFound()
{
// arrange
- var path = "my-path";
- var search = "my-search";
- var files = Array.Empty();
- IDirectoryInfo di = A.Fake();
- A.CallTo(() => _fileSystem.DirectoryInfo.New(path)).Returns(di);
- A.CallTo(() => di.EnumerateFileSystemInfos(search, SearchOption.AllDirectories))
- .Returns(files);
+ const string PATH = "my-path";
+ const string SEARCH = "my-search";
+ A.CallTo(() => _fileSystem.Directory.EnumerateFileSystemEntries(PATH, SEARCH, A._))
+ .Returns(Array.Empty());
// act
- IEnumerable result = Sut.FindFilesInner(_context, _span, path, search);
+ IEnumerable result = Sut.FindFilesInner(_context, _span, PATH, SEARCH);
// assert
result.Should().BeEquivalentTo(Array.Empty());
- A.CallTo(() => _fileSystem.DirectoryInfo.New(path)).MustHaveHappenedOnceExactly();
- A.CallTo(() => di.EnumerateFileSystemInfos(search, SearchOption.AllDirectories)).MustHaveHappenedOnceExactly();
+ A.CallTo(() => _fileSystem.Directory.EnumerateFileSystemEntries(PATH, SEARCH, A._))
+ .MustHaveHappenedOnceExactly();
}
[Theory]