mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-14 15:34:06 +02:00
parent
27fb36a6c5
commit
932296afb6
.teamcity/_Self
build.gradle.ktsgradle.propertiessrc
main
java/com/maddyhome/idea/vim
resources/META-INF
test/java/org/jetbrains/plugins/ideavim
4
.teamcity/_Self/Constants.kt
vendored
4
.teamcity/_Self/Constants.kt
vendored
@ -5,7 +5,7 @@ object Constants {
|
||||
const val EAP_CHANNEL = "eap"
|
||||
const val DEV_CHANNEL = "Dev"
|
||||
|
||||
const val VERSION = "1.9.1"
|
||||
const val VERSION = "1.9.0"
|
||||
const val DEV_VERSION = "1.10.0"
|
||||
|
||||
const val GITHUB_TESTS = "LATEST-EAP-SNAPSHOT"
|
||||
@ -14,7 +14,7 @@ object Constants {
|
||||
const val PROPERTY_TESTS = "LATEST-EAP-SNAPSHOT"
|
||||
const val LONG_RUNNING_TESTS = "LATEST-EAP-SNAPSHOT"
|
||||
const val QODANA_TESTS = "LATEST-EAP-SNAPSHOT"
|
||||
const val RELEASE = "2021.3"
|
||||
const val RELEASE = "2021.2.2"
|
||||
const val RELEASE_DEV = "LATEST-EAP-SNAPSHOT"
|
||||
const val RELEASE_EAP = "LATEST-EAP-SNAPSHOT"
|
||||
}
|
||||
|
@ -74,14 +74,14 @@ configurations {
|
||||
|
||||
tasks {
|
||||
// Include tests for testing on LATEST-EAP-SNAPSHOT
|
||||
val test by getting(Test::class) {
|
||||
isScanForTestClasses = false
|
||||
// Only run tests from classes that end with "Test"
|
||||
include("**/*Test.class")
|
||||
include("**/*Tests.class")
|
||||
exclude("**/ParserTest.class")
|
||||
}
|
||||
|
||||
// val test by getting(Test::class) {
|
||||
// isScanForTestClasses = false
|
||||
// // Only run tests from classes that end with "Test"
|
||||
// include("**/*Test.class")
|
||||
// include("**/*Tests.class")
|
||||
// exclude("**/ParserTest.class")
|
||||
// }
|
||||
//
|
||||
compileJava {
|
||||
sourceCompatibility = javaVersion
|
||||
targetCompatibility = javaVersion
|
||||
|
@ -1,6 +1,6 @@
|
||||
# suppress inspection "UnusedProperty" for whole file
|
||||
|
||||
ideaVersion=LATEST-EAP-SNAPSHOT
|
||||
ideaVersion=2021.2.2
|
||||
downloadIdeaSources=true
|
||||
instrumentPluginCode=true
|
||||
version=SNAPSHOT
|
||||
|
@ -18,9 +18,8 @@
|
||||
|
||||
package com.maddyhome.idea.vim.common
|
||||
|
||||
import com.intellij.ide.bookmark.BookmarkType
|
||||
import com.intellij.ide.bookmark.BookmarksManager
|
||||
import com.intellij.ide.bookmark.LineBookmark
|
||||
import com.intellij.ide.bookmarks.Bookmark
|
||||
import com.intellij.ide.bookmarks.BookmarkManager
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.LogicalPosition
|
||||
import com.intellij.openapi.project.Project
|
||||
@ -80,11 +79,11 @@ data class VimMark(
|
||||
}
|
||||
}
|
||||
|
||||
class IntellijMark(bookmark: LineBookmark, override val col: Int, project: Project?) : Mark {
|
||||
class IntellijMark(bookmark: Bookmark, override val col: Int, project: Project?) : Mark {
|
||||
|
||||
private val project: WeakReference<Project?> = WeakReference(project)
|
||||
|
||||
override val key = BookmarksManager.getInstance(project)?.getType(bookmark)?.mnemonic!!
|
||||
override val key = bookmark.mnemonic
|
||||
override val logicalLine: Int
|
||||
get() = getMark()?.line ?: 0
|
||||
override val filename: String
|
||||
@ -92,16 +91,14 @@ class IntellijMark(bookmark: LineBookmark, override val col: Int, project: Proje
|
||||
override val protocol: String
|
||||
get() = getMark()?.file?.let { MarkGroup.extractProtocol(it) } ?: ""
|
||||
|
||||
override fun isClear(): Boolean = getMark() == null
|
||||
override fun isClear(): Boolean = getMark()?.isValid?.not() ?: false
|
||||
override fun clear() {
|
||||
val mark = getMark() ?: return
|
||||
getProject()?.let { project -> BookmarksManager.getInstance(project)?.remove(mark) }
|
||||
getProject()?.let { project -> BookmarkManager.getInstance(project).removeBookmark(mark) }
|
||||
}
|
||||
|
||||
private fun getMark(): LineBookmark? =
|
||||
getProject()?.let {
|
||||
project -> BookmarksManager.getInstance(project)?.getBookmark(BookmarkType.get(key)) as? LineBookmark
|
||||
}
|
||||
private fun getMark(): Bookmark? =
|
||||
getProject()?.let { project -> BookmarkManager.getInstance(project).findBookmarkForMnemonic(key) }
|
||||
|
||||
private fun getProject(): Project? {
|
||||
val proj = project.get() ?: return null
|
||||
|
@ -18,10 +18,9 @@
|
||||
|
||||
package com.maddyhome.idea.vim.group;
|
||||
|
||||
import com.intellij.ide.bookmark.BookmarkGroup;
|
||||
import com.intellij.ide.bookmark.BookmarkType;
|
||||
import com.intellij.ide.bookmark.BookmarksManager;
|
||||
import com.intellij.ide.bookmark.LineBookmark;
|
||||
import com.intellij.ide.bookmarks.Bookmark;
|
||||
import com.intellij.ide.bookmarks.BookmarkManager;
|
||||
import com.intellij.ide.bookmarks.BookmarksListener;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.RoamingType;
|
||||
import com.intellij.openapi.components.State;
|
||||
@ -48,6 +47,7 @@ import com.maddyhome.idea.vim.helper.HelperKt;
|
||||
import com.maddyhome.idea.vim.helper.SearchHelper;
|
||||
import com.maddyhome.idea.vim.vimscript.services.OptionService;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -221,7 +221,7 @@ public class MarkGroup implements PersistentStateComponent<Element> {
|
||||
HashMap<Character, Mark> fmarks = getFileMarks(editor.getDocument());
|
||||
if (fmarks == null) return false;
|
||||
|
||||
@Nullable LineBookmark systemMark = SystemMarks.createOrGetSystemMark(ch, lp.line, editor);
|
||||
Bookmark systemMark = createOrGetSystemMark(ch, lp.line, editor);
|
||||
Mark mark;
|
||||
if (systemMark != null) {
|
||||
mark = new IntellijMark(systemMark, lp.column, editor.getProject());
|
||||
@ -238,6 +238,22 @@ public class MarkGroup implements PersistentStateComponent<Element> {
|
||||
return true;
|
||||
}
|
||||
|
||||
private @Nullable Bookmark createOrGetSystemMark(char ch, int line, @NotNull Editor editor) {
|
||||
if (!VimPlugin.getOptionService().isSet(new OptionService.Scope.LOCAL(editor), "ideamarks", "ideamarks")) return null;
|
||||
final Project project = editor.getProject();
|
||||
if (project == null) return null;
|
||||
final BookmarkManager bookmarkManager = BookmarkManager.getInstance(project);
|
||||
|
||||
Bookmark bookmark = bookmarkManager.findBookmarkForMnemonic(ch);
|
||||
if (bookmark != null && bookmark.getLine() == line) return bookmark;
|
||||
|
||||
final VirtualFile virtualFile = EditorHelper.getVirtualFile(editor);
|
||||
if (virtualFile == null) return null;
|
||||
bookmark = bookmarkManager.addTextBookmark(virtualFile, line, "");
|
||||
bookmarkManager.setMnemonic(bookmark, ch);
|
||||
return bookmark;
|
||||
}
|
||||
|
||||
public static String extractProtocol(@NotNull VirtualFile vf) {
|
||||
return VirtualFileManager.extractProtocol(vf.getUrl());
|
||||
}
|
||||
@ -730,56 +746,68 @@ public class MarkGroup implements PersistentStateComponent<Element> {
|
||||
}
|
||||
}
|
||||
|
||||
public static class VimBookmarksListener implements com.intellij.ide.bookmark.BookmarksListener {
|
||||
private final Project myProject;
|
||||
public static class MarkListener implements BookmarksListener {
|
||||
|
||||
public VimBookmarksListener(Project project) {
|
||||
myProject = project;
|
||||
private final Project project;
|
||||
private Bookmark bookmarkTemplate = null;
|
||||
|
||||
@Contract(pure = true)
|
||||
public MarkListener(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
/**
|
||||
* IJ has an interesting approach in mnemonic marks initialization. Firstly it creates an unnamed mark,
|
||||
* then updates it. In general, it creates two events: one for creation and one for mnemonic set.
|
||||
* However, when IJ starts and reads existing marks from caches, it creates marks with mnemonics already.
|
||||
*/
|
||||
@Override
|
||||
public void bookmarkAdded(@NotNull BookmarkGroup group, com.intellij.ide.bookmark.@NotNull Bookmark bookmark) {
|
||||
public void bookmarkAdded(@NotNull Bookmark b) {
|
||||
if (!VimPlugin.isEnabled()) return;
|
||||
if (!VimPlugin.getOptionService().isSet(OptionService.Scope.GLOBAL.INSTANCE, "ideamarks", "ideamarks")) return;
|
||||
|
||||
if (!(bookmark instanceof LineBookmark)) return;
|
||||
BookmarksManager bookmarksManager = BookmarksManager.getInstance(myProject);
|
||||
if (bookmarksManager == null) return;
|
||||
BookmarkType type = bookmarksManager.getType(bookmark);
|
||||
if (type == null) return;
|
||||
|
||||
char mnemonic = type.getMnemonic();
|
||||
if (GLOBAL_MARKS.indexOf(mnemonic) == -1) return;
|
||||
|
||||
createVimMark((LineBookmark)bookmark, mnemonic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bookmarkRemoved(@NotNull BookmarkGroup group, com.intellij.ide.bookmark.@NotNull Bookmark bookmark) {
|
||||
if (!VimPlugin.isEnabled()) return;
|
||||
if (!VimPlugin.getOptionService().isSet(OptionService.Scope.GLOBAL.INSTANCE, "ideamarks", "ideamarks")) return;
|
||||
|
||||
if (!(bookmark instanceof LineBookmark)) return;
|
||||
BookmarksManager bookmarksManager = BookmarksManager.getInstance(myProject);
|
||||
if (bookmarksManager == null) return;
|
||||
BookmarkType type = bookmarksManager.getType(bookmark);
|
||||
if (type == null) return;
|
||||
char ch = type.getMnemonic();
|
||||
if (GLOBAL_MARKS.indexOf(ch) != -1) {
|
||||
FileMarks<Character, Mark> fmarks = VimPlugin.getMark().getFileMarks(((LineBookmark)bookmark).getFile().getPath());
|
||||
fmarks.remove(ch);
|
||||
VimPlugin.getMark().globalMarks.remove(ch);
|
||||
if (b.getMnemonic() == '\u0000') {
|
||||
bookmarkTemplate = b;
|
||||
} else {
|
||||
createVimMark(b);
|
||||
}
|
||||
}
|
||||
|
||||
private void createVimMark(@NotNull LineBookmark b, char mnemonic) {
|
||||
int col = 0;
|
||||
Editor editor = EditorHelper.getEditor(b.getFile());
|
||||
if (editor != null) col = editor.getCaretModel().getCurrentCaret().getLogicalPosition().column;
|
||||
IntellijMark mark = new IntellijMark(b, col, myProject);
|
||||
FileMarks<Character, Mark> fmarks = VimPlugin.getMark().getFileMarks(b.getFile().getPath());
|
||||
fmarks.put(mnemonic, mark);
|
||||
VimPlugin.getMark().globalMarks.put(mnemonic, mark);
|
||||
@Override
|
||||
public void bookmarkRemoved(@NotNull Bookmark b) {
|
||||
if (!VimPlugin.isEnabled()) return;
|
||||
if (!VimPlugin.getOptionService().isSet(OptionService.Scope.GLOBAL.INSTANCE, "ideamarks", "ideamarks")) return;
|
||||
|
||||
char ch = b.getMnemonic();
|
||||
if (GLOBAL_MARKS.indexOf(ch) != -1) {
|
||||
FileMarks<Character, Mark> fmarks = VimPlugin.getMark().getFileMarks(b.getFile().getPath());
|
||||
fmarks.remove(ch);
|
||||
VimPlugin.getMark().globalMarks.remove(ch);
|
||||
// No need to call mark.clear()
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bookmarkChanged(@NotNull Bookmark b) {
|
||||
if (!VimPlugin.isEnabled()) return;
|
||||
/* IJ sets named marks in two steps. Firstly it creates an unnamed mark, then adds a mnemonic */
|
||||
if (!VimPlugin.getOptionService().isSet(OptionService.Scope.GLOBAL.INSTANCE, "ideamarks", "ideamarks")) return;
|
||||
if (b != bookmarkTemplate) return;
|
||||
bookmarkTemplate = null;
|
||||
|
||||
createVimMark(b);
|
||||
}
|
||||
|
||||
private void createVimMark(@NotNull Bookmark b) {
|
||||
char ch = b.getMnemonic();
|
||||
if (GLOBAL_MARKS.indexOf(ch) != -1) {
|
||||
int col = 0;
|
||||
Editor editor = EditorHelper.getEditor(b.getFile());
|
||||
if (editor != null) col = editor.getCaretModel().getCurrentCaret().getLogicalPosition().column;
|
||||
IntellijMark mark = new IntellijMark(b, col, project);
|
||||
FileMarks<Character, Mark> fmarks = VimPlugin.getMark().getFileMarks(b.getFile().getPath());
|
||||
fmarks.put(ch, mark);
|
||||
VimPlugin.getMark().globalMarks.put(ch, mark);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2021 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2021 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 com.maddyhome.idea.vim.group
|
||||
|
||||
import com.intellij.ide.bookmark.Bookmark
|
||||
import com.intellij.ide.bookmark.BookmarkType
|
||||
import com.intellij.ide.bookmark.BookmarksManager
|
||||
import com.intellij.ide.bookmark.LineBookmark
|
||||
import com.intellij.ide.bookmark.providers.LineBookmarkProvider
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.vimscript.services.OptionService.Scope.LOCAL
|
||||
|
||||
class SystemMarks {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun createOrGetSystemMark(ch: Char, line: Int, editor: Editor): LineBookmark? {
|
||||
if (!VimPlugin.getOptionService().isSet(LOCAL(editor), "ideamarks", "ideamarks")) return null
|
||||
|
||||
val project = editor.project ?: return null
|
||||
val type = BookmarkType.get(ch)
|
||||
if (type == BookmarkType.DEFAULT) return null
|
||||
|
||||
val bookmarksManager = BookmarksManager.getInstance(project) ?: return null
|
||||
val foundBookmark = bookmarksManager.getBookmark(type)
|
||||
if (foundBookmark != null) {
|
||||
if (foundBookmark is LineBookmark && foundBookmark.line == line) {
|
||||
return foundBookmark
|
||||
}
|
||||
bookmarksManager.remove(foundBookmark)
|
||||
}
|
||||
|
||||
return project.createLineBookmark(editor, line, ch)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.createLineBookmark(editor: Editor, line: Int, mnemonic: Char): LineBookmark? {
|
||||
val bookmarksManager = BookmarksManager.getInstance(this) ?: return null
|
||||
val lineBookmarkProvider = LineBookmarkProvider.find(this) ?: return null
|
||||
val bookmark = lineBookmarkProvider.createBookmark(editor, line) as LineBookmark? ?: return null
|
||||
val type = BookmarkType.get(mnemonic)
|
||||
if (type == BookmarkType.DEFAULT) return null
|
||||
|
||||
val group = bookmarksManager.defaultGroup ?: bookmarksManager.addGroup("IdeaVim", true) ?: return null
|
||||
if (group.canAdd(bookmark)) {
|
||||
group.add(bookmark, type)
|
||||
return bookmark
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
internal fun Bookmark.mnemonic(project: Project?): Char {
|
||||
return BookmarksManager.getInstance(project)?.getType(this)!!.mnemonic
|
||||
}
|
@ -18,8 +18,8 @@
|
||||
<listener class="com.maddyhome.idea.vim.listener.IdeaSpecifics$VimTemplateManagerListener"
|
||||
topic="com.intellij.codeInsight.template.TemplateManagerListener"/>
|
||||
|
||||
<listener class="com.maddyhome.idea.vim.group.MarkGroup$VimBookmarksListener"
|
||||
topic="com.intellij.ide.bookmark.BookmarksListener"/>
|
||||
<listener class="com.maddyhome.idea.vim.group.MarkGroup$MarkListener"
|
||||
topic="com.intellij.ide.bookmarks.BookmarksListener"/>
|
||||
|
||||
<listener class="com.maddyhome.idea.vim.listener.IdeaSpecifics$VimFindModelListener"
|
||||
topic="com.intellij.find.FindModelListener"/>
|
||||
|
@ -76,7 +76,7 @@
|
||||
|
||||
<!-- Please search for "[VERSION UPDATE]" in project in case you update the since-build version -->
|
||||
<!-- Check for [Version Update] tag in YouTrack as well -->
|
||||
<idea-version since-build="213"/>
|
||||
<idea-version since-build="203"/>
|
||||
|
||||
<!-- Mark the plugin as compatible with RubyMine and other products based on the IntelliJ platform (including CWM) -->
|
||||
<depends>com.intellij.modules.platform</depends>
|
||||
|
@ -17,7 +17,8 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.ideavim
|
||||
|
||||
import com.intellij.ide.bookmark.BookmarksManager
|
||||
import com.intellij.ide.bookmarks.Bookmark
|
||||
import com.intellij.ide.bookmarks.BookmarkManager
|
||||
import com.intellij.ide.highlighter.JavaFileType
|
||||
import com.intellij.ide.highlighter.XmlFileType
|
||||
import com.intellij.json.JsonFileType
|
||||
@ -77,6 +78,7 @@ import com.maddyhome.idea.vim.vimscript.services.OptionService
|
||||
import com.maddyhome.idea.vim.vimscript.services.VariableServiceImpl
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.junit.Assert
|
||||
import java.util.function.Consumer
|
||||
import javax.swing.KeyStroke
|
||||
|
||||
/**
|
||||
@ -127,10 +129,8 @@ abstract class VimTestCase : UsefulTestCase() {
|
||||
override fun tearDown() {
|
||||
val swingTimer = swingTimer
|
||||
swingTimer?.stop()
|
||||
val bookmarksManager = BookmarksManager.getInstance(myFixture.project)
|
||||
bookmarksManager?.bookmarks?.forEach { bookmark ->
|
||||
bookmarksManager.remove(bookmark)
|
||||
}
|
||||
val bookmarkManager = BookmarkManager.getInstance(myFixture.project)
|
||||
bookmarkManager.validBookmarks.forEach(Consumer { bookmark: Bookmark? -> bookmarkManager.removeBookmark(bookmark!!) })
|
||||
SelectionVimListenerSuppressor.lock().use { myFixture.tearDown() }
|
||||
ExEntryPanel.getInstance().deactivate(false)
|
||||
(VimPlugin.getVariableService() as VariableServiceImpl).clear()
|
||||
|
@ -18,12 +18,8 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.motion.mark
|
||||
|
||||
import com.intellij.ide.bookmark.BookmarksManager
|
||||
import com.intellij.ide.bookmark.LineBookmark
|
||||
import com.intellij.testFramework.PlatformTestUtil
|
||||
import com.intellij.ide.bookmarks.BookmarkManager
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.group.createLineBookmark
|
||||
import com.maddyhome.idea.vim.group.mnemonic
|
||||
import com.maddyhome.idea.vim.helper.StringHelper
|
||||
import com.maddyhome.idea.vim.option.IdeaMarksOptionsData
|
||||
import junit.framework.TestCase
|
||||
@ -31,6 +27,7 @@ import org.jetbrains.plugins.ideavim.OptionValueType
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestCase
|
||||
import org.jetbrains.plugins.ideavim.VimOptionTestConfiguration
|
||||
import org.jetbrains.plugins.ideavim.VimTestOption
|
||||
import org.junit.Ignore
|
||||
|
||||
class MotionMarkActionTest : VimOptionTestCase(IdeaMarksOptionsData.name) {
|
||||
@VimOptionTestConfiguration(VimTestOption(IdeaMarksOptionsData.name, OptionValueType.NUMBER, "1"))
|
||||
@ -78,10 +75,7 @@ class MotionMarkActionTest : VimOptionTestCase(IdeaMarksOptionsData.name) {
|
||||
""".trimIndent()
|
||||
configureByText(text)
|
||||
typeText(keys)
|
||||
checkMarks('A' to 2)
|
||||
|
||||
// Previously it was like this, but now it's impossible to set multiple bookmarks on the same line.
|
||||
// checkMarks('A' to 2, 'B' to 2, 'C' to 2)
|
||||
checkMarks('A' to 2, 'B' to 2, 'C' to 2)
|
||||
}
|
||||
|
||||
@VimOptionTestConfiguration(VimTestOption(IdeaMarksOptionsData.name, OptionValueType.NUMBER, "1"))
|
||||
@ -111,8 +105,34 @@ class MotionMarkActionTest : VimOptionTestCase(IdeaMarksOptionsData.name) {
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent()
|
||||
configureByText(text)
|
||||
myFixture.project.createLineBookmark(myFixture.editor, 2, 'A')
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
val bookmarkManager = BookmarkManager.getInstance(myFixture.project)
|
||||
bookmarkManager.addEditorBookmark(myFixture.editor, 2)
|
||||
val bookmark = bookmarkManager.findEditorBookmark(myFixture.editor.document, 2) ?: kotlin.test.fail()
|
||||
bookmarkManager.setMnemonic(bookmark, 'A')
|
||||
val vimMarks = VimPlugin.getMark().getMarks(myFixture.editor)
|
||||
TestCase.assertEquals(1, vimMarks.size)
|
||||
TestCase.assertEquals('A', vimMarks[0].key)
|
||||
}
|
||||
|
||||
@VimOptionTestConfiguration(VimTestOption(IdeaMarksOptionsData.name, OptionValueType.NUMBER, "1"))
|
||||
@Ignore("Probably one day it would be possible to test it")
|
||||
fun `ignoretest apply new state`() {
|
||||
val text = """
|
||||
A Discovery
|
||||
|
||||
I ${c}found it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent()
|
||||
configureByText(text)
|
||||
val bookmarkManager = BookmarkManager.getInstance(myFixture.project)
|
||||
bookmarkManager.addEditorBookmark(myFixture.editor, 2)
|
||||
val bookmark = bookmarkManager.findEditorBookmark(myFixture.editor.document, 2) ?: kotlin.test.fail()
|
||||
|
||||
bookmark.mnemonic = 'A'
|
||||
bookmarkManager.applyNewStateInTestMode(listOf(bookmark))
|
||||
|
||||
val vimMarks = VimPlugin.getMark().getMarks(myFixture.editor)
|
||||
TestCase.assertEquals(1, vimMarks.size)
|
||||
TestCase.assertEquals('A', vimMarks[0].key)
|
||||
@ -129,12 +149,15 @@ class MotionMarkActionTest : VimOptionTestCase(IdeaMarksOptionsData.name) {
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent()
|
||||
configureByText(text)
|
||||
var bookmarkManager = BookmarkManager.getInstance(myFixture.project)
|
||||
bookmarkManager.addEditorBookmark(myFixture.editor, 2)
|
||||
var bookmark = bookmarkManager.findEditorBookmark(myFixture.editor.document, 2) ?: kotlin.test.fail()
|
||||
bookmarkManager.setMnemonic(bookmark, 'A')
|
||||
|
||||
val bookmark = myFixture.project.createLineBookmark(myFixture.editor, 2, 'A')
|
||||
|
||||
BookmarksManager.getInstance(myFixture.project)?.remove(bookmark!!)
|
||||
myFixture.project.createLineBookmark(myFixture.editor, 4, 'A')
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
bookmarkManager = BookmarkManager.getInstance(myFixture.project)
|
||||
bookmarkManager.addEditorBookmark(myFixture.editor, 4)
|
||||
bookmark = bookmarkManager.findEditorBookmark(myFixture.editor.document, 4) ?: kotlin.test.fail()
|
||||
bookmarkManager.setMnemonic(bookmark, 'A')
|
||||
val vimMarks = VimPlugin.getMark().getMarks(myFixture.editor)
|
||||
TestCase.assertEquals(1, vimMarks.size)
|
||||
TestCase.assertEquals('A', vimMarks[0].key)
|
||||
@ -142,12 +165,11 @@ class MotionMarkActionTest : VimOptionTestCase(IdeaMarksOptionsData.name) {
|
||||
}
|
||||
|
||||
private fun checkMarks(vararg marks: Pair<Char, Int>) {
|
||||
val project = myFixture.project
|
||||
val validBookmarks = BookmarksManager.getInstance(project)!!.bookmarks.sortedBy { it.mnemonic(project) }
|
||||
val validBookmarks = BookmarkManager.getInstance(myFixture.project).validBookmarks
|
||||
assertEquals(marks.size, validBookmarks.size)
|
||||
marks.sortedBy { it.first }.forEachIndexed { index, (mn, line) ->
|
||||
assertEquals(mn, validBookmarks[index].mnemonic(project))
|
||||
assertEquals(line, (validBookmarks[index] as LineBookmark).line)
|
||||
marks.forEachIndexed { index, (mn, line) ->
|
||||
assertEquals(mn, validBookmarks[marks.size - index - 1].mnemonic)
|
||||
assertEquals(line, validBookmarks[marks.size - index - 1].line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.ex.implementation.commands
|
||||
|
||||
import com.intellij.openapi.editor.LogicalPosition
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.common.Mark
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
@ -35,22 +34,11 @@ class DeleteMarksCommandTest : VimTestCase() {
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
|
||||
The features it combines mark it as new
|
||||
to science: shape and shade -- the special tinge,
|
||||
akin to moonlight, tempering its blue,
|
||||
the dingy underside, the checquered fringe.
|
||||
|
||||
My needles have teased out its sculpted sex;
|
||||
corroded tissues could no longer hide
|
||||
that priceless mote now dimpling the convex
|
||||
and limpid teardrop on a lighted slide.
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
marks.forEachIndexed { index, c ->
|
||||
VimPlugin.getMark()
|
||||
.setMark(myFixture.editor, c, myFixture.editor.logicalPositionToOffset(LogicalPosition(index, 0)))
|
||||
VimPlugin.getMark().setMark(myFixture.editor, c, index * 10)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user