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

ScriptEditor: possible to have the same script open multiple times #67705

Open
alazifk opened this issue Oct 21, 2022 · 2 comments
Open

ScriptEditor: possible to have the same script open multiple times #67705

alazifk opened this issue Oct 21, 2022 · 2 comments

Comments

@alazifk
Copy link

alazifk commented Oct 21, 2022

Godot version

4.0 Beta3

System information

Windows 10

Issue description

It is possible to open the same script multiple times in the script editor. This results in a reappearing "The file on disk is newer"-warning until the duplicate scripts are closed.

Capture
(identical file names except upper and lower case. Windows does not really separate between upper and lower case)

I think there needs to be a check earlier on if the file paths are identical (when converted to lower case). If only the case is different one option is to flat out ignore the rename (because of Windows and like Windows does). The - I imagine - safest other option would be to rename the path automatically first to an intermediate path, also to make sure that Windows renames folders correctly.

The following code in dir_access_windows.cpp seems relevant:

// If we're only changing file name case we need to do a little juggling
	if (p_path.to_lower() == p_new_path.to_lower()) {
		if (dir_exists(p_path)) {
			// The path is a dir; just rename   <== (me: there probably needs to happen some juggling here)
			return ::_wrename((LPCWSTR)(p_path.utf16().get_data()), (LPCWSTR)(p_new_path.utf16().get_data())) == 0 ? OK : FAILED;
		}
		// The path is a file; juggle
		WCHAR tmpfile[MAX_PATH];

I also think there needs to be an OS independent check earlier. IMHO it should not be possible on any OS to have file paths that differ only in case in order to enforce portability.

Steps to reproduce

The first three steps have already been done in minimal reproduction project.
(

  1. create "X/X.tscn" and "X/X.gd"

  2. apply X.gd to the root of X.tscn and save

  3. open the script
    )

  4. Rename the folder "X" to "x", this will result in an error but temporarily create the folder.
    You should now have "x/X.gd" and "X/X.gd" open inside the script editor.

Minimal reproduction project

RenameBug.zip
Renaming the folder "X" to "x" should be enough to trigger the bug. This only seems to work the first time and is probably a Windows specific bug.

@alazifk
Copy link
Author

alazifk commented Oct 26, 2022

Related to: #22475
May be closed by: #52189

@TheSofox
Copy link
Contributor

TheSofox commented Apr 5, 2024

Came across this issue while fixing #76021
It also affects Scenes:

320120003-bdab0a92-fc03-417d-acb1-f056ad6ea482
320120112-c62139a4-940d-4f6a-8173-eec2cacb7460

I was able to reproduce it just by renaming folders in the OS (Windows) file manager. My bug fix stops folder duplication, but not having the same file opened multiple times.

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

No branches or pull requests

3 participants