mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-03-05 06:32:51 +01:00
Updates to block caret in insert mode
This commit is contained in:
parent
60bc936cd9
commit
7a164d6d5f
src/com/maddyhome/idea/vim
test/org/jetbrains/plugins/ideavim/action/change/insert
@ -319,7 +319,7 @@ public class KeyHandler {
|
||||
}
|
||||
}
|
||||
reset(editor);
|
||||
ChangeGroup.resetCaret(editor, VimPlugin.getEditor().isBarCursor());
|
||||
ChangeGroup.resetCaret(editor, false);
|
||||
}
|
||||
|
||||
private boolean handleKeyMapping(final @NotNull Editor editor,
|
||||
|
@ -27,9 +27,11 @@ import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.editor.event.CaretEvent;
|
||||
import com.intellij.openapi.editor.event.CaretListener;
|
||||
import com.intellij.openapi.editor.ex.EditorGutterComponentEx;
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.maddyhome.idea.vim.KeyHandler;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.group.visual.VisualGroupKt;
|
||||
import com.maddyhome.idea.vim.helper.*;
|
||||
import com.maddyhome.idea.vim.option.OptionChangeListener;
|
||||
import com.maddyhome.idea.vim.option.OptionsManager;
|
||||
@ -204,8 +206,8 @@ public class EditorGroup implements PersistentStateComponent<Element> {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBarCursor() {
|
||||
return !isBlockCursor;
|
||||
public boolean isBarCursorSettings() {
|
||||
return !EditorSettingsExternalizable.getInstance().isBlockCursor();
|
||||
}
|
||||
|
||||
public void editorCreated(@NotNull Editor editor) {
|
||||
@ -222,7 +224,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) || isBlockCursor);
|
||||
VisualGroupKt.resetShape(CommandStateHelper.getMode(editor), editor);
|
||||
editor.getSettings().setRefrainFromScrolling(REFRAIN_FROM_SCROLLING_VIM_VALUE);
|
||||
}
|
||||
|
||||
|
@ -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, VimPlugin.getEditor().isBarCursor)
|
||||
CommandState.Mode.SELECT, CommandState.Mode.INSERT -> ChangeGroup.resetCaret(editor, VimPlugin.getEditor().isBarCursorSettings)
|
||||
CommandState.Mode.CMD_LINE, CommandState.Mode.OP_PENDING -> Unit
|
||||
}
|
||||
|
||||
|
@ -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, VimPlugin.getEditor().isBarCursor)
|
||||
ChangeGroup.resetCaret(e.editor, true)
|
||||
}
|
||||
}
|
||||
if (mouseDragging && e.editor.caretModel.primaryCaret.hasSelection()) {
|
||||
ChangeGroup.resetCaret(e.editor, VimPlugin.getEditor().isBarCursor)
|
||||
ChangeGroup.resetCaret(e.editor, true)
|
||||
|
||||
if (!cutOffFixed && ComponentMouseListener.cutOffEnd) {
|
||||
cutOffFixed = true
|
||||
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2020 The IdeaVim authors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.change.insert
|
||||
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
|
||||
class InsertBeforeCursorActionTest : VimTestCase() {
|
||||
fun `test check caret shape`() {
|
||||
doTest("i", "123", "123", CommandState.Mode.INSERT, CommandState.SubMode.NONE)
|
||||
assertFalse(myFixture.editor.settings.isBlockCursor)
|
||||
}
|
||||
|
||||
fun `test check caret shape for block caret`() {
|
||||
EditorSettingsExternalizable.getInstance().isBlockCursor = true
|
||||
try {
|
||||
doTest("i", "123", "123", CommandState.Mode.INSERT, CommandState.SubMode.NONE)
|
||||
assertTrue(myFixture.editor.settings.isBlockCursor)
|
||||
} finally {
|
||||
EditorSettingsExternalizable.getInstance().isBlockCursor = false
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user