Skip to content

Commit a0bac9e

Browse files
committed
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.
1 parent 75f69db commit a0bac9e

File tree

1 file changed

+6
-1
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets

1 file changed

+6
-1
lines changed

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/FileDialog.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@ private NSString appendSelectedExtension (NSString filename) {
144144
NSString ext = filename.pathExtension();
145145
if (ext == null || ext.length() == 0) {
146146
filename = filename.stringByAppendingPathExtension(NSString.stringWith(extension));
147-
}
147+
}else if (!ext.getString().equalsIgnoreCase(extension)) {
148+
NSString originalName = filename.stringByDeletingPathExtension();
149+
NSString newFilename = originalName.stringByAppendingPathExtension(NSString.stringWith(extension));
150+
filename = newFilename;
151+
152+
}
148153
}
149154
return filename;
150155
}

0 commit comments

Comments
 (0)