Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ea0103f
Verify that project base path exists before using it as the working dir
MituuZ Dec 21, 2025
20beffe
Change API to enable kotlin only backend
MituuZ Dec 21, 2025
2361f21
Return emptylist
MituuZ Dec 21, 2025
f9bba18
Add plan for fuzzier grep and modify the interface signature
MituuZ Dec 21, 2025
9a5d57c
Separate the kotlin backend to its own file
MituuZ Dec 21, 2025
4cee476
Smarter word search
MituuZ Dec 21, 2025
68ec2b1
Copy existing logic
MituuZ Dec 24, 2025
fcf8409
Skip binary files
MituuZ Dec 24, 2025
24710cd
Add timer logging
MituuZ Dec 24, 2025
192f6b5
Use coroutines for command and cancel command execution correctly
MituuZ Dec 24, 2025
0f10579
Use pure virtual files instead of file paths
MituuZ Dec 24, 2025
a5cce1f
First working iteration
MituuZ Dec 24, 2025
f192e64
Add support for secondary field
MituuZ Dec 24, 2025
54a4a00
Only fetch clm once
MituuZ Dec 24, 2025
9e87975
Remove initial plan
MituuZ Dec 25, 2025
3b574a0
Only use the first known complete word for search optimization
MituuZ Jan 10, 2026
fb6a0ad
Add setting to force fuzzier as grep backend
MituuZ Jan 11, 2026
002c13e
Increment version and add change notes
MituuZ Jan 11, 2026
a64ecca
Add change notes for 157
MituuZ Jan 18, 2026
481a74f
Remove perf printing
MituuZ Jan 18, 2026
4a87684
Fix array check and use max size from settings
MituuZ Jan 18, 2026
2879c11
Handle file read failures
MituuZ Jan 18, 2026
f2dbd5f
gs
MituuZ Jan 18, 2026
534c2b0
Non-nullable parameter
MituuZ Jan 18, 2026
775101e
Update build changelog
MituuZ Jan 18, 2026
0d39517
Separate ripgrep backend to a separate file
MituuZ Jan 18, 2026
c5071fe
Cleanup backend interface
MituuZ Jan 18, 2026
5df4c23
Remove unnecessary method
MituuZ Jan 18, 2026
3c95b6f
Move tests to a correct file
MituuZ Jan 18, 2026
18e2b06
Collapse redudant interface to a concrete class
MituuZ Jan 18, 2026
fb26702
Separate utils and create tests
MituuZ Jan 18, 2026
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
73 changes: 7 additions & 66 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 = "2.0.1"
val currentVersion = "2.1.0"
val myGroup = "com.mituuz"
version = currentVersion
group = myGroup
Expand All @@ -40,78 +40,19 @@ intellijPlatform {
changeNotes = """
<h2>Version $currentVersion</h2>
<ul>
<li>Fix incorrect <code>grep</code> command</li>
<li>Partially fix <code>findstr</code> command</li>
<li>Re-add the backend name to the popup title</li>
</ul>
<h3>Known issues</h3>
<ul>
<li><code>findstr</code> does not work with currently open tabs
<li>Add a fallback solution for file path handling on Windows
<ul>
<li>To reduce the maintenance burden, I may remove support later</li>
<li>Performance is poor enough that I thought that the command wasn't returning any results</li>
<li>Thanks to <a href="https://github.com/s0ders">s0ders</a>!</li>
</ul>
</li>
</ul>
<h2>Version 2.0.0</h2>
<p>This version contains larger refactors and multiple new actions enabled by them.</p>
<p>I&#39;m updating the existing package structure to keep things nicer and not supporting the old actions to avoid possible problems in the future.</p>

<h3>Breaking changes</h3>
<p><strong>Rename existing actions</strong></p>
<ul>
<li><code>com.mituuz.fuzzier.FuzzyGrepCaseInsensitive</code> to <code>com.mituuz.fuzzier.grep.FuzzyGrepCI</code></li>
<li><code>com.mituuz.fuzzier.FuzzyGrep</code> to <code>com.mituuz.fuzzier.grep.FuzzyGrep</code></li>
<li><code>com.mituuz.fuzzier.Fuzzier</code> to <code>com.mituuz.fuzzier.search.Fuzzier</code></li>
<li><code>com.mituuz.fuzzier.FuzzierVCS</code> to <code>com.mituuz.fuzzier.search.FuzzierVCS</code></li>
<li><code>com.mituuz.fuzzier.FuzzyMover</code> to <code>com.mituuz.fuzzier.operation.FuzzyMover</code></li>
</ul>
<p><strong>Update default list movement keys</strong></p>
<ul>
<li>From <code>CTRL + j</code> and <code>CTRL + k</code> to <code>CTRL + n</code> and <code>CTRL + p</code></li>
</ul>

<h3>New actions</h3>
<p>Added some new grep variations</p>
<pre><code>com.mituuz.fuzzier.grep.FuzzyGrepOpenTabsCI
com.mituuz.fuzzier.grep.FuzzyGrepOpenTabs
com.mituuz.fuzzier.grep.FuzzyGrepCurrentBufferCI
com.mituuz.fuzzier.grep.FuzzyGrepCurrentBuffer</code></pre>

<h3>Example mappings</h3>
<pre><code>&quot; File search
nmap &lt;Leader&gt;sf &lt;action&gt;(com.mituuz.fuzzier.search.Fuzzier)
nmap &lt;Leader&gt;sg &lt;action&gt;(com.mituuz.fuzzier.search.FuzzierVCS)

&quot; Mover
nmap &lt;Leader&gt;fm &lt;action&gt;(com.mituuz.fuzzier.operation.FuzzyMover)

&quot; Grepping
nmap &lt;Leader&gt;ss &lt;action&gt;(com.mituuz.fuzzier.grep.FuzzyGrepCI)
nmap &lt;Leader&gt;sS &lt;action&gt;(com.mituuz.fuzzier.grep.FuzzyGrep)
nmap &lt;Leader&gt;st &lt;action&gt;(com.mituuz.fuzzier.grep.FuzzyGrepOpenTabsCI)
nmap &lt;Leader&gt;sT &lt;action&gt;(com.mituuz.fuzzier.grep.FuzzyGrepOpenTabs)
nmap &lt;Leader&gt;sb &lt;action&gt;(com.mituuz.fuzzier.grep.FuzzyGrepCurrentBufferCI)
nmap &lt;Leader&gt;sB &lt;action&gt;(com.mituuz.fuzzier.grep.FuzzyGrepCurrentBuffer)</code></pre>

<h3>New features</h3>
<ul>
<li>Popup now defaults to auto-sized, which scales with the current window</li>
<li>You can revert this from the settings</li>
</ul>

<h3>Other changes</h3>
<ul>
<li>Refactor file search to use coroutines
<li>Add a built-in Fuzzier grep backend
<ul>
<li>Handle list size limiting during processing instead of doing them separately</li>
<li>Replaces <code>grep</code> and <code>findstr</code> fallback implementations</li>
<li>Add setting to choose between Dynamic (uses <code>rg</code> if available, otherwise Fuzzier) and Fuzzier backends</li>
</ul>
</li>
<li>Add debouncing for file preview using <code>SingleAlarm</code></li>
<li>Refactor everything</li>
<li>Remove manual handling of the divider location (use JBSplitter instead) and unify styling</li>
<li>Migrate from <code>Timer</code> to coroutines for debouncing</li>
</ul>

""".trimIndent()

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

## Version 2.1.0

- Add a fallback solution for file path handling on Windows
- Thanks to [s0ders](https://github.com/s0ders)!
- Add a built-in Fuzzier grep backend
- Replaces `grep` and `findstr` fallback implementations
- Add setting to choose between Dynamic (uses `rg` if available, otherwise Fuzzier) and Fuzzier backends
- Migrate from `Timer` to coroutines for debouncing

## Version 2.0.1

- Fix incorrect `grep` command
Expand Down
25 changes: 15 additions & 10 deletions src/main/kotlin/com/mituuz/fuzzier/actions/FuzzyAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,15 @@ import kotlinx.coroutines.*
import java.awt.Component
import java.awt.Font
import java.awt.event.ActionEvent
import java.util.*
import java.util.Timer
import java.util.concurrent.ConcurrentHashMap
import javax.swing.*
import kotlin.concurrent.schedule

abstract class FuzzyAction : AnAction() {
lateinit var component: FuzzyComponent
lateinit var popup: JBPopup
private lateinit var originalDownHandler: EditorActionHandler
private lateinit var originalUpHandler: EditorActionHandler
private var debounceTimer: TimerTask? = null
private var originalDownHandler: EditorActionHandler? = null
private var originalUpHandler: EditorActionHandler? = null
private var debounceJob: Job? = null
protected lateinit var projectState: FuzzierSettingsService.State
protected val globalState = service<FuzzierGlobalSettingsService>().state
protected var defaultDoc: Document? = null
Expand Down Expand Up @@ -138,9 +135,10 @@ abstract class FuzzyAction : AnAction() {
val document = component.searchField.document
val listener: DocumentListener = object : DocumentListener {
override fun documentChanged(event: DocumentEvent) {
debounceTimer?.cancel()
debounceJob?.cancel()
val debouncePeriod = globalState.debouncePeriod
debounceTimer = Timer().schedule(debouncePeriod.toLong()) {
debounceJob = actionScope?.launch {
delay(debouncePeriod.toLong())
updateListContents(project, component.searchField.text)
}
}
Expand All @@ -161,6 +159,9 @@ abstract class FuzzyAction : AnAction() {
fun cleanupPopup() {
resetOriginalHandlers()

debounceJob?.cancel()
debounceJob = null

currentUpdateListContentJob?.cancel()
currentUpdateListContentJob = null

Expand All @@ -180,8 +181,12 @@ abstract class FuzzyAction : AnAction() {

fun resetOriginalHandlers() {
val actionManager = EditorActionManager.getInstance()
actionManager.setActionHandler(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN, originalDownHandler)
actionManager.setActionHandler(IdeActions.ACTION_EDITOR_MOVE_CARET_UP, originalUpHandler)
originalDownHandler?.let {
actionManager.setActionHandler(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN, it)
}
originalUpHandler?.let {
actionManager.setActionHandler(IdeActions.ACTION_EDITOR_MOVE_CARET_UP, it)
}
}

class FuzzyListActionHandler(private val fuzzyAction: FuzzyAction, private val isUp: Boolean) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,26 @@ class FuzzierGlobalSettingsComponent(
JBCheckBox(), "Fuzzy Grep: Preview entire file",
"""
Toggles showing the full file in the preview.<br><br>

If set, preview will use full syntax highlighting.<br>
Otherwise, preview will only use limited syntax highlighting and show a slice around the match.<br><br>
Disabling this option may improve performance on very large files,

Disabling this option may improve performance on very large files,
for small-to-medium files the performance impact is negligible.
""".trimIndent(),
false
)

val grepBackendSelector = SettingsComponent(
ComboBox<GrepBackend>(), "Grep backend",
"""
Select which backend to use for Fuzzy Grep.<br><br>
<strong>Dynamic</strong>: Uses ripgrep (rg) if available, otherwise falls back to Fuzzier.<br>
<strong>Fuzzier</strong>: Uses the built-in Fuzzier backend.
""".trimIndent(),
false
)

val globalExclusionTextArea: JBTextArea = JBTextArea().apply {
rows = 5
lineWrap = true
Expand Down Expand Up @@ -328,6 +338,7 @@ class FuzzierGlobalSettingsComponent(
.addComponent(debounceTimerValue)
.addComponent(fileListLimit)
.addComponent(fuzzyGrepShowFullFile)
.addComponent(grepBackendSelector)
.addComponent(globalExclusionSet)

.addSeparator()
Expand Down Expand Up @@ -430,6 +441,25 @@ class FuzzierGlobalSettingsComponent(
popupSizingSelector.getPopupSizingComboBox().addItem(s)
}

grepBackendSelector.getGrepBackendComboBox().renderer = object : DefaultListCellRenderer() {
override fun getListCellRendererComponent(
list: JList<*>?,
value: Any?,
index: Int,
isSelected: Boolean,
cellHasFocus: Boolean
): Component {
val renderer =
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus) as JLabel
val backend = value as GrepBackend
renderer.text = backend.text
return renderer
}
}
for (backend in GrepBackend.entries) {
grepBackendSelector.getGrepBackendComboBox().addItem(backend)
}

filenameTypeSelector.getFilenameTypeComboBox().renderer = object : DefaultListCellRenderer() {
override fun getListCellRendererComponent(
list: JList<*>?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ class SettingsComponent {
return component as ComboBox<PopupSizing>
}

fun getGrepBackendComboBox(): ComboBox<FuzzierGlobalSettingsService.GrepBackend> {
@Suppress("UNCHECKED_CAST")
return component as ComboBox<FuzzierGlobalSettingsService.GrepBackend>
}

fun getIntSpinner(index: Int): JBIntSpinner {
return (component as JPanel).getComponent(index) as JBIntSpinner
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,13 @@ import java.util.concurrent.Future
import javax.swing.DefaultListModel
import javax.swing.JPanel
import javax.swing.table.DefaultTableModel
import kotlin.concurrent.schedule

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
private var debounceJob: Job? = null

@Volatile
var currentTask: Future<*>? = null
Expand Down Expand Up @@ -122,9 +121,10 @@ class TestBenchComponent : JPanel(), Disposable {
val document = searchField.document
val listener: DocumentListener = object : DocumentListener {
override fun documentChanged(event: DocumentEvent) {
debounceTimer?.cancel()
debounceJob?.cancel()
val debouncePeriod = liveSettingsComponent.debounceTimerValue.getIntSpinner().value as Int
debounceTimer = Timer().schedule(debouncePeriod.toLong()) {
debounceJob = actionScope.launch {
delay(debouncePeriod.toLong())
updateListContents(project, searchField.text)
}
}
Expand Down Expand Up @@ -199,14 +199,16 @@ class TestBenchComponent : JPanel(), Disposable {
}

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

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

actionScope.cancel()

ApplicationManager.getApplication().invokeLater {
try {
table.setPaintBusy(false)
Expand Down
54 changes: 30 additions & 24 deletions src/main/kotlin/com/mituuz/fuzzier/entities/FuzzyContainer.kt
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
/*
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.entities

import com.intellij.openapi.vfs.VirtualFile
import com.mituuz.fuzzier.settings.FuzzierGlobalSettingsService

abstract class FuzzyContainer(val filePath: String, val basePath: String, val filename: String) {
abstract class FuzzyContainer(
val filePath: String,
val basePath: String,
val filename: String,
val virtualFile: VirtualFile? = null,
) {
/**
* Get display string for the popup
*/
Expand All @@ -34,7 +40,7 @@ abstract class FuzzyContainer(val filePath: String, val basePath: String, val fi
/**
* Get the complete URI for the file
*/
fun getFileUri() : String {
fun getFileUri(): String {
return "$basePath$filePath"
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/com/mituuz/fuzzier/entities/GrepConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@

package com.mituuz.fuzzier.entities

import com.intellij.openapi.vfs.VirtualFile

enum class CaseMode {
SENSITIVE,
INSENSITIVE,
}

class GrepConfig(
val targets: List<String>,
val targets: Set<VirtualFile>?,
val caseMode: CaseMode,
val title: String = "",
val supportsSecondaryField: Boolean = true,
Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/com/mituuz/fuzzier/entities/RowContainer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package com.mituuz.fuzzier.entities

import com.intellij.openapi.vfs.VirtualFile
import com.mituuz.fuzzier.settings.FuzzierGlobalSettingsService
import java.io.File

Expand All @@ -32,8 +33,9 @@ class RowContainer(
filename: String,
val rowNumber: Int,
val trimmedRow: String,
val columnNumber: Int = 0
) : FuzzyContainer(filePath, basePath, filename) {
val columnNumber: Int = 0,
virtualFile: VirtualFile? = null
) : FuzzyContainer(filePath, basePath, filename, virtualFile) {
companion object {
private val FILE_SEPARATOR: String = File.separator
private val RG_PATTERN: Regex = Regex("""^.+:\d+:\d+:\s*.+$""")
Expand Down
Loading