Make extensions case insensitive on linux

This commit is contained in:
Simon Gellis 2026-08-15 00:11:37 -04:00
parent 644e99c295
commit 4f3dc85bb4
No known key found for this signature in database
GPG Key ID: DA576912FED9577B
1 changed files with 18 additions and 0 deletions

View File

@ -1,4 +1,5 @@
use std::{
fmt::Write as _,
path::PathBuf,
sync::{Arc, Weak},
};
@ -49,6 +50,23 @@ pub struct FileDialogBuilder {
impl FileDialogBuilder {
pub fn add_filter(self, name: impl Into<String>, extensions: &[impl ToString]) -> Self {
#[cfg(target_os = "linux")]
let exts = extensions
.iter()
.map(|ext| {
let mut normalized = String::new();
for char in ext.to_string().chars() {
if char.is_ascii_lowercase() {
let _ = write!(&mut normalized, "[{char}{}]", char.to_ascii_uppercase());
} else {
normalized.push(char);
}
}
normalized
})
.collect::<Vec<_>>();
#[cfg(target_os = "linux")]
let extensions = &exts;
Self {
dialog: self.dialog.add_filter(name, extensions),
..self