Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fixed an issue with drag and dropping items onto .py files #13986

Merged
merged 6 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 5 additions & 2 deletions src/Files.App/Helpers/Navigation/NavigationHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,11 @@ private static async Task<FilesystemResult> OpenFile(string path, IShellPage ass
// Now launch file with options.
var storageItem = (StorageFile)await FilesystemTasks.Wrap(() => childFile.Item.ToStorageFileAsync().AsTask());

if (storageItem is not null)
launchSuccess = await Launcher.LaunchFileAsync(storageItem, options);
if (!FileExtensionHelpers.IsPythonFile(storageItem.Path))
{
if (storageItem is not null)
yaira2 marked this conversation as resolved.
Show resolved Hide resolved
launchSuccess = await Launcher.LaunchFileAsync(storageItem, options);
}
}

if (!launchSuccess)
Expand Down
15 changes: 13 additions & 2 deletions src/Files.Shared/Helpers/FileExtensionHelpers.cs
yaira2 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ public static bool IsShortcutOrUrlFile(string? filePathToCheck)
/// </summary>
/// <param name="filePathToCheck">The file path to check.</param>
/// <returns><c>true</c> if the filePathToCheck is an executable file; otherwise, <c>false</c>.</returns>
/// /// <remarks>Executable file types are; exe, bat, cmd</remarks>
/// /// <remarks>Executable file types are; exe, bat, cmd, py</remarks>
public static bool IsExecutableFile(string? filePathToCheck, bool exeOnly = false)
{
return
exeOnly
? HasExtension(filePathToCheck, ".exe")
: HasExtension(filePathToCheck, ".exe", ".bat", ".cmd");
: HasExtension(filePathToCheck, ".exe", ".bat", ".cmd", ".py");
}

antonioseet marked this conversation as resolved.
Show resolved Hide resolved
/// <summary>
Expand Down Expand Up @@ -206,5 +206,16 @@ public static bool IsCertificateFile(string? filePathToCheck)
{
return HasExtension(filePathToCheck, ".cer", ".crt", ".der", ".pfx");
}

/// <summary>
/// Check if the file extension is a Python file.
/// </summary>
/// <param name="filePathToCheck"></param>
/// <returns><c>true</c> if the filePathToCheck is a python file; otherwise, <c>false</c>.</returns>
public static bool IsPythonFile(string? filePathToCheck)
{
return HasExtension(filePathToCheck, ".py");
}

}
}