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
17 changes: 16 additions & 1 deletion 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.0"
val currentVersion = "2.0.1"
val myGroup = "com.mituuz"
version = currentVersion
group = myGroup
Expand All @@ -39,6 +39,21 @@ 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
<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>
</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>

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

## Version 2.0.1

- Fix incorrect `grep` command
- Partially fix `findstr` command
- Re-add the backend name to the popup title

**Known issues**

- `findstr` does not work with currently open tabs
- To reduce the maintenance burden, I may remove support later
- Performance is poor enough that I thought that the command wasn't returning any results

## Version 2.0.0

This version contains larger refactors and multiple new actions enabled by them.
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/com/mituuz/fuzzier/entities/GrepConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class GrepConfig(
val title: String = "",
val supportsSecondaryField: Boolean = true,
) {
fun getPopupTitle(): String {
fun getPopupTitle(backendName: String): String {
if (caseMode == CaseMode.INSENSITIVE) {
return "$title (Case Insensitive)"
return "$title (case-insensitive $backendName)"
}
return title
return "$title ($backendName)"
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/com/mituuz/fuzzier/grep/FuzzyGrep.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ open class FuzzyGrep : FuzzyAction() {
) {
currentLaunchJob?.cancel()
grepConfig = getGrepConfig(project)
val popupTitle = grepConfig.getPopupTitle()

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)

if (backendResult.isFailure) {
showNotification(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BackendResolver(val isWindows: Boolean) {
projectBasePath
) -> Result.success(BackendStrategy.Findstr)

!isWindows && isInstalled(commandRunner, "com/mituuz/fuzzier/grep", projectBasePath) -> Result.success(
!isWindows && isInstalled(commandRunner, "grep", projectBasePath) -> Result.success(
BackendStrategy.Grep
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,23 @@ sealed interface BackendStrategy {
"/p",
"/s",
"/n",
searchString
"/C:$searchString"
)
)
commands.addAll(grepConfig.targets)
commands.addAll(grepConfig.targets.map { if (it == ".") "*" else it })
return commands
}
}

object Grep : BackendStrategy {
override val name = "com/mituuz/fuzzier/grep"
override val name = "grep"

override fun buildCommand(
grepConfig: GrepConfig,
searchString: String,
secondarySearchString: String?
): List<String> {
val commands = mutableListOf("com/mituuz/fuzzier/grep")
val commands = mutableListOf("grep")

if (grepConfig.caseMode == CaseMode.INSENSITIVE) {
commands.add("-i")
Expand All @@ -126,6 +126,7 @@ sealed interface BackendStrategy {
mutableListOf(
"--color=none",
"-r",
"-H",
"-n",
searchString
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class BackendResolverTest {
coEvery { commandRunner.runCommandForOutput(listOf("which", "rg"), projectBasePath) } returns ""
coEvery {
commandRunner.runCommandForOutput(
listOf("which", "com/mituuz/fuzzier/grep"),
listOf("which", "grep"),
projectBasePath
)
} returns "/usr/bin/grep"
Expand All @@ -103,7 +103,7 @@ class BackendResolverTest {
assertTrue(result.isSuccess)
assertEquals(BackendStrategy.Grep, result.getOrNull())
coVerify { commandRunner.runCommandForOutput(listOf("which", "rg"), projectBasePath) }
coVerify { commandRunner.runCommandForOutput(listOf("which", "com/mituuz/fuzzier/grep"), projectBasePath) }
coVerify { commandRunner.runCommandForOutput(listOf("which", "grep"), projectBasePath) }
}

@Test
Expand All @@ -128,7 +128,7 @@ class BackendResolverTest {
coEvery { commandRunner.runCommandForOutput(listOf("which", "rg"), projectBasePath) } returns " "
coEvery {
commandRunner.runCommandForOutput(
listOf("which", "com/mituuz/fuzzier/grep"),
listOf("which", "grep"),
projectBasePath
)
} returns ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class BackendStrategyTest {
assertTrue(result.contains("/p"))
assertTrue(result.contains("/s"))
assertTrue(result.contains("/n"))
assertTrue(result.contains("test"))
assertTrue(result.contains("/C:test"))
assertTrue(result.contains("C:\\path\\to\\search"))
}

Expand Down Expand Up @@ -204,7 +204,7 @@ class BackendStrategyTest {

val result = BackendStrategy.Grep.buildCommand(config, "test", null)

assertTrue(result.contains("com/mituuz/fuzzier/grep"))
assertTrue(result.contains("grep"))
assertTrue(result.contains("--color=none"))
assertTrue(result.contains("-r"))
assertTrue(result.contains("-n"))
Expand Down Expand Up @@ -238,7 +238,7 @@ class BackendStrategyTest {

@Test
fun `name should return grep`() {
assertEquals("com/mituuz/fuzzier/grep", BackendStrategy.Grep.name)
assertEquals("grep", BackendStrategy.Grep.name)
}
}
}