Make `FileDialog` filtering case insensitive
When using FileDialog to save files on non-case-sensitive file systems (Windows and often macOS), a file may have an uppercase file extension ( file.TXT ) but the filter is set as lowercase ( *.txt ; Text Files ). The FileDialog will list the file but selecting it to overwrite will not detect that the file matches the filter and append the lowercase extension after the existing uppercase file extension and would result in the selected file being file.TXT.txt
As most other operating systems can be case sensitive, my suggestion is to add a CaseSensitivity enum with the values of True, False and OS Default to the FileDialog for toggling between using f.match(str) and f.matchn(str) in the checks which would allow it to either be explicit based on the developer intent or implicit based on the standard of the operating system.
Currently if OS Default is used then the code uses a case-sensitive check if the OS is not Windows or macOS. Is there a better approach for this? Are there any other supported OS's are not case-sensitive by default?
Attached is an MRP similar to the one provided in the issue, with the addition of an OptionButton for changing between the CaseSensitivity setting when running the project. FileDialogCaseSensitivity.zip
Fixes #85788
You also need to register these enums in _bind_methods, see the other ones
You also need to document these methods, use --doctool, see here
You also need to document these methods, use
--doctool, see here
I've updated the doc xml now, is this correct? ~~The --doctool tool didn't generate any additional entries in it for the enum or methods.~~ my mistake, I must have run it against the wrong exe, it fixed up the incorrect default when I re-ran it.
Documentation isn't my forte so the wording might need tweaking.
I noticed a merge conflict, so I've rebased and resolved it.
It looks like one of the tests failed due to a ubuntu keyserver issue. Could a maintainer request a rerun of the failed test?
I appologise if the ping is innapropriate, but Yuri also requested requested @bruvzg to re-review the PR in December. Is there anything else which needs to be done before it can be approved for merging?
Tested locally on Linux (on a case-sensitive filesystem), I'm a bit confused about the behavior. The only behavior that seems desirable to me here is the one where case sensitive is set to False:
https://github.com/godotengine/godot/assets/180032/78d912ea-1b03-4c26-bcb4-f364bfacbac9
Otherwise, you get a double extension appended. Is there a point for keeping case sensitive True (and OS Default on case-sensitive filesystems)?
Also, the file filter is always case-insensitive regardless of this option, but I guess that's expected.
That behaviour looks as expected. Having the option for true and OS Default is so it doesn't break anything which might be reliant on a case sensitive file picking for whatever reason. I agree, having it set to false is the desirable option in all the use cases I could think of but I didn't feel comfortable making that assumption for everyone, hence having the option and defaulting to match the OS's case sensitivity.
The file filter was case insensitive for listing the files in the dialog originally, it was just the functionality of the detecting the extension on the selected filename and appending if it was missing which wasn't case insensitive, which resulted in the doubling of the file extension.
I could remove the setting and just make this always be case insensitive, or I could have it default to false and leave the option for the rare situtation it might be wanted? I'm open to whichever option is most suitable.
IMO this makes sense. The change only affects extension checking and I don't see why would you care about extension casing and make a double extension, like currently happens on mismatch.
The same change should be done in EditorFileDialog.
IMO this makes sense. The change only affects extension checking and I don't see why would you care about extension casing and make a double extension, like currently happens on mismatch.
The same change should be done in EditorFileDialog.
Good shout, I've added the change to EditorFileDialog too, I also noticed FileDialog::_native_dialog_cb needed the change too so I've dropped it in there.
Needs to be squashed into 1 commit.
Commits squashed 👍
Thanks! And congrats for your first merged Godot contribution :tada: