dubreuia/intellij-plugin-save-actions

"save actions on save" is not work at Intellij 2021.3 (Ultimate Edition)

donguseo opened this issue · 7 comments

Describe the bug
After I upgrade my Intellij to 2021.3, "save actions on short cut(cmd + shift + s)" is working properly.
But "save actions on save(cmd + s)" is not work.

What triggered the plugin
cmd + s

Versions
IntelliJ IDEA 2021.3 (Ultimate Edition)
Build #IU-213.5744.223, built on November 27, 2021
Licensed to --------
Subscription is active until June 27, 2022.
Runtime version: 11.0.13+7-b1751.19 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 11.2.3
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 16
Non-Bundled Plugins:
google-java-format (1.13.0.0)
de.netnexus.camelcaseplugin (3.0.8)
com.mnw.tabmover (1.3.0)
com.markskelton.one-dark-theme (5.4.1)
com.intellij.plugins.vscodekeymap (213.5744.3)
net.ashald.envfile (3.2.2)
com.xstudio.com.xstudio.plugin.idea (1.0.13)
com.github.leomillon.uuidgenerator (4.5.1)
com.dubreuia (2.3.0)
com.4lex4.intellij.solarized (2.4.0)
ru.adelf.idea.dotenv (2021.3.0.213)
com.nvinayshetty.DTOnator (V0.997)
zielu.gittoolbox (212.8.4)

Kotlin: 213-1.5.10-release-949-IJ5744.223

@donguseo I cannot reproduce your issue. Since you are using vscodekeymap: Is cmd+s associated with File / save all?

@donguseo Save Actions Plugin is hooked into the save document action and not vice versa. Hence, "Save Actions" does not trigger the "Save document" but "Save document" triggers "save actions".

In your screenshot, you can see that you have a shortcut conflict for Command + S. Please click on the warning triangle symbol next to the pen to see which action is also associated to Command + S.

I noticed, that something has been changed in 2021.3 in terms of shortcut management. I my case another plugin was blocking Command + C for copy a file. That plugin was working without trouble in 2021.2.

One thing to notice. Save Actions will reformat your code on "File / Save All" if activated instead of "Other / Save Document".

It should look like this:
image

See:

@Override
public void beforeAllDocumentsSaving() {
LOGGER.debug("[+] Start SaveActionsDocumentManagerListener#beforeAllDocumentsSaving, " + project.getName());
List<Document> unsavedDocuments = Arrays.asList(FileDocumentManager.getInstance().getUnsavedDocuments());
if (!unsavedDocuments.isEmpty()) {
LOGGER.debug(String.format("Locating psi files for %d documents: %s", unsavedDocuments.size(), unsavedDocuments));
beforeDocumentsSaving(unsavedDocuments);
}
LOGGER.debug("End SaveActionsDocumentManagerListener#beforeAllDocumentsSaving");
}
public void beforeDocumentsSaving(List<Document> documents) {
if (project.isDisposed()) {
return;
}
Set<PsiFile> psiFiles = documents.stream()
.map(psiDocumentManager::getPsiFile)
.filter(Objects::nonNull)
.collect(Collectors.toSet());

One thing to notice. Save Actions will reformat your code on "File / Save All" if activated instead of "Other / Save Document".

It should look like this:
image

See:

@Override
public void beforeAllDocumentsSaving() {
LOGGER.debug("[+] Start SaveActionsDocumentManagerListener#beforeAllDocumentsSaving, " + project.getName());
List<Document> unsavedDocuments = Arrays.asList(FileDocumentManager.getInstance().getUnsavedDocuments());
if (!unsavedDocuments.isEmpty()) {
LOGGER.debug(String.format("Locating psi files for %d documents: %s", unsavedDocuments.size(), unsavedDocuments));
beforeDocumentsSaving(unsavedDocuments);
}
LOGGER.debug("End SaveActionsDocumentManagerListener#beforeAllDocumentsSaving");
}
public void beforeDocumentsSaving(List<Document> documents) {
if (project.isDisposed()) {
return;
}
Set<PsiFile> psiFiles = documents.stream()
.map(psiDocumentManager::getPsiFile)
.filter(Objects::nonNull)
.collect(Collectors.toSet());

Thank you.
your last comment solved my problem !

Great! Thanks for your feedback.

Could please mark your ticket as closed? I am not able to do since I am just a contributor.

Thank you for your help!