Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
lippfi committed Jan 28, 2024
2 parents 0137de5 + f4afdb2 commit 7769985
Show file tree
Hide file tree
Showing 24 changed files with 320 additions and 85 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/runUiOctopusTests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Run Non Octopus UI Tests
on:
workflow_dispatch:
schedule:
- cron: '0 12 * * *'
jobs:
build-for-ui-test-mac-os:
if: github.repository == 'JetBrains/ideavim'
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Apply Patch
run: |
git apply src/test/java/ui/octopus.patch
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
- name: Setup FFmpeg
uses: FedericoCarboni/setup-ffmpeg@v3
with:
# Not strictly necessary, but it may prevent rate limit
# errors especially on GitHub-hosted macos machines.
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Gradle
uses: gradle/[email protected]
- name: Build Plugin
run: gradle :buildPlugin
- name: Run Idea
run: |
mkdir -p build/reports
gradle :runIdeForUiTests > build/reports/idea.log &
- name: Wait for Idea started
uses: jtalk/url-health-check-action@v3
with:
url: http://127.0.0.1:8082
max-attempts: 20
retry-delay: 10s
- name: Tests
run: gradle :testUi
- name: Move video
if: always()
run: mv video build/reports
- name: Move sandbox logs
if: always()
run: mv build/idea-sandbox/system/log sandbox-idea-log
- name: Save report
if: always()
uses: actions/upload-artifact@v4
with:
name: ui-test-fails-report-mac
path: |
build/reports
sandbox-idea-log
# build-for-ui-test-linux:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Setup Java
# uses: actions/[email protected]
# with:
# distribution: zulu
# java-version: 11
# - name: Build Plugin
# run: gradle :buildPlugin
# - name: Run Idea
# run: |
# export DISPLAY=:99.0
# Xvfb -ac :99 -screen 0 1920x1080x16 &
# mkdir -p build/reports
# gradle :runIdeForUiTests #> build/reports/idea.log
# - name: Wait for Idea started
# uses: jtalk/[email protected]
# with:
# url: http://127.0.0.1:8082
# max-attempts: 15
# retry-delay: 30s
# - name: Tests
# run: gradle :testUi
# - name: Save fails report
# if: ${{ failure() }}
# uses: actions/upload-artifact@v2
# with:
# name: ui-test-fails-report-linux
# path: |
# ui-test-example/build/reports
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ usual beta standards.
* [VIM-3206](https://youtrack.jetbrains.com/issue/VIM-3206) Disable both copilot suggestion and insert mode on a single escape
* [VIM-3090](https://youtrack.jetbrains.com/issue/VIM-3090) Cmd line mode saves the visual mode
* [VIM-3085](https://youtrack.jetbrains.com/issue/VIM-3085) Open access to VimTypedActionHandler and VimShortcutKeyAction
* [VIM-3260](https://youtrack.jetbrains.com/issue/VIM-3260) Processing the offsets at the file end
* [VIM-3183](https://youtrack.jetbrains.com/issue/VIM-3183) Execute .ideavimrc on pooled thread

### Merged PRs:
* [763](https://github.com/JetBrains/ideavim/pull/763) by [Sam Ng](https://github.com/samabcde): Fix(VIM-3176) add test for restore selection after pasting in/below s…
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ val knownPlugins = listOf(
"com.github.dankinsoid.multicursor",
"com.joshestein.ideavim-quickscope",
"ca.alexgirard.HarpoonIJ",
"com.protoseo.input-source-auto-converter",

// "cc.implicated.intellij.plugins.bunny", // I don't want to include this plugin in the list of IdeaVim plugins as I don't understand what this is for
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.maddyhome.idea.vim.api.globalOptions
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.group.IjOptionConstants
import com.maddyhome.idea.vim.group.IjOptions
import com.maddyhome.idea.vim.handler.enableOctopus
import com.maddyhome.idea.vim.handler.isOctopusEnabled
import com.maddyhome.idea.vim.helper.EditorHelper
import com.maddyhome.idea.vim.helper.HandlerInjector
Expand Down Expand Up @@ -116,11 +117,13 @@ public class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatible
if (VimPlugin.isNotEnabled()) return ActionEnableStatus.no("IdeaVim is disabled", LogLevel.DEBUG)
val editor = getEditor(e)
if (editor != null && keyStroke != null) {
if (isOctopusEnabled(keyStroke, editor)) {
return ActionEnableStatus.no(
"Processing VimShortcutKeyAction for the key that is used in the octopus handler",
LogLevel.ERROR
)
if (enableOctopus) {
if (isOctopusEnabled(keyStroke, editor)) {
return ActionEnableStatus.no(
"Processing VimShortcutKeyAction for the key that is used in the octopus handler",
LogLevel.ERROR
)
}
}
if (editor.isIdeaVimDisabledHere) {
return ActionEnableStatus.no("IdeaVim is disabled in this place", LogLevel.INFO)
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/com/maddyhome/idea/vim/group/KeyGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.util.List;
import java.util.*;

import static com.maddyhome.idea.vim.api.VimInjectorKt.injector;
import static java.util.stream.Collectors.toList;

/**
Expand Down Expand Up @@ -227,10 +228,12 @@ public void registerCommandAction(@NotNull LazyVimCommand command) {

private void registerRequiredShortcut(@NotNull List<KeyStroke> keys, MappingOwner owner) {
for (KeyStroke key : keys) {
if (key.getKeyChar() == KeyEvent.CHAR_UNDEFINED &&
!(key.getKeyCode() == KeyEvent.VK_ESCAPE && key.getModifiers() == 0) &&
!(key.getKeyCode() == KeyEvent.VK_ENTER && key.getModifiers() == 0)) {
getRequiredShortcutKeys().add(new RequiredShortcut(key, owner));
if (key.getKeyChar() == KeyEvent.CHAR_UNDEFINED) {
if (!injector.getOptionGroup().getGlobalOptions().getOctopushandler() ||
!(key.getKeyCode() == KeyEvent.VK_ESCAPE && key.getModifiers() == 0) &&
!(key.getKeyCode() == KeyEvent.VK_ENTER && key.getModifiers() == 0)) {
getRequiredShortcutKeys().add(new RequiredShortcut(key, owner));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ private fun correctCopilotKeymap() {
// This is needed to initialize the injector in case this verification is called to fast
VimPlugin.getInstance()

if (!enableOctopus) return
if (injector.enabler.isEnabled()) {
val keymap = KeymapManagerEx.getInstanceEx().activeKeymap
val res = keymap.getShortcuts("copilot.disposeInlays")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ internal class EditorHandlersChainLogger : ProjectActivity {
private val editorHandlers = ExtensionPointName<EditorActionHandlerBean>("com.intellij.editorActionHandler")

override suspend fun execute(project: Project) {
if (!enableOctopus) return

val escHandlers = editorHandlers.extensionList
.filter { it.action == "EditorEscape" }
.joinToString("\n") { it.implementationClass }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ private fun verifyKeymap() {
// This is needed to initialize the injector in case this verification is called to fast
VimPlugin.getInstance()

if (!enableOctopus) return
if (!injector.enabler.isEnabled()) return

val keymap = KeymapManagerEx.getInstanceEx().activeKeymap
Expand Down
21 changes: 17 additions & 4 deletions src/main/java/com/maddyhome/idea/vim/handler/VimEnterHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.intellij.openapi.util.UserDataHolder
import com.intellij.openapi.util.removeUserData
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.globalOptions
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.api.key
import com.maddyhome.idea.vim.group.IjOptionConstants
Expand All @@ -52,7 +53,7 @@ internal val commandContinuation = Key.create<EditorActionHandler>("commandConti
*/
internal class CaretShapeEnterEditorHandler(private val nextHandler: EditorActionHandler) : EditorActionHandler() {
override fun doExecute(editor: Editor, caret: Caret?, dataContext: DataContext?) {
if (VimPlugin.isEnabled()) {
if (VimPlugin.isEnabled() && enableOctopus) {
invokeLater {
editor.updateCaretsVisualAttributes()
}
Expand Down Expand Up @@ -128,6 +129,7 @@ internal abstract class OctopusHandler(private val nextHandler: EditorActionHand
if (VimPlugin.isNotEnabled()) return false
if (!isHandlerEnabled(editor, dataContext)) return false
if (isNotActualKeyPress(dataContext)) return false
if (!enableOctopus) return false
return true
}

Expand Down Expand Up @@ -242,6 +244,7 @@ internal class VimEscForRiderHandler(nextHandler: EditorActionHandler) : VimKeyH
override val key: String = "<Esc>"

override fun isHandlerEnabled(editor: Editor, dataContext: DataContext?): Boolean {
if (!enableOctopus) return false
return LookupManager.getActiveLookup(editor) != null
}
}
Expand All @@ -257,7 +260,9 @@ internal class VimEscForRiderHandler(nextHandler: EditorActionHandler) : VimKeyH
*/
internal class VimEscLoggerHandler(private val nextHandler: EditorActionHandler) : EditorActionHandler() {
override fun doExecute(editor: Editor, caret: Caret?, dataContext: DataContext?) {
LOG.info("Esc pressed")
if (enableOctopus) {
LOG.info("Esc pressed")
}
nextHandler.execute(editor, caret, dataContext)
}

Expand All @@ -283,7 +288,9 @@ internal class StartNewLineBeforeCurrentDetector(nextHandler: EditorActionHandle

internal open class StartNewLineDetectorBase(private val nextHandler: EditorActionHandler) : EditorActionHandler() {
override fun doExecute(editor: Editor, caret: Caret?, dataContext: DataContext?) {
DataManager.getInstance().saveInDataContext(dataContext, Util.key, true)
if (enableOctopus) {
DataManager.getInstance().saveInDataContext(dataContext, Util.key, true)
}
nextHandler.execute(editor, caret, dataContext)
}

Expand Down Expand Up @@ -311,7 +318,9 @@ internal open class StartNewLineDetectorBase(private val nextHandler: EditorActi
*/
internal class VimEnterLoggerHandler(private val nextHandler: EditorActionHandler) : EditorActionHandler() {
override fun doExecute(editor: Editor, caret: Caret?, dataContext: DataContext?) {
LOG.info("Enter pressed")
if (enableOctopus) {
LOG.info("Enter pressed")
}
nextHandler.execute(editor, caret, dataContext)
}

Expand Down Expand Up @@ -341,6 +350,7 @@ internal abstract class VimKeyHandler(nextHandler: EditorActionHandler?) : Octop
}

internal fun isOctopusEnabled(s: KeyStroke, editor: Editor): Boolean {
if (!enableOctopus) return false
// CMD line has a different processing mechanizm: the processing actions are registered
// for the input field component. These keys are not dispatched via the octopus handler.
if (editor.vim.mode is Mode.CMD_LINE) return false
Expand All @@ -350,3 +360,6 @@ internal fun isOctopusEnabled(s: KeyStroke, editor: Editor): Boolean {
}
return false
}

internal val enableOctopus: Boolean
get() = injector.globalOptions().octopushandler
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import com.maddyhome.idea.vim.VimTypedActionHandler
import com.maddyhome.idea.vim.api.LocalOptionInitialisationScenario
import com.maddyhome.idea.vim.api.Options
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.coerceOffset
import com.maddyhome.idea.vim.api.getLineEndForOffset
import com.maddyhome.idea.vim.api.getLineStartForOffset
import com.maddyhome.idea.vim.api.injector
Expand Down Expand Up @@ -462,11 +463,17 @@ internal object VimListenerManager {
if (lineEnd == endOffset - 1) {
// When starting on an empty line and dragging vertically upwards onto
// another line, the selection should include the entirety of the empty line
caret.setSelection(endOffset + 1, startOffset)
caret.setSelection(
ijVimEditor.coerceOffset(endOffset + 1).point,
ijVimEditor.coerceOffset(startOffset).point,
)
} else if (lineEnd == startOffset + 1 && startOffset == endOffset) {
// When dragging left from EOL on a non-empty line, the selection
// should include the last character on the line
caret.setSelection(lineEnd, lineEnd - 1)
caret.setSelection(
ijVimEditor.coerceOffset(lineEnd).point,
ijVimEditor.coerceOffset(lineEnd - 1).point,
)
}
}
//endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import com.intellij.openapi.editor.actionSystem.EditorActionHandlerBean
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.testFramework.ExtensionTestUtil
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.globalOptions
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
Expand Down Expand Up @@ -45,24 +47,26 @@ class InsertEnterActionTest : VimTestCase() {
forEachBean.action = "EditorEnter"
forEachBean.setPluginDescriptor(PluginManagerCore.getPlugin(VimPlugin.getPluginId())!!)

if (repetitionInfo.currentRepetition == 1) {
ExtensionTestUtil.maskExtensions(
ExtensionPointName("com.intellij.editorActionHandler"),
listOf(mainBean),
fixture.testRootDisposable
)
} else if (repetitionInfo.currentRepetition == 2) {
ExtensionTestUtil.maskExtensions(
ExtensionPointName("com.intellij.editorActionHandler"),
listOf(singleBean, mainBean),
fixture.testRootDisposable
)
} else if (repetitionInfo.currentRepetition == 3) {
ExtensionTestUtil.maskExtensions(
ExtensionPointName("com.intellij.editorActionHandler"),
listOf(forEachBean, mainBean),
fixture.testRootDisposable
)
if (injector.globalOptions().octopushandler) {
if (repetitionInfo.currentRepetition == 1) {
ExtensionTestUtil.maskExtensions(
ExtensionPointName("com.intellij.editorActionHandler"),
listOf(mainBean),
fixture.testRootDisposable
)
} else if (repetitionInfo.currentRepetition == 2) {
ExtensionTestUtil.maskExtensions(
ExtensionPointName("com.intellij.editorActionHandler"),
listOf(singleBean, mainBean),
fixture.testRootDisposable
)
} else if (repetitionInfo.currentRepetition == 3) {
ExtensionTestUtil.maskExtensions(
ExtensionPointName("com.intellij.editorActionHandler"),
listOf(forEachBean, mainBean),
fixture.testRootDisposable
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,19 @@ class SetCommandTest : VimTestCase() {
assertCommandOutput("set all",
"""
|--- Options ---
|noargtextobj noideatracetime scrolljump=1 notextobj-entire
| closenotebooks ideawrite=all scrolloff=0 notextobj-indent
|nocommentary noignorecase selectmode= timeout
|nodigraph noincsearch shellcmdflag=-x timeoutlen=1000
|noexchange nomatchit shellxescape=@ notrackactionids
|nogdefault maxmapdepth=20 shellxquote={ undolevels=1000
|nohighlightedyank more showcmd unifyjumps
| history=50 nomultiple-cursors showmode virtualedit=
|nohlsearch noNERDTree sidescroll=0 novisualbell
|noideaglobalmode nrformats=hex sidescrolloff=0 visualdelay=100
|noideajoin nonumber nosmartcase whichwrap=b,s
| ideamarks norelativenumber startofline wrapscan
| ideastrictmode scroll=0 nosurround
|noargtextobj noideatracetime scroll=0 nosurround
| closenotebooks ideawrite=all scrolljump=1 notextobj-entire
|nocommentary noignorecase scrolloff=0 notextobj-indent
|nodigraph noincsearch selectmode= timeout
|noexchange nomatchit shellcmdflag=-x timeoutlen=1000
|nogdefault maxmapdepth=20 shellxescape=@ notrackactionids
|nohighlightedyank more shellxquote={ undolevels=1000
| history=50 nomultiple-cursors showcmd unifyjumps
|nohlsearch noNERDTree showmode virtualedit=
|noideaglobalmode nrformats=hex sidescroll=0 novisualbell
|noideajoin nonumber sidescrolloff=0 visualdelay=100
| ideamarks octopushandler nosmartcase whichwrap=b,s
| ideastrictmode norelativenumber startofline wrapscan
| clipboard=ideaput,autoselect,exclude:cons\|linux
| excommandannotation
| guicursor=n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175
Expand Down Expand Up @@ -260,6 +260,7 @@ class SetCommandTest : VimTestCase() {
|noNERDTree
| nrformats=hex
|nonumber
| octopushandler
|norelativenumber
|noReplaceWithRegister
| scroll=0
Expand Down
Loading

0 comments on commit 7769985

Please sign in to comment.