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
20 changes: 5 additions & 15 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.2.2"
val currentVersion = "2.3.0"
val myGroup = "com.mituuz"
version = currentVersion
group = myGroup
Expand All @@ -43,26 +43,17 @@ intellijPlatform {
<li>
Update dependencies
</li>
</ul>
<h2>Version 2.2.1</h2>
<ul>
<li>
Update dependencies
Fix ETD errors
</li>
</ul>
<h2>Version 2.2.0</h2>
<ul>
<li>
Implement Fuzzy File Search (Open Tabs) action
<ul>
<li><code>com.mituuz.fuzzier.search.FuzzierOpenTabs</code></li>
</ul>
Update minimum version to 2026.1
</li>
</ul>
""".trimIndent()

ideaVersion {
sinceBuild = "251"
sinceBuild = "261"
untilBuild = provider { null }
}
}
Expand Down Expand Up @@ -94,8 +85,7 @@ repositories {

dependencies {
intellijPlatform {
// TODO: Update minimum version to 2025.3 and replace this deprecated config
intellijIdeaCommunity(libs.versions.communityVersion.get())
intellijIdea("2026.1.1")
pluginVerifier()
zipSigner()
testFramework(TestFrameworkType.Platform)
Expand Down
4 changes: 3 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Changelog

## Version 2.2.2
## Version 2.3.0

- Update dependencies
- Fix ETD errors
- Update minimum version to 2026.1

## Version 2.2.1

Expand Down
23 changes: 15 additions & 8 deletions src/main/kotlin/com/mituuz/fuzzier/actions/FuzzyAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.intellij.notification.Notification
import com.intellij.notification.NotificationType
import com.intellij.notification.Notifications
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.application.EDT
import com.intellij.openapi.components.service
import com.intellij.openapi.editor.Caret
import com.intellij.openapi.editor.Document
Expand Down Expand Up @@ -99,14 +100,20 @@ abstract class FuzzyAction : AnAction() {
}

override fun actionPerformed(actionEvent: AnActionEvent) {
val project = actionEvent.project
if (project != null) {
projectState = project.service<FuzzierSettingsService>().state
FuzzierUtil.parseModules(project)
setCustomHandlers()
actionScope?.cancel()
actionScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
runAction(project, actionEvent)
val project = actionEvent.project ?: return

actionScope?.cancel()
actionScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)

actionScope?.launch {
val state = project.service<FuzzierSettingsService>().state
FuzzierUtil.parseModules(project, state)

withContext(Dispatchers.EDT) {
projectState = state
setCustomHandlers()
runAction(project, actionEvent)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class TestBenchComponent : JPanel(), Disposable {
val project = ProjectManager.getInstance().openProjects[0]
projectState = project.service<FuzzierSettingsService>().state

FuzzierUtil.parseModules(project)
FuzzierUtil.parseModules(project, projectState)

liveSettingsComponent = settingsComponent
layout = GridLayoutManager(2, 1)
Expand Down
12 changes: 7 additions & 5 deletions src/main/kotlin/com/mituuz/fuzzier/grep/FuzzyGrep.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,19 @@ open class FuzzyGrep : FuzzyAction() {

val projectBasePath = project.basePath.toString()
currentLaunchJob = actionScope?.launch(Dispatchers.EDT) {
val backendResult: Result<BackendStrategy> = backendResolver.resolveBackend(commandRunner, projectBasePath)
backend = backendResult.getOrNull()
val popupTitle = grepConfig.getPopupTitle(backend!!.name)

val backendResult: Result<BackendStrategy> = withContext(Dispatchers.IO) {
backendResolver.resolveBackend(commandRunner, projectBasePath)
}
if (backendResult.isFailure) {
showNotification(
"No search command found", "Fuzzy Grep failed: no suitable grep command found", project
)
return@launch
}
if (backend == null) return@launch

val resolvedBackend = backendResult.getOrNull() ?: return@launch
backend = resolvedBackend
val popupTitle = grepConfig.getPopupTitle(resolvedBackend.name)

yield()
defaultDoc = EditorFactory.getInstance().createDocument("")
Expand Down
7 changes: 5 additions & 2 deletions src/main/kotlin/com/mituuz/fuzzier/operation/FuzzyMover.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ class FuzzyMover : FilesystemAction() {
createListeners(project)
val currentEditor = FileEditorManager.getInstance(project).selectedTextEditor
if (currentEditor != null) {
currentFile = currentEditor.virtualFile
component.fileList.setEmptyText("Press enter to use current file: ${currentFile.path}")
val editorFile = currentEditor.virtualFile
if (editorFile != null) {
currentFile = editorFile
component.fileList.setEmptyText("Press enter to use current file: ${currentFile.path}")
}
}

val maybePopup = getPopupProvider().show(
Expand Down
85 changes: 46 additions & 39 deletions src/main/kotlin/com/mituuz/fuzzier/runner/CommandRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.intellij.execution.configurations.GeneralCommandLine
import com.intellij.execution.process.OSProcessHandler
import com.intellij.execution.process.ProcessEvent
import com.intellij.execution.process.ProcessListener
import com.intellij.openapi.application.EDT
import com.intellij.openapi.util.Key
import com.mituuz.fuzzier.entities.FuzzyContainer
import com.mituuz.fuzzier.entities.RowContainer
Expand All @@ -46,28 +47,28 @@ class CommandRunner {
projectBasePath: String
): String? {
return try {
val commandLine = GeneralCommandLine(commands)
.withWorkDirectory(projectBasePath)
.withRedirectErrorStream(true)
val output = StringBuilder()
val processHandler = OSProcessHandler(commandLine)
withContext(Dispatchers.IO) {
val commandLine = GeneralCommandLine(commands)
.withWorkDirectory(projectBasePath)
.withRedirectErrorStream(true)
val processHandler = OSProcessHandler(commandLine)

processHandler.addProcessListener(object : ProcessListener {
override fun onTextAvailable(event: ProcessEvent, outputType: Key<*>) {
if (output.length < MAX_OUTPUT_SIZE) {
output.appendLine(event.text.replace("\n", ""))
processHandler.addProcessListener(object : ProcessListener {
override fun onTextAvailable(event: ProcessEvent, outputType: Key<*>) {
if (output.length < MAX_OUTPUT_SIZE) {
output.appendLine(event.text.replace("\n", ""))
}
}
}
})
})

try {
withContext(Dispatchers.IO) {
try {
processHandler.startNotify()
processHandler.waitFor(2000)
}
} finally {
if (!processHandler.isProcessTerminated) {
processHandler.destroyProcess()
} finally {
if (!processHandler.isProcessTerminated) {
processHandler.destroyProcess()
}
}
}
output.toString()
Expand All @@ -86,39 +87,45 @@ class CommandRunner {
parseOutputLine: (String, String) -> RowContainer?
) {
try {
val commandLine = GeneralCommandLine(commands)
.withWorkDirectory(projectBasePath)
.withRedirectErrorStream(true)

val processHandler = OSProcessHandler(commandLine)
val results = mutableListOf<RowContainer>()
var count = 0

processHandler.addProcessListener(object : ProcessListener {
override fun onTextAvailable(event: ProcessEvent, outputType: Key<*>) {
if (count >= MAX_NUMBER_OR_RESULTS) return
withContext(Dispatchers.IO) {
val commandLine = GeneralCommandLine(commands)
.withWorkDirectory(projectBasePath)
.withRedirectErrorStream(true)

val processHandler = OSProcessHandler(commandLine)

event.text.lines().forEach { line ->
if (count >= MAX_NUMBER_OR_RESULTS) return@forEach
if (line.isNotBlank()) {
val rowContainer = parseOutputLine(line, projectBasePath)
if (rowContainer != null) {
listModel.addElement(rowContainer)
count++
processHandler.addProcessListener(object : ProcessListener {
override fun onTextAvailable(event: ProcessEvent, outputType: Key<*>) {
if (count >= MAX_NUMBER_OR_RESULTS) return

event.text.lines().forEach { line ->
if (count >= MAX_NUMBER_OR_RESULTS) return@forEach
if (line.isNotBlank()) {
val rowContainer = parseOutputLine(line, projectBasePath)
if (rowContainer != null) {
results.add(rowContainer)
count++
}
}
}
}
}
})
})

try {
withContext(Dispatchers.IO) {
try {
processHandler.startNotify()
processHandler.waitFor(2000)
} finally {
if (!processHandler.isProcessTerminated) {
processHandler.destroyProcess()
}
}
} finally {
if (!processHandler.isProcessTerminated) {
processHandler.destroyProcess()
}
}

withContext(Dispatchers.EDT) {
results.forEach { listModel.addElement(it) }
}
} catch (_: InterruptedException) {
throw InterruptedException()
Expand Down
7 changes: 3 additions & 4 deletions src/main/kotlin/com/mituuz/fuzzier/util/FuzzierUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package com.mituuz.fuzzier.util

import com.intellij.openapi.components.service
import com.intellij.openapi.module.Module
import com.intellij.openapi.module.ModuleManager
import com.intellij.openapi.project.Project
Expand Down Expand Up @@ -70,7 +69,7 @@ class FuzzierUtil {
*
* Populates `FuzzierSettings.state.modules`-field
*/
fun parseModules(project: Project) {
fun parseModules(project: Project, state: FuzzierSettingsService.State) {
val moduleManager = ModuleManager.getInstance(project)

// Gather all modules and paths into a list
Expand Down Expand Up @@ -101,11 +100,11 @@ class FuzzierUtil {

if (moduleList.isEmpty() && project.basePath != null) {
moduleList.add(ModuleContainer(project.name, project.basePath!!))
project.service<FuzzierSettingsService>().state.isProject = true
state.isProject = true
}

val moduleMap = listToMap(moduleList)
project.service<FuzzierSettingsService>().state.modules = moduleMap
state.modules = moduleMap
}

private fun shortenModulePaths(modules: List<ModuleContainer>) {
Expand Down
16 changes: 8 additions & 8 deletions src/test/kotlin/com/mituuz/fuzzier/util/FuzzierUtilTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FuzzierUtilTest {
listOf("src2", "/src2/file2"),
listOf("src3", "/src3/file3")
)
FuzzierUtil.parseModules(myFixture.project)
FuzzierUtil.parseModules(myFixture.project, myFixture.project.service<FuzzierSettingsService>().state)

val modules = myFixture.project.service<FuzzierSettingsService>().state.modules
assertEquals(3, modules.size)
Expand All @@ -68,7 +68,7 @@ class FuzzierUtilTest {
listOf("to/src2", "/to/src2/file2"),
listOf("module/src3", "/module/src3/file3")
)
FuzzierUtil.parseModules(myFixture.project)
FuzzierUtil.parseModules(myFixture.project, myFixture.project.service<FuzzierSettingsService>().state)

val modules = myFixture.project.service<FuzzierSettingsService>().state.modules
assertEquals(3, modules.size)
Expand All @@ -86,7 +86,7 @@ class FuzzierUtilTest {
listOf("src1/module1", "/src1/module1/file1"),
listOf("src1/module2", "/src1/module2/file1")
)
FuzzierUtil.parseModules(myFixture.project)
FuzzierUtil.parseModules(myFixture.project, myFixture.project.service<FuzzierSettingsService>().state)

val modules = myFixture.project.service<FuzzierSettingsService>().state.modules

Expand All @@ -103,7 +103,7 @@ class FuzzierUtilTest {
listOf("src1/module1", "/src1/module1/file1"), listOf("src2", "/src2/file1")
)
val project = myFixture.project
FuzzierUtil.parseModules(project)
FuzzierUtil.parseModules(project, project.service<FuzzierSettingsService>().state)

val modules = myFixture.project.service<FuzzierSettingsService>().state.modules
assertEquals(3, modules.size)
Expand Down Expand Up @@ -132,7 +132,7 @@ class FuzzierUtilTest {
listOf("module/src3", "/module/src3/file3")
)
val project = myFixture.project
FuzzierUtil.parseModules(project)
FuzzierUtil.parseModules(project, project.service<FuzzierSettingsService>().state)

val modules = myFixture.project.service<FuzzierSettingsService>().state.modules
assertEquals(3, modules.size)
Expand All @@ -156,7 +156,7 @@ class FuzzierUtilTest {
@Test
fun `Remove module paths, point only to project root`() {
val myFixture = testUtil.setUpMultiModuleProject(listOf("path/src1", "/path/src1/file1"))
FuzzierUtil.parseModules(myFixture.project)
FuzzierUtil.parseModules(myFixture.project, myFixture.project.service<FuzzierSettingsService>().state)

val modules = myFixture.project.service<FuzzierSettingsService>().state.modules
assertEquals(1, modules.size)
Expand All @@ -168,7 +168,7 @@ class FuzzierUtilTest {
@Test
fun `Remove module paths, file not included`() {
val myFixture = testUtil.setUpMultiModuleProject(listOf("path/src1", "/path/src1/file1"))
FuzzierUtil.parseModules(myFixture.project)
FuzzierUtil.parseModules(myFixture.project, myFixture.project.service<FuzzierSettingsService>().state)

val modules = myFixture.project.service<FuzzierSettingsService>().state.modules
assertEquals(1, modules.size)
Expand All @@ -179,7 +179,7 @@ class FuzzierUtilTest {
@Test
fun parseModulesSingleModule() {
val myFixture = testUtil.setUpMultiModuleProject(listOf("src1", "/src1/file1"))
FuzzierUtil.parseModules(myFixture.project)
FuzzierUtil.parseModules(myFixture.project, myFixture.project.service<FuzzierSettingsService>().state)

val modules = myFixture.project.service<FuzzierSettingsService>().state.modules
assertEquals(1, modules.size)
Expand Down
Loading