diff --git a/build.gradle.kts b/build.gradle.kts index 4b2a9e7e..487749a1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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 @@ -43,26 +43,17 @@ intellijPlatform {
  • Update dependencies
  • - -

    Version 2.2.1

    - -

    Version 2.2.0

    - """.trimIndent() ideaVersion { - sinceBuild = "251" + sinceBuild = "261" untilBuild = provider { null } } } @@ -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) diff --git a/changelog.md b/changelog.md index e270c99f..19b60925 100644 --- a/changelog.md +++ b/changelog.md @@ -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 diff --git a/src/main/kotlin/com/mituuz/fuzzier/actions/FuzzyAction.kt b/src/main/kotlin/com/mituuz/fuzzier/actions/FuzzyAction.kt index cb3e2c1e..799d953c 100644 --- a/src/main/kotlin/com/mituuz/fuzzier/actions/FuzzyAction.kt +++ b/src/main/kotlin/com/mituuz/fuzzier/actions/FuzzyAction.kt @@ -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 @@ -99,14 +100,20 @@ abstract class FuzzyAction : AnAction() { } override fun actionPerformed(actionEvent: AnActionEvent) { - val project = actionEvent.project - if (project != null) { - projectState = project.service().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().state + FuzzierUtil.parseModules(project, state) + + withContext(Dispatchers.EDT) { + projectState = state + setCustomHandlers() + runAction(project, actionEvent) + } } } diff --git a/src/main/kotlin/com/mituuz/fuzzier/components/TestBenchComponent.kt b/src/main/kotlin/com/mituuz/fuzzier/components/TestBenchComponent.kt index 09f63a26..ac871b04 100644 --- a/src/main/kotlin/com/mituuz/fuzzier/components/TestBenchComponent.kt +++ b/src/main/kotlin/com/mituuz/fuzzier/components/TestBenchComponent.kt @@ -69,7 +69,7 @@ class TestBenchComponent : JPanel(), Disposable { val project = ProjectManager.getInstance().openProjects[0] projectState = project.service().state - FuzzierUtil.parseModules(project) + FuzzierUtil.parseModules(project, projectState) liveSettingsComponent = settingsComponent layout = GridLayoutManager(2, 1) diff --git a/src/main/kotlin/com/mituuz/fuzzier/grep/FuzzyGrep.kt b/src/main/kotlin/com/mituuz/fuzzier/grep/FuzzyGrep.kt index fcddc9bd..528d928d 100644 --- a/src/main/kotlin/com/mituuz/fuzzier/grep/FuzzyGrep.kt +++ b/src/main/kotlin/com/mituuz/fuzzier/grep/FuzzyGrep.kt @@ -81,17 +81,19 @@ open class FuzzyGrep : FuzzyAction() { val projectBasePath = project.basePath.toString() currentLaunchJob = actionScope?.launch(Dispatchers.EDT) { - val backendResult: Result = backendResolver.resolveBackend(commandRunner, projectBasePath) - backend = backendResult.getOrNull() - val popupTitle = grepConfig.getPopupTitle(backend!!.name) - + val backendResult: Result = 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("") diff --git a/src/main/kotlin/com/mituuz/fuzzier/operation/FuzzyMover.kt b/src/main/kotlin/com/mituuz/fuzzier/operation/FuzzyMover.kt index 1c8244c0..c4e6ae48 100644 --- a/src/main/kotlin/com/mituuz/fuzzier/operation/FuzzyMover.kt +++ b/src/main/kotlin/com/mituuz/fuzzier/operation/FuzzyMover.kt @@ -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( diff --git a/src/main/kotlin/com/mituuz/fuzzier/runner/CommandRunner.kt b/src/main/kotlin/com/mituuz/fuzzier/runner/CommandRunner.kt index 1f05e5b8..6226363c 100644 --- a/src/main/kotlin/com/mituuz/fuzzier/runner/CommandRunner.kt +++ b/src/main/kotlin/com/mituuz/fuzzier/runner/CommandRunner.kt @@ -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 @@ -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() @@ -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() 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() diff --git a/src/main/kotlin/com/mituuz/fuzzier/util/FuzzierUtil.kt b/src/main/kotlin/com/mituuz/fuzzier/util/FuzzierUtil.kt index 7084f495..8de9d50e 100644 --- a/src/main/kotlin/com/mituuz/fuzzier/util/FuzzierUtil.kt +++ b/src/main/kotlin/com/mituuz/fuzzier/util/FuzzierUtil.kt @@ -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 @@ -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 @@ -101,11 +100,11 @@ class FuzzierUtil { if (moduleList.isEmpty() && project.basePath != null) { moduleList.add(ModuleContainer(project.name, project.basePath!!)) - project.service().state.isProject = true + state.isProject = true } val moduleMap = listToMap(moduleList) - project.service().state.modules = moduleMap + state.modules = moduleMap } private fun shortenModulePaths(modules: List) { diff --git a/src/test/kotlin/com/mituuz/fuzzier/util/FuzzierUtilTest.kt b/src/test/kotlin/com/mituuz/fuzzier/util/FuzzierUtilTest.kt index 41cbef4e..f3ef7b8a 100644 --- a/src/test/kotlin/com/mituuz/fuzzier/util/FuzzierUtilTest.kt +++ b/src/test/kotlin/com/mituuz/fuzzier/util/FuzzierUtilTest.kt @@ -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().state) val modules = myFixture.project.service().state.modules assertEquals(3, modules.size) @@ -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().state) val modules = myFixture.project.service().state.modules assertEquals(3, modules.size) @@ -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().state) val modules = myFixture.project.service().state.modules @@ -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().state) val modules = myFixture.project.service().state.modules assertEquals(3, modules.size) @@ -132,7 +132,7 @@ class FuzzierUtilTest { listOf("module/src3", "/module/src3/file3") ) val project = myFixture.project - FuzzierUtil.parseModules(project) + FuzzierUtil.parseModules(project, project.service().state) val modules = myFixture.project.service().state.modules assertEquals(3, modules.size) @@ -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().state) val modules = myFixture.project.service().state.modules assertEquals(1, modules.size) @@ -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().state) val modules = myFixture.project.service().state.modules assertEquals(1, modules.size) @@ -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().state) val modules = myFixture.project.service().state.modules assertEquals(1, modules.size)