1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-05-14 15:34:06 +02:00

VIM-1475: Respect the "use block caret" when in insert mode

The "use block caret" IDEA option controls the style of the cursor: when
it's enabled, the cursor is drawn as a block, and when it's disabled,
it's drawn as a bar. However, after installing IdeaVIM, this option
isn't respected; the plugin always uses a block cursor when in command
mode, and always uses a bar cursor when in insert mode.

This commit changes the behavior so that when the "use block caret"
option is enabled, IdeaVIM's insert mode uses a block cursor instead of
a bar cursor. The cursor in normal mode is always drawn as a block
cursor. If the "use block caret" option is disabled, the behavior is the
same as in previous versions of IdeaVIM (block cursor in normal mode,
bar cursor in insert mode).

Fixes VIM-1475 (on YouTrack)
This commit is contained in:
Grzegorz Antoniak 2020-11-16 20:14:18 +01:00 committed by Alex Pláte
parent 251e8e8ff4
commit 62c828d722
4 changed files with 9 additions and 5 deletions
src/com/maddyhome/idea/vim

View File

@ -325,7 +325,7 @@ public class KeyHandler {
}
}
reset(editor);
ChangeGroup.resetCaret(editor, false);
ChangeGroup.resetCaret(editor, VimPlugin.getEditor().isBarCursor());
}
private boolean handleKeyMapping(final @NotNull Editor editor,

View File

@ -203,6 +203,10 @@ public class EditorGroup implements PersistentStateComponent<Element> {
}
}
public boolean isBarCursor() {
return !isBlockCursor;
}
public void editorCreated(@NotNull Editor editor) {
isBlockCursor = editor.getSettings().isBlockCursor();
isRefrainFromScrolling = editor.getSettings().isRefrainFromScrolling();
@ -217,7 +221,7 @@ public class EditorGroup implements PersistentStateComponent<Element> {
VimPlugin.getChange().insertBeforeCursor(editor, new EditorDataContext(editor, null));
KeyHandler.getInstance().reset(editor);
}
editor.getSettings().setBlockCursor(!CommandStateHelper.inInsertMode(editor));
editor.getSettings().setBlockCursor(!CommandStateHelper.inInsertMode(editor) || isBlockCursor);
editor.getSettings().setRefrainFromScrolling(REFRAIN_FROM_SCROLLING_VIM_VALUE);
}

View File

@ -163,7 +163,7 @@ fun updateCaretState(editor: Editor) {
fun CommandState.Mode.resetShape(editor: Editor) = when (this) {
CommandState.Mode.COMMAND, CommandState.Mode.VISUAL, CommandState.Mode.REPLACE -> ChangeGroup.resetCaret(editor, false)
CommandState.Mode.SELECT, CommandState.Mode.INSERT -> ChangeGroup.resetCaret(editor, true)
CommandState.Mode.SELECT, CommandState.Mode.INSERT -> ChangeGroup.resetCaret(editor, VimPlugin.getEditor().isBarCursor)
CommandState.Mode.CMD_LINE, CommandState.Mode.OP_PENDING -> Unit
}

View File

@ -253,11 +253,11 @@ object VimListenerManager {
if (onLineEnd(caret)) {
// UX protection for case when user performs a small dragging while putting caret on line end
caret.removeSelection()
ChangeGroup.resetCaret(e.editor, true)
ChangeGroup.resetCaret(e.editor, VimPlugin.getEditor().isBarCursor)
}
}
if (mouseDragging && e.editor.caretModel.primaryCaret.hasSelection()) {
ChangeGroup.resetCaret(e.editor, true)
ChangeGroup.resetCaret(e.editor, VimPlugin.getEditor().isBarCursor)
if (!cutOffFixed && ComponentMouseListener.cutOffEnd) {
cutOffFixed = true