mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-03-01 22:46:01 +01:00
Remove editor selection after undo
This commit is contained in:
parent
f0c234a5de
commit
13fc780287
@ -20,6 +20,8 @@ package com.maddyhome.idea.vim.helper;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.command.undo.UndoManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -28,13 +30,16 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author oleg
|
||||
*/
|
||||
public class UndoRedoHelper {
|
||||
|
||||
public static boolean undo(@NotNull final DataContext context) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(context);
|
||||
final FileEditor fileEditor = PlatformDataKeys.FILE_EDITOR.getData(context);
|
||||
final com.intellij.openapi.command.undo.UndoManager undoManager = com.intellij.openapi.command.undo.UndoManager.getInstance(project);
|
||||
final UndoManager undoManager = UndoManager.getInstance(project);
|
||||
if (fileEditor != null && undoManager.isUndoAvailable(fileEditor)) {
|
||||
undoManager.undo(fileEditor);
|
||||
final Editor editor = PlatformDataKeys.EDITOR.getData(context);
|
||||
if (editor != null) {
|
||||
editor.getSelectionModel().removeSelection();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -43,11 +48,12 @@ public class UndoRedoHelper {
|
||||
public static boolean redo(@NotNull final DataContext context) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(context);
|
||||
final FileEditor fileEditor = PlatformDataKeys.FILE_EDITOR.getData(context);
|
||||
final com.intellij.openapi.command.undo.UndoManager undoManager = com.intellij.openapi.command.undo.UndoManager.getInstance(project);
|
||||
final UndoManager undoManager = UndoManager.getInstance(project);
|
||||
if (fileEditor != null && undoManager.isRedoAvailable(fileEditor)) {
|
||||
undoManager.redo(fileEditor);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user