Skip to content

fix: split shell exec pattern for terminal file picker on Windows - #2637

Open
weiningwei wants to merge 1 commit into
sourcegit-scm:developfrom
weiningwei:fix/shell-terminal-picker-pattern
Open

fix: split shell exec pattern for terminal file picker on Windows#2637
weiningwei wants to merge 1 commit into
sourcegit-scm:developfrom
weiningwei:fix/shell-terminal-picker-pattern

Conversation

@weiningwei

Copy link
Copy Markdown
Contributor

On Windows, the shell/terminal file picker in Preferences could not display pwsh.exe / powershell.exe when the user tried to manually select the PowerShell executable.

Root cause

ShellOrTerminal.Exec for PowerShell is "pwsh.exe|powershell.exe", using | as a separator for alternative executable names. The file picker (SelectShellOrTerminal in src/Views/Preferences.axaml.cs) passed the entire string as a single glob pattern to FilePickerFileType.Patterns:

Patterns = [shell.Exec]

Avalonia's Win32 implementation joins the patterns with ; and hands the result to the native file dialog, which treats | as a literal character rather than an alternative separator. Since no file is literally named pwsh.exe|powershell.exe, the dialog showed nothing in the target directory.

The other Windows terminals (bash.exe, cmd.exe, wt.exe) use a single executable name and are unaffected.

Fix

Split Exec on | so each alternative becomes its own pattern entry. For PowerShell this produces ["pwsh.exe", "powershell.exe"], which the Win32 dialog matches as pwsh.exe;powershell.exe.

Patterns = shell.Exec.Split('|', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)

No behavior change for terminals with a single executable name.

Comment on lines +344 to +348
FileTypeFilter = [new FilePickerFileType(shell.Name)
{
Patterns = shell.Exec.Split('|',
StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
}],

@Mingun Mingun Aug 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would beter to change shell.Exec type from String (?) to String[] if that possible.

Signed-off-by: weiningwei <weiningwei09@gmail.com>
@weiningwei
weiningwei force-pushed the fix/shell-terminal-picker-pattern branch from 84a3f02 to bff6e20 Compare August 19, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants