1
0
mirror of https://github.com/chylex/IntelliJ-AceJump.git synced 2025-05-09 22:34:05 +02:00

Merge pull request from huoguangjin/master

Remove only the highlighters added by AceJump when the jump session ends
This commit is contained in:
breandan 2022-05-16 19:53:40 -04:00 committed by GitHub
commit f8b2db5090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions
src
main/kotlin/org/acejump/view
test/kotlin

View File

@ -148,7 +148,9 @@ internal class TextHighlighter {
}
fun reset() {
previousHighlights.keys.forEach { it.markupModel.removeAllHighlighters() }
previousHighlights.forEach { (editor, highlighters) ->
highlighters.forEach(editor.markupModel::removeHighlighter)
}
previousHighlights.clear()
previousHint?.hide()
}

View File

@ -1,5 +1,7 @@
import com.intellij.mock.MockVirtualFile
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.markup.HighlighterLayer
import com.intellij.openapi.editor.markup.HighlighterTargetArea
import com.intellij.openapi.fileEditor.TextEditor
import com.intellij.util.ui.UIUtil
import it.unimi.dsi.fastutil.ints.IntArrayList
@ -166,4 +168,21 @@ class ExternalUsageTest: BaseTest() {
TestCase.assertEquals(mark, detectedMark)
TestCase.assertEquals("", detectedQuery)
}
fun `test do not remove other highlights when the session ends`() {
makeEditor("test do not remove other highlights when the session ends")
val markupModel = myFixture.editor.markupModel
val layer = HighlighterLayer.SELECTION - 1
val existedHighlighter = markupModel.addRangeHighlighter(0, 1, layer, null, HighlighterTargetArea.EXACT_RANGE)
takeAction(AceAction.StartAllWordsMode())
val mark = session.tags[0].key
typeAndWaitForResults(mark)
TestCase.assertEquals("last session should be disposed", null, SessionManager[myFixture.editor])
TestCase.assertTrue("existed highlighter should not be removed", existedHighlighter.isValid)
existedHighlighter.dispose()
}
}