Skip to content

Commit

Permalink
Fixes #237 Remember file extension in export dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
krasa committed Apr 20, 2020
1 parent 308ba15 commit 6d83094
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ul>
<li>PlantUml library upgrade to v1.2020.7</li>
<li>Render URL links fix</li>
<li>Remember file extension in export dialog</li>
</ul>
<p>2.23</p>
<ul>
Expand Down
11 changes: 9 additions & 2 deletions src/org/plantuml/idea/action/AbstractSaveDiagramAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileWrapper;
import com.intellij.util.ArrayUtil;
import com.intellij.util.PathUtilRt;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -102,7 +103,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
lastDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(parentDir);
logger.info("lastDir set to " + lastDir);
}

String[] tokens = file.getAbsolutePath().split("\\.(?=[^\\.]+$)");
String base = tokens[0];
String extension;
Expand All @@ -113,7 +114,13 @@ public void actionPerformed(@NotNull AnActionEvent e) {
} else {
extension = tokens[1];
}

for (int i = 0; i < extensions.length; i++) {
String s = extensions[i];
if (s.equals(extension)) {
ArrayUtil.swap(extensions, 0, i);
break;
}
}

PlantUml.ImageFormat imageFormat;
try {
Expand Down

1 comment on commit 6d83094

@uhafner
Copy link

Choose a reason for hiding this comment

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

I'm not sure if I am doing something wrong but that does not work in IntelliJ 2020.1 and 2.25.2.

Steps to reproduce:

  • Click Save Button in PlantUml
  • IntelliJ offers a Dialog with diagram.png
  • Change Name to diagram.svg
  • Press Save
  • IntelliJ Correctly saves to diagram.svg and closes the dialog
  • Click Save Button again
  • IntelliJ still offers a Dialog with diagram.png

Expected:

  • IntelliJ offers now a Dialog with diagram.svg

Please sign in to comment.