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

After failed file creation due to "A resource exists with a different case", wizard still tries to open non-existant File #1866

Open
2 tasks done
jwflicker opened this issue Apr 29, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jwflicker
Copy link

jwflicker commented Apr 29, 2024

  • I verified I can reproduce this issue against [latest Integration Build of Eclipse SDK]Eclipse IDE for Java Developers (includes Incubating components)

Steps to reproduce

From a fresh installation and clean workspace:

  1. From Package Explorer (or any explorer)
  2. Crdate a new general project using menu New > Project and select General > Project.
  3. Select that general project and from its context menu select New -> File
  4. Create file "abc.txt" in that project.
  5. Again, select that general project and from its context menu select New -> File
  6. Create file "ABC.txt" in that project. (Same file name, different casing)
  7. You will see an error dialog with message: "A resource exists with a different case: '/project/abc.txt'"
  8. After pression OK on the error dialog, the IDE will then still attempt to open that non-existant file in an Editor.
  9. Depending on the file extension, it may open the existing file with matching name in a System Editor, other times it will try to open the non-existant file in an internal editor so that the editor just displays the error message: Resource '/project/ABC.txt' does not exist

I expected: that it would not try to open an editor to the file name that could not be created due to a an existing file with similar name but in a different case.

But got: Sometimes an extenral system editor open on the 'wrong' file, sometimes an internal editor w/ the Resource not found eror.

Here is some relevant source code

BasicNewFileResourceWizard:

	@Override
	public boolean performFinish() {
		IFile file = mainPage.createNewFile();
		if (file == null) {
			return false;
		}

mainPage.createNewFile() will trigger the display of the error message dialog showing "A resource exists with a different case", but it will return a non-null File object whose .exists() method would return false, but is not checked before invoking IDE.openEditor(page, file, true); just below

within WizardNewFileCreationPage.createNewFile() method, the error is caught and thrown here... but nothing is done to cause a return of null:
https://github.com/eclipse-platform/eclipse.platform.ui/blob/master/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewFileCreationPage.java#L409

Tested under this environment:

  • Version: 2024-03 (4.31.0)
  • Build id: 20240307-1437
  • OS: Mac OS X, v.14.4.1, x86_64 / cocoa
  • Java vendor: Eclipse Adoptium
  • Java runtime version: 17.0.10+7
  • Java version: 17.0.10

Community

  • I understand reporting an issue to this OSS project does not mandate anyone to fix it. Other contributors may consider the issue, or not, at their own convenience. The most efficient way to get it fixed is that I fix it myself and contribute it back as a good quality patch to the project.
@jwflicker jwflicker added the bug Something isn't working label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant