Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

// Use the same version and group for the jar and the plugin
val currentVersion = "1.10.0"
val currentVersion = "1.11.0"
val myGroup = "com.mituuz"
version = currentVersion
group = myGroup
Expand All @@ -40,15 +40,7 @@ intellijPlatform {
changeNotes = """
<h2>Version $currentVersion</h2>
<ul>
<li>Add an option to load full file contents in the FuzzyGrep preview window
<ul>
<li>Uses full highlighting</li>
<li>On by default</li>
<li>Thanks to <a href="https://github.com/givemeurhats">givemeurhats</a> for highlighting this issue</li>
</ul>
</li>
<li>Update IntelliJ platform plugin to 2.7.2</li>
<li>Update Gradle to 9.0.0</li>
<li>Update deprecated method calls</li>
</ul>
""".trimIndent()

Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Version 1.11.0

- Update deprecated method calls

## Version 1.10.0

- Add an option to load full file contents in the FuzzyGrep preview window
Expand Down
60 changes: 30 additions & 30 deletions src/main/kotlin/com/mituuz/fuzzier/FuzzyAction.kt
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
/*
MIT License

Copyright (c) 2025 Mitja Leino

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
* MIT License
*
* Copyright (c) 2025 Mitja Leino
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.mituuz.fuzzier

import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.actionSystem.IdeActions
import com.intellij.openapi.actionSystem.KeyboardShortcut
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.components.service
import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Document
Expand Down Expand Up @@ -68,6 +64,7 @@ abstract class FuzzyAction : AnAction() {
protected lateinit var projectState: FuzzierSettingsService.State
protected val globalState = service<FuzzierGlobalSettingsService>().state
protected var defaultDoc: Document? = null

@Volatile
var currentTask: Future<*>? = null
val fuzzierUtil = FuzzierUtil()
Expand Down Expand Up @@ -152,15 +149,17 @@ abstract class FuzzyAction : AnAction() {
})

val document = component.searchField.document
document.addDocumentListener(object : DocumentListener {
val listener: DocumentListener = object : DocumentListener {
override fun documentChanged(event: DocumentEvent) {
debounceTimer?.cancel()
val debouncePeriod = globalState.debouncePeriod
debounceTimer = Timer().schedule(debouncePeriod.toLong()) {
updateListContents(project, component.searchField.text)
}
}
})
}

document.addDocumentListener(listener, popup)
}

abstract fun updateListContents(project: Project, searchString: String)
Expand All @@ -180,7 +179,8 @@ abstract class FuzzyAction : AnAction() {
actionManager.setActionHandler(IdeActions.ACTION_EDITOR_MOVE_CARET_UP, originalUpHandler)
}

class FuzzyListActionHandler(private val fuzzyAction: FuzzyAction, private val isUp: Boolean) : EditorActionHandler() {
class FuzzyListActionHandler(private val fuzzyAction: FuzzyAction, private val isUp: Boolean) :
EditorActionHandler() {
override fun doExecute(editor: Editor, caret: Caret?, dataContext: DataContext?) {
if (isUp) {
fuzzyAction.moveListUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
*/
package com.mituuz.fuzzier.components

import com.intellij.openapi.Disposable
import com.intellij.openapi.components.service
import com.intellij.openapi.ui.ComboBox
import com.intellij.openapi.util.Disposer
import com.intellij.ui.JBIntSpinner
import com.intellij.ui.components.JBCheckBox
import com.intellij.ui.components.JBLabel
Expand All @@ -36,7 +38,9 @@ import com.mituuz.fuzzier.settings.FuzzierGlobalSettingsService.SearchPosition
import java.awt.Component
import javax.swing.*

class FuzzierGlobalSettingsComponent {
class FuzzierGlobalSettingsComponent(
val disposable: Disposable,
) {
var jPanel: JPanel

/////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -299,6 +303,7 @@ class FuzzierGlobalSettingsComponent {
.addComponent(JBLabel("<html><h2>Reset window</h2></html>"))
.addComponent(resetWindowDimension)
.panel
Disposer.register(disposable, testBench)
}


Expand Down
98 changes: 63 additions & 35 deletions src/main/kotlin/com/mituuz/fuzzier/components/TestBenchComponent.kt
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
/*
MIT License

Copyright (c) 2025 Mitja Leino

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
* MIT License
*
* Copyright (c) 2025 Mitja Leino
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.mituuz.fuzzier.components

import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.service
import com.intellij.openapi.editor.event.DocumentEvent
Expand All @@ -38,8 +39,8 @@ import com.intellij.ui.table.JBTable
import com.intellij.uiDesigner.core.GridConstraints
import com.intellij.uiDesigner.core.GridLayoutManager
import com.mituuz.fuzzier.entities.FuzzyContainer
import com.mituuz.fuzzier.entities.StringEvaluator
import com.mituuz.fuzzier.entities.FuzzyMatchContainer
import com.mituuz.fuzzier.entities.StringEvaluator
import com.mituuz.fuzzier.settings.FuzzierSettingsService
import com.mituuz.fuzzier.util.FuzzierUtil
import org.apache.commons.lang3.StringUtils
Expand All @@ -51,11 +52,13 @@ import javax.swing.JPanel
import javax.swing.table.DefaultTableModel
import kotlin.concurrent.schedule

class TestBenchComponent : JPanel() {
private val columnNames = arrayOf("Filename", "Filepath", "Streak", "MultiMatch", "PartialPath", "Filename", "Total")
class TestBenchComponent : JPanel(), Disposable {
private val columnNames =
arrayOf("Filename", "Filepath", "Streak", "MultiMatch", "PartialPath", "Filename", "Total")
private val table = JBTable()
private var searchField = EditorTextField()
private var debounceTimer: TimerTask? = null

@Volatile
var currentTask: Future<*>? = null
private lateinit var liveSettingsComponent: FuzzierGlobalSettingsComponent
Expand Down Expand Up @@ -112,21 +115,22 @@ class TestBenchComponent : JPanel() {

// Add a listener that updates the search list every time a change is made
val document = searchField.document

document.addDocumentListener(object : DocumentListener {
val listener: DocumentListener = object : DocumentListener {
override fun documentChanged(event: DocumentEvent) {
debounceTimer?.cancel()
val debouncePeriod = liveSettingsComponent.debounceTimerValue.getIntSpinner().value as Int
debounceTimer = Timer().schedule(debouncePeriod.toLong()) {
updateListContents(project, searchField.text)
}
}
})
}

document.addDocumentListener(listener, liveSettingsComponent.disposable)
}

fun updateListContents(project: Project, searchString: String) {
if (StringUtils.isBlank(searchString)) {
ApplicationManager.getApplication().invokeLater {
ApplicationManager.getApplication().invokeLater {
table.model = DefaultTableModel()
}
return
Expand Down Expand Up @@ -164,8 +168,10 @@ class TestBenchComponent : JPanel() {
}
}

private fun process(project: Project, stringEvaluator: StringEvaluator, searchString: String,
listModel: DefaultListModel<FuzzyContainer>) {
private fun process(
project: Project, stringEvaluator: StringEvaluator, searchString: String,
listModel: DefaultListModel<FuzzyContainer>
) {
val moduleManager = ModuleManager.getInstance(project)
if (project.service<FuzzierSettingsService>().state.isProject) {
processProject(project, stringEvaluator, searchString, listModel)
Expand All @@ -174,8 +180,10 @@ class TestBenchComponent : JPanel() {
}
}

private fun processProject(project: Project, stringEvaluator: StringEvaluator,
searchString: String, listModel: DefaultListModel<FuzzyContainer>) {
private fun processProject(
project: Project, stringEvaluator: StringEvaluator,
searchString: String, listModel: DefaultListModel<FuzzyContainer>
) {
val ss = FuzzierUtil.cleanSearchString(searchString, projectState.ignoredCharacters)
val contentIterator = stringEvaluator.getContentIterator(project.name, ss, listModel, null)

Expand All @@ -188,8 +196,10 @@ class TestBenchComponent : JPanel() {
ProjectFileIndex.getInstance(project).iterateContent(contentIterator)
}

private fun processModules(moduleManager: ModuleManager, stringEvaluator: StringEvaluator,
searchString: String, listModel: DefaultListModel<FuzzyContainer>) {
private fun processModules(
moduleManager: ModuleManager, stringEvaluator: StringEvaluator,
searchString: String, listModel: DefaultListModel<FuzzyContainer>
) {
for (module in moduleManager.modules) {
val moduleFileIndex = module.rootManager.fileIndex
val ss = FuzzierUtil.cleanSearchString(searchString, projectState.ignoredCharacters)
Expand All @@ -205,4 +215,22 @@ class TestBenchComponent : JPanel() {
moduleFileIndex.iterateContent(contentIterator)
}
}

override fun dispose() {
debounceTimer?.cancel()
debounceTimer = null

currentTask?.let { task ->
if (!task.isDone) task.cancel(true)
}
currentTask = null

ApplicationManager.getApplication().invokeLater {
try {
table.setPaintBusy(false)
} catch (_: Throwable) {
// Ignore this
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
*/
package com.mituuz.fuzzier.settings

import com.intellij.openapi.Disposable
import com.intellij.openapi.components.service
import com.intellij.openapi.options.Configurable
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.NlsContexts
import com.mituuz.fuzzier.components.FuzzierGlobalSettingsComponent
import com.mituuz.fuzzier.entities.FuzzyContainer.FilenameType
Expand All @@ -34,13 +36,15 @@ import javax.swing.JComponent
class FuzzierGlobalSettingsConfigurable : Configurable {
private lateinit var component: FuzzierGlobalSettingsComponent
private var state = service<FuzzierGlobalSettingsService>().state
private var uiDisposable: Disposable? = null

override fun getDisplayName(): @NlsContexts.ConfigurableName String? {
override fun getDisplayName(): @NlsContexts.ConfigurableName String {
return "Fuzzier Global Settings"
}

override fun createComponent(): JComponent? {
component = FuzzierGlobalSettingsComponent()
override fun createComponent(): JComponent {
uiDisposable = Disposer.newDisposable("FuzzierGlobalSettingsConfigurable")
component = FuzzierGlobalSettingsComponent(uiDisposable!!)
component.newTabSelect.getCheckBox().isSelected = state.newTab
component.recentFileModeSelector.getRecentFilesTypeComboBox().selectedIndex = state.recentFilesMode.ordinal
component.defaultDimension.getIntSpinner(4).value = state.defaultPopupHeight
Expand Down Expand Up @@ -132,4 +136,9 @@ class FuzzierGlobalSettingsConfigurable : Configurable {
state.matchWeightStreakModifier = component.matchWeightStreakModifier.getIntSpinner().value as Int
state.matchWeightFilename = component.matchWeightFilename.getIntSpinner().value as Int
}

override fun disposeUIResources() {
Disposer.dispose(uiDisposable ?: return)
uiDisposable = null
}
}
Loading
Loading