mirror of
https://github.com/chylex/IntelliJ-AceJump.git
synced 2025-05-09 22:34:05 +02:00
Merge pull request #407 from huoguangjin/master
Remove only the highlighters added by AceJump when the jump session ends
This commit is contained in:
commit
f8b2db5090
src
@ -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()
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user