mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[formatter] IDEA-338921 fix inconsistent behaviour of undo/redo with "reindent file" action
The "reindent file" action is now also a named command. GitOrigin-RevId: fc497084f3b09b3896f82d036e6dea9f5dcec790
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9f573f31dc
commit
035a4cb296
+22
-3
@@ -15,6 +15,8 @@ import com.intellij.openapi.actionSystem.Separator;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.command.undo.BasicUndoableAction;
|
||||
import com.intellij.openapi.command.undo.UndoManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
@@ -215,8 +217,9 @@ public class DetectableIndentOptionsProvider extends FileIndentOptionsProvider {
|
||||
disableForFile(virtualFile, indentOptions);
|
||||
notifyIndentOptionsChanged(project, virtualFile);
|
||||
}));
|
||||
final var reindentActionText = ApplicationBundle.message("code.style.indent.detector.reindent", projectOptionsTip);
|
||||
actions.add(
|
||||
DumbAwareAction.create(ApplicationBundle.message("code.style.indent.detector.reindent", projectOptionsTip),
|
||||
DumbAwareAction.create(reindentActionText,
|
||||
e -> {
|
||||
disableForFile(virtualFile, indentOptions);
|
||||
final var document = FileDocumentManager.getInstance().getCachedDocument(virtualFile);
|
||||
@@ -228,9 +231,25 @@ public class DetectableIndentOptionsProvider extends FileIndentOptionsProvider {
|
||||
indentOptsWithoutDetected.associateWithDocument(document);
|
||||
}
|
||||
notifyIndentOptionsChanged(project, virtualFile);
|
||||
CommandProcessor.getInstance().runUndoTransparentAction(
|
||||
CommandProcessor.getInstance().executeCommand(
|
||||
project,
|
||||
() -> ApplicationManager.getApplication().runWriteAction(
|
||||
() -> CodeStyleManager.getInstance(project).adjustLineIndent(file, file.getTextRange()))
|
||||
() -> {
|
||||
CodeStyleManager.getInstance(project).adjustLineIndent(file, file.getTextRange());
|
||||
UndoManager.getInstance(project).undoableActionPerformed(new BasicUndoableAction() {
|
||||
@Override
|
||||
public void undo() {
|
||||
notifyIndentOptionsChanged(project, virtualFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redo() {
|
||||
notifyIndentOptionsChanged(project, virtualFile);
|
||||
}
|
||||
});
|
||||
}),
|
||||
reindentActionText,
|
||||
null
|
||||
);
|
||||
myDiscardedOptions.remove(virtualFile);
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user