1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-08-17 16:31:45 +02:00

Compare commits

...

7 Commits

Author SHA1 Message Date
Alex Plate
e89e0466eb Prepare for 0.60 release 2020-10-09 11:24:48 +02:00
Alex Plate
c9d0d7aef6 [VIM-2140] Downgrade java version to 1.8 2020-10-09 11:06:38 +02:00
Alex Plate
90c7d5a74a Update gradle to 6.6.1 2020-10-09 10:30:41 +02:00
Alex Plate
b19e11b5b6 Use proper access syntax 2020-10-09 10:16:30 +02:00
Alex Plate
2d002c044d Report if time for calculation of isIdeaVimDisabledHere take more than 10ms 2020-10-08 11:39:49 +02:00
Alex Plate
9a7b2bd158 Update the implementation of disabled IdeaVim editors 2020-10-08 11:25:47 +02:00
Alex Plate
461c874de6 Reformat some code 2020-10-08 10:31:21 +02:00
14 changed files with 60 additions and 35 deletions

View File

@@ -22,7 +22,7 @@ It is important to distinguish EAP from traditional pre-release software.
Please note that the quality of EAP versions may at times be way below even Please note that the quality of EAP versions may at times be way below even
usual beta standards. usual beta standards.
To Be Released 0.60, 2020-10-09
----------- -----------
**Features:** **Features:**

View File

@@ -120,7 +120,7 @@ The following `:set` commands can appear in `~/.ideavimrc` or be set manually in
- gray - use the gray version of the icon - gray - use the gray version of the icon
- disabled - hide the icon - disabled - hide the icon
`ideawrite` `ideawrite` String (default "all") [To Be Released] `ideawrite` `ideawrite` String (default "all")
"file" or "all". Defines the behaviour of ":w" command. "file" or "all". Defines the behaviour of ":w" command.
Value "all" enables execution of ":wa" (save all) command on ":w" (save). Value "all" enables execution of ":wa" (save all) command on ":w" (save).
This feature exists because some IJ options like "Prettier on save" or "ESlint on save" This feature exists because some IJ options like "Prettier on save" or "ESlint on save"

View File

@@ -4,7 +4,7 @@ ideaVersion=LATEST-EAP-SNAPSHOT
downloadIdeaSources=true downloadIdeaSources=true
instrumentPluginCode=true instrumentPluginCode=true
version=SNAPSHOT version=SNAPSHOT
javaVersion=11 javaVersion=1.8
kotlinVersion=1.3.71 kotlinVersion=1.3.71
publishUsername=username publishUsername=username
publishToken=token publishToken=token

Binary file not shown.

View File

@@ -1,6 +1,5 @@
#Thu Jun 25 19:36:41 MSK 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2
gradlew vendored
View File

@@ -82,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"` JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath # We build the pattern for arguments to be converted via cygpath

1
gradlew.bat vendored
View File

@@ -84,6 +84,7 @@ set CMD_LINE_ARGS=%*
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

View File

@@ -123,8 +123,9 @@ class VimShortcutKeyAction : AnAction(), DumbAware {
} }
private fun isEnabledForEscape(editor: Editor): Boolean { private fun isEnabledForEscape(editor: Editor): Boolean {
return (editor.isPrimaryEditor() || EditorHelper.isFileEditor(editor) && !editor.inNormalMode) || return editor.isPrimaryEditor()
(OptionsManager.dialogescape.value == "on" && !editor.inNormalMode) || EditorHelper.isFileEditor(editor) && !editor.inNormalMode
|| OptionsManager.dialogescape.value == "on" && !editor.inNormalMode
} }
private fun isShortcutConflict(keyStroke: KeyStroke): Boolean { private fun isShortcutConflict(keyStroke: KeyStroke): Boolean {

View File

@@ -130,7 +130,7 @@ public class FileGroup {
return res; return res;
} }
final Ref<VirtualFile> result = Ref.create(); final Ref<VirtualFile> result = Ref.create();
final VirtualFileVisitor<Object> visitor = new VirtualFileVisitor<>() { final VirtualFileVisitor<Object> visitor = new VirtualFileVisitor<Object>() {
@Override @Override
public boolean visitFile(@NotNull VirtualFile file) { public boolean visitFile(@NotNull VirtualFile file) {
if (file.getName().equals(filename)) { if (file.getName().equals(filename)) {

View File

@@ -32,6 +32,7 @@ import com.maddyhome.idea.vim.helper.inInsertMode
import com.maddyhome.idea.vim.helper.inNormalMode import com.maddyhome.idea.vim.helper.inNormalMode
import com.maddyhome.idea.vim.helper.inSelectMode import com.maddyhome.idea.vim.helper.inSelectMode
import com.maddyhome.idea.vim.helper.inVisualMode import com.maddyhome.idea.vim.helper.inVisualMode
import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere
import com.maddyhome.idea.vim.helper.isTemplateActive import com.maddyhome.idea.vim.helper.isTemplateActive
import com.maddyhome.idea.vim.helper.mode import com.maddyhome.idea.vim.helper.mode
import com.maddyhome.idea.vim.helper.popAllModes import com.maddyhome.idea.vim.helper.popAllModes
@@ -52,6 +53,8 @@ object IdeaSelectionControl {
fun controlNonVimSelectionChange(editor: Editor, selectionSource: VimListenerManager.SelectionSource = VimListenerManager.SelectionSource.OTHER) { fun controlNonVimSelectionChange(editor: Editor, selectionSource: VimListenerManager.SelectionSource = VimListenerManager.SelectionSource.OTHER) {
VimVisualTimer.singleTask(editor.mode) { initialMode -> VimVisualTimer.singleTask(editor.mode) { initialMode ->
if (editor.isIdeaVimDisabledHere) return@singleTask
logger.info("Adjust non-vim selection. Source: $selectionSource") logger.info("Adjust non-vim selection. Source: $selectionSource")
// Perform logic in one of the next cases: // Perform logic in one of the next cases:

View File

@@ -736,7 +736,7 @@ public class EditorHelper {
// a visual position). If it is an inlay and is related to preceding text, we want to display it, so use it as the // a visual position). If it is an inlay and is related to preceding text, we want to display it, so use it as the
// target column. If it's an inlay related to following text, we don't want to display it at the right of the // target column. If it's an inlay related to following text, we don't want to display it at the right of the
// screen, show the previous column // screen, show the previous column
var inlay = editor.getInlayModel().getInlineElementAt(new VisualPosition(visualLine, visualColumn)); Inlay inlay = editor.getInlayModel().getInlineElementAt(new VisualPosition(visualLine, visualColumn));
if (inlay != null && !inlay.isRelatedToPrecedingText()) { if (inlay != null && !inlay.isRelatedToPrecedingText()) {
targetVisualColumn = visualColumn - 1; targetVisualColumn = visualColumn - 1;
} }

View File

@@ -20,13 +20,15 @@
package com.maddyhome.idea.vim.helper package com.maddyhome.idea.vim.helper
import com.intellij.ide.scratch.ScratchFileService import com.intellij.ide.ui.laf.darcula.DarculaUIUtil
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.editor.Caret import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.VisualPosition import com.intellij.openapi.editor.VisualPosition
import com.intellij.openapi.editor.ex.util.EditorUtil import com.intellij.openapi.editor.ex.util.EditorUtil
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
import com.maddyhome.idea.vim.option.OptionsManager import com.maddyhome.idea.vim.option.OptionsManager
import kotlin.system.measureTimeMillis
val Editor.fileSize: Int val Editor.fileSize: Int
get() = document.textLength get() = document.textLength
@@ -36,13 +38,21 @@ val Editor.fileSize: Int
* So, we should enable IdeaVim for such editors and disable it on the first interaction * So, we should enable IdeaVim for such editors and disable it on the first interaction
*/ */
val Editor.isIdeaVimDisabledHere: Boolean val Editor.isIdeaVimDisabledHere: Boolean
get() = (isOneLineMode || disabledForThisEditor) && !OptionsManager.oneline.isSet get() {
var res = true
val Editor.disabledForThisEditor: Boolean val timeForCalculation = measureTimeMillis {
get() = isDatabaseCell || disabledInDialog res = (disabledInDialog
|| isDatabaseCell && !OptionsManager.oneline.isSet
|| isOneLineMode && !OptionsManager.oneline.isSet)
}
if (timeForCalculation > 10) {
logger<Editor>().error("Time for calculation of 'isIdeaVimDisabledHere' took $timeForCalculation ms.")
}
return res
}
private val Editor.isDatabaseCell: Boolean private val Editor.isDatabaseCell: Boolean
get() = ScratchFileService.findRootType(EditorHelper.getVirtualFile(this))?.id == "consoles/.datagrid" get() = DarculaUIUtil.isTableCellEditor(this.component)
private val Editor.disabledInDialog: Boolean private val Editor.disabledInDialog: Boolean
get() = OptionsManager.dialogescape.value == "off" && (!this.isPrimaryEditor() && !EditorHelper.isFileEditor(this)) get() = OptionsManager.dialogescape.value == "off" && (!this.isPrimaryEditor() && !EditorHelper.isFileEditor(this))
@@ -64,6 +74,6 @@ val Caret.amountOfInlaysBeforeCaret: Int
fun Editor.amountOfInlaysBeforeVisualPosition(pos: VisualPosition): Int { fun Editor.amountOfInlaysBeforeVisualPosition(pos: VisualPosition): Int {
val newOffset = EditorHelper.visualPositionToOffset(this, pos) val newOffset = EditorHelper.visualPositionToOffset(this, pos)
val lineStartNewOffset: Int = this.getDocument().getLineStartOffset(this.visualToLogicalPosition(pos).line) val lineStartNewOffset: Int = this.document.getLineStartOffset(this.visualToLogicalPosition(pos).line)
return this.getInlayModel().getInlineElementsInRange(lineStartNewOffset, newOffset).size return this.inlayModel.getInlineElementsInRange(lineStartNewOffset, newOffset).size
} }

View File

@@ -49,8 +49,21 @@ import com.maddyhome.idea.vim.group.EditorGroup
import com.maddyhome.idea.vim.group.FileGroup import com.maddyhome.idea.vim.group.FileGroup
import com.maddyhome.idea.vim.group.MotionGroup import com.maddyhome.idea.vim.group.MotionGroup
import com.maddyhome.idea.vim.group.SearchGroup import com.maddyhome.idea.vim.group.SearchGroup
import com.maddyhome.idea.vim.group.visual.* import com.maddyhome.idea.vim.group.visual.IdeaSelectionControl
import com.maddyhome.idea.vim.helper.* import com.maddyhome.idea.vim.group.visual.VimVisualTimer
import com.maddyhome.idea.vim.group.visual.moveCaretOneCharLeftFromSelectionEnd
import com.maddyhome.idea.vim.group.visual.vimSetSystemSelectionSilently
import com.maddyhome.idea.vim.helper.EditorHelper
import com.maddyhome.idea.vim.helper.StatisticReporter
import com.maddyhome.idea.vim.helper.exitSelectMode
import com.maddyhome.idea.vim.helper.exitVisualMode
import com.maddyhome.idea.vim.helper.inSelectMode
import com.maddyhome.idea.vim.helper.inVisualMode
import com.maddyhome.idea.vim.helper.isEndAllowed
import com.maddyhome.idea.vim.helper.isIdeaVimDisabledHere
import com.maddyhome.idea.vim.helper.moveToInlayAwareOffset
import com.maddyhome.idea.vim.helper.subMode
import com.maddyhome.idea.vim.helper.vimLastColumn
import com.maddyhome.idea.vim.listener.VimListenerManager.EditorListeners.add import com.maddyhome.idea.vim.listener.VimListenerManager.EditorListeners.add
import com.maddyhome.idea.vim.listener.VimListenerManager.EditorListeners.remove import com.maddyhome.idea.vim.listener.VimListenerManager.EditorListeners.remove
import com.maddyhome.idea.vim.option.OptionsManager import com.maddyhome.idea.vim.option.OptionsManager
@@ -139,8 +152,6 @@ object VimListenerManager {
fun add(editor: Editor) { fun add(editor: Editor) {
if (editor.disabledForThisEditor) return
editor.contentComponent.addKeyListener(VimKeyListener) editor.contentComponent.addKeyListener(VimKeyListener)
val eventFacade = EventFacade.getInstance() val eventFacade = EventFacade.getInstance()
eventFacade.addEditorMouseListener(editor, EditorMouseHandler) eventFacade.addEditorMouseListener(editor, EditorMouseHandler)
@@ -155,8 +166,6 @@ object VimListenerManager {
fun remove(editor: Editor, isReleased: Boolean) { fun remove(editor: Editor, isReleased: Boolean) {
if (editor.disabledForThisEditor) return
editor.contentComponent.removeKeyListener(VimKeyListener) editor.contentComponent.removeKeyListener(VimKeyListener)
val eventFacade = EventFacade.getInstance() val eventFacade = EventFacade.getInstance()
eventFacade.removeEditorMouseListener(editor, EditorMouseHandler) eventFacade.removeEditorMouseListener(editor, EditorMouseHandler)

View File

@@ -1,6 +1,6 @@
# Manual Tests # Manual Tests
## #1 [Last run: 2020-08-25] ## #1 [Last run: 2020-10-09]
_Initial mode:_ NORMAL _Initial mode:_ NORMAL
@@ -14,7 +14,7 @@ Word is selected, block-caret is placed on the word end (offset = `word end - 1`
![](resources/manualTests/1.png) ![](resources/manualTests/1.png)
## #2 [Last run: 2020-08-25] ## #2 [Last run: 2020-10-09]
_Initial mode:_ NORMAL _Initial mode:_ NORMAL
@@ -26,7 +26,7 @@ Last word is selected, block caret is placed on the word end without bouncing
![](resources/manualTests/2.png) ![](resources/manualTests/2.png)
## #3 [Last run: 2020-08-25] ## #3 [Last run: 2020-10-09]
_Initial mode:_ NORMAL _Initial mode:_ NORMAL
@@ -38,7 +38,7 @@ Line is selected. Caret is placed on the line end
![](resources/manualTests/3.png) ![](resources/manualTests/3.png)
## #4 [Last run: 2020-08-25] ## #4 [Last run: 2020-10-09]
_Initial mode:_ NORMAL _Initial mode:_ NORMAL
@@ -51,7 +51,7 @@ After mouse release, caret moves one character back and becomes block shape
![](resources/manualTests/4.gif) ![](resources/manualTests/4.gif)
## #5 [Last run: 2020-08-25] ## #5 [Last run: 2020-10-09]
_Initial mode:_ NORMAL _Initial mode:_ NORMAL
@@ -65,7 +65,7 @@ After mouse release, caret moves one character back and becomes block shape
![](resources/manualTests/5.gif) ![](resources/manualTests/5.gif)
## #6 [Last run: 2020-08-25] ## #6 [Last run: 2020-10-09]
_Initial mode:_ NORMAL _Initial mode:_ NORMAL
@@ -77,7 +77,7 @@ Line is selected, caret is on the first position
![](resources/manualTests/6.gif) ![](resources/manualTests/6.gif)
## #6 [Last run: 2020-08-25] ## #6 [Last run: 2020-10-09]
_Initial mode:_ NORMAL _Initial mode:_ NORMAL
@@ -94,7 +94,7 @@ Caret stays in _block_ shape with a normal mode
![](resources/manualTests/7.2.gif) ![](resources/manualTests/7.2.gif)
## #7 [Last run: 2020-08-25] ## #7 [Last run: 2020-10-09]
_Action:_ _Action:_
Turn emulation off and on Turn emulation off and on
@@ -102,7 +102,7 @@ Turn emulation off and on
_Result:_ _Result:_
Vim emulator works as expected Vim emulator works as expected
## #8 [Last run: 2020-08-25 ## #8 [Last run: 2020-10-09
_Action:_ _Action:_
Start up IJ with disabled emulator, turn it on Start up IJ with disabled emulator, turn it on
@@ -110,7 +110,7 @@ Start up IJ with disabled emulator, turn it on
_Result:_ _Result:_
Vim emulator works as expected Vim emulator works as expected
## #9 [Last run: 2020-08-25] ## #9 [Last run: 2020-10-09]
_Action:_ _Action:_
Wrap with if Wrap with if