From d4c041e7fc9c2d9fb219bcd3ba609ab1a5f6c967 Mon Sep 17 00:00:00 2001 From: Elsa Zacharia Date: Mon, 13 Oct 2025 21:24:48 +0530 Subject: [PATCH] Fix the fileExtension issue in macOS. Currently if there is no file extension for the file, then only the new extension is getting appended; but there is no implementation if there is an extension already present for the file and the user wants to overwrite it; The PR is raised to include that condition too. --- .../cocoa/org/eclipse/swt/widgets/FileDialog.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FileDialog.java index 3f8f8c60537..7fb5b4a649e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FileDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FileDialog.java @@ -144,7 +144,12 @@ private NSString appendSelectedExtension (NSString filename) { NSString ext = filename.pathExtension(); if (ext == null || ext.length() == 0) { filename = filename.stringByAppendingPathExtension(NSString.stringWith(extension)); - } + }else if (!ext.getString().equalsIgnoreCase(extension)) { + NSString originalName = filename.stringByDeletingPathExtension(); + NSString newFilename = originalName.stringByAppendingPathExtension(NSString.stringWith(extension)); + filename = newFilename; + + } } return filename; }