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

Prevent renaming to an unkown extension from FileSystem dock. #56847

Merged
merged 1 commit into from
Jan 17, 2022

Conversation

jmb462
Copy link
Contributor

@jmb462 jmb462 commented Jan 16, 2022

Fixes #56805

Issue description

Renaming a file in FileSystem dock to an unrecognized extension hides the file in editor.
No warning. Just a file that disapears. Can't be undone from editor FileSystem dock.

Fix proposal

Prevent doing such a thing because it is probably a mistake and it can't be undone from the editor which may be quite misleading.
Instead of renaming, show a warning explaining the situation.
Invite user to use system file explorer to do such a rename on purpose.

image

As english is not my native language, you are invited to provide me a better message if you think it's needed.

@jmb462 jmb462 requested a review from a team as a code owner January 16, 2022 18:18
@Calinou Calinou added bug cherrypick:3.4 cherrypick:3.x Considered for cherry-picking into a future 3.x release topic:editor usability labels Jan 16, 2022
@Calinou Calinou added this to the 4.0 milestone Jan 16, 2022
@akien-mga akien-mga added enhancement and removed bug labels Jan 17, 2022
editor/filesystem_dock.cpp Outdated Show resolved Hide resolved
@KoBeWi
Copy link
Member

KoBeWi commented Jan 17, 2022

I noticed that EditorFileSystem has a list of valid extensions. Maybe we could add a method to retrieve it, so it can be reused?

@jmb462
Copy link
Contributor Author

jmb462 commented Jan 17, 2022

I noticed that EditorFileSystem has a list of valid extensions. Maybe we could add a method to retrieve it, so it can be reused?

I've added a method : Set<String> EditorFileSystem::get_valid_extensions() const
It's just returning valid_extensions. As the list is updated in scan(), I'm not sure if we need to check if valid_extension is not empty and if empty, call _update_extensions().

The function is not exposed to GDScript. Don't know if it will be very usefull (plugins ?)

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

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

Looks good. The message might need tweaking though, CC @Calinou

As the list is updated in scan(), I'm not sure if we need to check if valid_extension is not empty and if empty, call _update_extensions().

AFAIK editor automatically scans on startup, so this is not a problem.

The function is not exposed to GDScript. Don't know if it will be very usefull (plugins ?)

No need to expose it for now.

editor/filesystem_dock.cpp Outdated Show resolved Hide resolved
@akien-mga akien-mga merged commit 780f5c0 into godotengine:master Jan 17, 2022
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

Cherry-picked for 3.5.

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Jan 19, 2022
@akien-mga
Copy link
Member

Cherry-picked for 3.4.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Renaming a script without a supported file extension, hides the script without a warning
4 participants