diff --git a/src/main/kotlin/org/acejump/search/Solver.kt b/src/main/kotlin/org/acejump/search/Solver.kt index 45de7bbd..347d3a50 100644 --- a/src/main/kotlin/org/acejump/search/Solver.kt +++ b/src/main/kotlin/org/acejump/search/Solver.kt @@ -10,7 +10,7 @@ import org.acejump.immutableText import org.acejump.input.KeyLayoutCache import org.acejump.isWordPart import org.acejump.wordEndPlus -import java.util.* +import java.util.IdentityHashMap import kotlin.math.max /* @@ -89,6 +89,10 @@ internal class Solver private constructor( while (iter.hasNext()) { val site = iter.nextInt() + if (editor.foldingModel.isOffsetCollapsed(site)) { + continue + } + for ((firstLetter, tags) in tagsByFirstLetter.entries) { if (canTagBeginWithChar(editor, site, firstLetter)) { for (tag in tags) { diff --git a/src/main/kotlin/org/acejump/search/Tag.kt b/src/main/kotlin/org/acejump/search/Tag.kt index db2e87a6..e72098cf 100644 --- a/src/main/kotlin/org/acejump/search/Tag.kt +++ b/src/main/kotlin/org/acejump/search/Tag.kt @@ -1,5 +1,8 @@ package org.acejump.search import com.intellij.openapi.editor.Editor +import org.acejump.getView -data class Tag(val editor: Editor, val offset: Int) +data class Tag(val editor: Editor, val offset: Int) { + fun isVisible() = offset in editor.getView() && !editor.foldingModel.isOffsetCollapsed(offset) +} diff --git a/src/main/kotlin/org/acejump/search/Tagger.kt b/src/main/kotlin/org/acejump/search/Tagger.kt index 5aeb24a1..862f5336 100644 --- a/src/main/kotlin/org/acejump/search/Tagger.kt +++ b/src/main/kotlin/org/acejump/search/Tagger.kt @@ -155,7 +155,7 @@ internal class Tagger(private val editors: List) { tagPortion.isNotEmpty() && label.startsWith(tagPortion, ignoreCase = true) && isTagCompatibleWithQuery(label, tag, query) - && tag.offset in tag.editor.getView() + && tag.isVisible() } private fun removeResultsWithOverlappingTags(editor: Editor, offsets: IntList) { diff --git a/src/main/kotlin/org/acejump/view/TagCanvas.kt b/src/main/kotlin/org/acejump/view/TagCanvas.kt index 3ccdd2f7..5bcba765 100644 --- a/src/main/kotlin/org/acejump/view/TagCanvas.kt +++ b/src/main/kotlin/org/acejump/view/TagCanvas.kt @@ -67,6 +67,7 @@ internal class TagCanvas(private val editor: Editor): JComponent(), CaretListene val cache = EditorOffsetCache.new() val viewRange = VISIBLE_ON_SCREEN.getOffsetRange(editor, cache) + val foldingModel = editor.foldingModel val occupied = mutableListOf() // If there is a tag at the caret location, prioritize its rendering over @@ -82,8 +83,9 @@ internal class TagCanvas(private val editor: Editor): JComponent(), CaretListene val caretMarker = markers.find { it.offsetL == caretOffset || it.offsetR == caretOffset } caretMarker?.paint(g, editor, cache, font, occupied) - for (marker in markers) - if (marker.isOffsetInRange(viewRange) && marker !== caretMarker) + for (marker in markers) { + if (marker.isOffsetInRange(viewRange) && !foldingModel.isOffsetCollapsed(marker.offsetL) && marker !== caretMarker) marker.paint(g, editor, cache, font, occupied) + } } }