Skip to content

Commit

Permalink
Merge pull request #59 from dprint/hotfix-for-plugins-using-git
Browse files Browse the repository at this point in the history
Hotfix: Fix issue for plugins that require commands to be run within the git repository of the project.
  • Loading branch information
ryan-rushton authored Nov 23, 2023
2 parents 681bb5f + 717cbaa commit 95b902a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# dprint-intellij-plugin Changelog

## Unreleased
- Fixed issue for plugins that require the underlying process to be running in the working projects git repository.

## 0.4.3 - 2023-10-11
- Update to latest dependencies
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html
pluginGroup=com.dprint.intellij.plugin
pluginName=dprint-intellij-plugin
pluginVersion=0.4.3
pluginVersion=0.4.4
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
pluginSinceBuild=231
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import kotlinx.serialization.json.int
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
import org.apache.commons.collections4.map.LRUMap
import java.io.File
import java.util.concurrent.CompletableFuture
import java.util.concurrent.ExecutionException
import java.util.concurrent.TimeUnit
Expand All @@ -52,13 +53,17 @@ class EditorServiceManager(private val project: Project) {
// The less generic error is kotlinx.serialization.json.internal.JsonDecodingException and is not accessible
// unfortunately
@Suppress("TooGenericExceptionCaught")
private fun getSchemaVersion(): Int? {
private fun getSchemaVersion(configPath: String?): Int? {
val executablePath = getValidExecutablePath(project)

val commandLine = GeneralCommandLine(
executablePath,
"editor-info"
)
configPath?.let {
val workingDir = File(it).parent
commandLine.withWorkDirectory(workingDir)
}
val result = ExecUtil.execAndGetOutput(commandLine)

return try {
Expand All @@ -83,8 +88,8 @@ class EditorServiceManager(private val project: Project) {
createTaskWithTimeout(
DprintBundle.message("editor.service.manager.initialising.editor.service"),
{
val schemaVersion = getSchemaVersion()
configPath = getValidConfigPath(project)
val schemaVersion = getSchemaVersion(configPath)
infoLogWithConsole(
DprintBundle.message("editor.service.manager.received.schema.version", schemaVersion ?: "none"),
project,
Expand Down

0 comments on commit 95b902a

Please sign in to comment.