mirror of
https://github.com/chylex/IntelliJ-AceJump.git
synced 2025-05-09 22:34:05 +02:00
Merge branch 'visible-area' of https://github.com/chylex/AceJump into chylex-visible-area
# Conflicts: # src/main/kotlin/org/acejump/config/AceConfig.kt # src/main/kotlin/org/acejump/config/AceConfigurable.kt # src/main/kotlin/org/acejump/config/AceSettings.kt # src/main/kotlin/org/acejump/config/AceSettingsPanel.kt # src/main/resources/AceResources.properties
This commit is contained in:
commit
8e46a5a3e3
@ -6,8 +6,9 @@ import org.jetbrains.intellij.tasks.PatchPluginXmlTask
|
||||
plugins {
|
||||
idea apply true
|
||||
kotlin("jvm") version "1.3.72"
|
||||
id("org.jetbrains.intellij") version "0.6.1"
|
||||
id("org.jetbrains.intellij") version "0.6.4"
|
||||
id("org.jetbrains.changelog") version "0.6.2"
|
||||
id("com.github.ben-manes.versions") version "0.36.0"
|
||||
}
|
||||
|
||||
tasks {
|
||||
@ -45,6 +46,7 @@ changelog {
|
||||
dependencies {
|
||||
// gradle-intellij-plugin doesn't attach sources properly for Kotlin :(
|
||||
compileOnly(kotlin("stdlib-jdk8"))
|
||||
// https://github.com/promeG/TinyPinyin
|
||||
implementation("com.github.promeg:tinypinyin:2.0.3")
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@ class AceConfig: PersistentStateComponent<AceSettings> {
|
||||
val tagForegroundColor: Color get() = settings.tagForegroundColor
|
||||
val tagBackgroundColor: Color get() = settings.tagBackgroundColor
|
||||
val roundedTagCorners: Boolean get() = settings.roundedTagCorners
|
||||
val searchWholeFile: Boolean get() = settings.searchWholeFile
|
||||
val supportPinyin: Boolean get() = settings.supportPinyin
|
||||
|
||||
private val nearby: Map<Char, Map<Char, Int>> = mapOf(
|
||||
|
@ -28,6 +28,7 @@ class AceConfigurable: Configurable {
|
||||
panel.tagForegroundColor != settings.tagForegroundColor ||
|
||||
panel.tagBackgroundColor != settings.tagBackgroundColor ||
|
||||
panel.roundedTagCorners != settings.roundedTagCorners ||
|
||||
panel.searchWholeFile != settings.searchWholeFile ||
|
||||
panel.supportPinyin != settings.supportPinyin
|
||||
|
||||
private fun String.distinctAlphanumerics() =
|
||||
@ -52,6 +53,7 @@ class AceConfigurable: Configurable {
|
||||
panel.tagForegroundColor ?.let { settings.tagForegroundColor = it }
|
||||
panel.tagBackgroundColor ?.let { settings.tagBackgroundColor = it }
|
||||
settings.roundedTagCorners = panel.roundedTagCorners
|
||||
settings.searchWholeFile = panel.searchWholeFile
|
||||
settings.supportPinyin = panel.supportPinyin
|
||||
|
||||
logger.info("User applied new settings: $settings")
|
||||
|
@ -39,5 +39,6 @@ data class AceSettings(
|
||||
|
||||
var displayQuery: Boolean = false,
|
||||
var roundedTagCorners: Boolean = true,
|
||||
var searchWholeFile: Boolean = true,
|
||||
var supportPinyin: Boolean = false
|
||||
)
|
@ -40,6 +40,7 @@ internal class AceSettingsPanel {
|
||||
private val tagBackgroundColorWheel = ColorPanel()
|
||||
private val displayQueryCheckBox = JBCheckBox().apply { isEnabled = false }
|
||||
private val roundedTagCornersCheckBox = JBCheckBox()
|
||||
private val searchWholeFileCheckBox = JBCheckBox()
|
||||
private val supportPinyinCheckBox = JBCheckBox()
|
||||
|
||||
init {
|
||||
@ -111,7 +112,8 @@ internal class AceSettingsPanel {
|
||||
row { short(roundedTagCornersCheckBox.apply { text = aceString("roundedTagCornersLabel") }) }
|
||||
}
|
||||
|
||||
titledRow(aceString("languagesHeading")) {
|
||||
titledRow(aceString("behaviorHeading")) {
|
||||
row { short(searchWholeFileCheckBox.apply { text = aceString("searchWholeFileLabel") }) }
|
||||
row { short(supportPinyinCheckBox.apply { text = aceString("supportPinyin") }) }
|
||||
}
|
||||
}
|
||||
@ -133,6 +135,7 @@ internal class AceSettingsPanel {
|
||||
internal var tagBackgroundColor by tagBackgroundColorWheel
|
||||
internal var displayQuery by displayQueryCheckBox
|
||||
internal var roundedTagCorners by roundedTagCornersCheckBox
|
||||
internal var searchWholeFile by searchWholeFileCheckBox
|
||||
internal var supportPinyin by supportPinyinCheckBox
|
||||
|
||||
fun reset(settings: AceSettings) {
|
||||
@ -150,6 +153,7 @@ internal class AceSettingsPanel {
|
||||
tagBackgroundColor = settings.tagBackgroundColor
|
||||
displayQuery = settings.displayQuery
|
||||
roundedTagCorners = settings.roundedTagCorners
|
||||
searchWholeFile = settings.searchWholeFile
|
||||
supportPinyin = settings.supportPinyin
|
||||
}
|
||||
|
||||
|
@ -4,12 +4,12 @@ import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.editor.markup.HighlighterLayer
|
||||
import com.intellij.openapi.editor.markup.HighlighterTargetArea.EXACT_RANGE
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter
|
||||
import org.acejump.config.AceConfig
|
||||
import org.acejump.control.Handler
|
||||
import org.acejump.control.Trigger
|
||||
import org.acejump.label.Pattern
|
||||
import org.acejump.label.Tagger
|
||||
import org.acejump.view.Boundary
|
||||
import org.acejump.view.Boundary.FULL_FILE_BOUNDARY
|
||||
import org.acejump.view.Marker
|
||||
import org.acejump.view.Model.LONG_DOCUMENT
|
||||
import org.acejump.view.Model.boundaries
|
||||
@ -76,20 +76,24 @@ object Finder : Resettable {
|
||||
* applying tags once we have received a "chunk" of search text.
|
||||
*/
|
||||
|
||||
private fun skimThenSearch() =
|
||||
if (results.size == 0 && LONG_DOCUMENT) {
|
||||
skim = true
|
||||
private fun skimThenSearch() {
|
||||
if (results.size == 0 && LONG_DOCUMENT && AceConfig.searchWholeFile) {
|
||||
logger.info("Skimming document for matches of: $query")
|
||||
skim = true
|
||||
search()
|
||||
skimTrigger(400L) { skim = false; search() }
|
||||
} else search()
|
||||
}
|
||||
else {
|
||||
search()
|
||||
}
|
||||
}
|
||||
|
||||
fun search(pattern: Pattern, bounds: Boundary = FULL_FILE_BOUNDARY) {
|
||||
fun search(pattern: Pattern, bounds: Boundary) {
|
||||
logger.info("Searching for regular expression: ${pattern.name} in $bounds")
|
||||
search(pattern.string, bounds)
|
||||
}
|
||||
|
||||
fun search(pattern: String, bounds: Boundary = FULL_FILE_BOUNDARY) {
|
||||
fun search(pattern: String, bounds: Boundary) {
|
||||
boundaries = bounds
|
||||
// TODO: Fix this broken reset
|
||||
reset()
|
||||
@ -98,13 +102,25 @@ object Finder : Resettable {
|
||||
}
|
||||
|
||||
fun search(model: AceFindModel = AceFindModel(query)) {
|
||||
measureTimeMillis {
|
||||
results = Scanner.find(model, results)
|
||||
}.let { logger.info("Found ${results.size} matching sites in $it ms") }
|
||||
val time = measureTimeMillis {
|
||||
results = Scanner.find(model, calculateSearchBoundaries(), results)
|
||||
}
|
||||
|
||||
logger.info("Found ${results.size} matching sites in $time ms")
|
||||
|
||||
markResults(results, model)
|
||||
}
|
||||
|
||||
private fun calculateSearchBoundaries(): IntRange {
|
||||
if (AceConfig.searchWholeFile) {
|
||||
return boundaries.intRange()
|
||||
}
|
||||
|
||||
val bounds1 = boundaries
|
||||
val bounds2 = Boundary.SCREEN_BOUNDARY
|
||||
return max(bounds1.start, bounds2.start)..min(bounds1.endInclusive, bounds2.endInclusive)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used by IdeaVim integration plugin and must not be inlined.
|
||||
*
|
||||
|
@ -1,9 +1,7 @@
|
||||
package org.acejump.search
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import org.acejump.view.Boundary.FULL_FILE_BOUNDARY
|
||||
import org.acejump.view.Model.LONG_DOCUMENT
|
||||
import org.acejump.view.Model.boundaries
|
||||
import org.acejump.view.Model.LONG_DOCUMENT_LENGTH
|
||||
import org.acejump.view.Model.editorText
|
||||
import java.util.*
|
||||
import kotlin.streams.toList
|
||||
@ -22,9 +20,9 @@ internal object Scanner {
|
||||
* will filter prior results instead of searching the editor contents.
|
||||
*/
|
||||
|
||||
fun find(model: AceFindModel, cache: Set<Int> = emptySet()): SortedSet<Int> =
|
||||
if (!LONG_DOCUMENT || cache.size != 0 || boundaries != FULL_FILE_BOUNDARY)
|
||||
editorText.search(model, cache, boundaries.intRange()).toSortedSet()
|
||||
fun find(model: AceFindModel, boundaries: IntRange, cache: Set<Int> = emptySet()): SortedSet<Int> =
|
||||
if (cache.isNotEmpty() || (boundaries.last - boundaries.first) < LONG_DOCUMENT_LENGTH)
|
||||
editorText.search(model, cache, boundaries).toSortedSet()
|
||||
else editorText.chunk().parallelStream().map { chunk ->
|
||||
editorText.search(model, cache, chunk)
|
||||
}.toList().flatten().toSortedSet()
|
||||
|
@ -57,9 +57,9 @@ object Model {
|
||||
val arcD
|
||||
get() = if (AceConfig.roundedTagCorners) rectHeight - 6 else 1
|
||||
var viewBounds = 0..0
|
||||
const val DEFAULT_BUFFER = 30000
|
||||
const val LONG_DOCUMENT_LENGTH = 100000
|
||||
val LONG_DOCUMENT
|
||||
get() = DEFAULT_BUFFER < editorText.length
|
||||
get() = LONG_DOCUMENT_LENGTH < editorText.length
|
||||
const val MAX_TAG_RESULTS = 300
|
||||
|
||||
val defaultBoundary = FULL_FILE_BOUNDARY
|
||||
|
@ -19,4 +19,6 @@ appearanceHeading=Appearance
|
||||
displayQueryLabel=Display search query
|
||||
roundedTagCornersLabel=Rounded tag corners
|
||||
languagesHeading=Language
|
||||
behaviorHeading=Behavior
|
||||
searchWholeFileLabel=Search whole file
|
||||
supportPinyin=Support Pinyin selection
|
||||
|
Loading…
Reference in New Issue
Block a user