Skip to content

Add Windows support via fixing path handling. #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "com.hotovo.plugins"
version = "0.1.0"
version = "0.1.1"

repositories {
mavenCentral()
Expand Down
15 changes: 12 additions & 3 deletions src/main/kotlin/com/hotovo/plugins/aiderdesk/AiderDeskConnector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ class AiderDeskConnector : CoroutineScope {
}

private fun sendInitMessage(project: Project) {
val isWindows = System.getProperty("os.name").lowercase().contains("win")

val projectBasePath = project.basePath ?: return
val normalizedBasePath = if (isWindows) projectBasePath.replace("/", "\\") else projectBasePath
val contextFiles = ArrayList<Map<String, Any>>()

for (editor in FileEditorManager.getInstance(project).allEditors) {
Expand All @@ -208,9 +211,10 @@ class AiderDeskConnector : CoroutineScope {
}

val relativePath = Path.of(projectBasePath).relativize(Path.of(file.path)).toString().replace("\\", "/")
val normalizedPath = if (isWindows) relativePath.replace("/", "\\") else relativePath
contextFiles.add(
mapOf(
"path" to relativePath,
"path" to normalizedPath,
"sourceType" to "intellij"
)
)
Expand All @@ -219,7 +223,7 @@ class AiderDeskConnector : CoroutineScope {
launch {
val initMessage = mapOf(
"action" to "init",
"baseDir" to projectBasePath,
"baseDir" to normalizedBasePath,
"contextFiles" to contextFiles
)
sendMessage(initMessage, project)
Expand All @@ -236,8 +240,13 @@ class AiderDeskConnector : CoroutineScope {
}

private fun sendMessage(message: FileMessage) {
val isWindows = System.getProperty("os.name").lowercase().contains("win")
val normalizedPath = if (isWindows) message.path.replace("/", "\\") else message.path
val normalizedBasePath = if (isWindows) message.baseDir.replace("/", "\\") else message.baseDir
val normalizedMessage = if (isWindows) FileMessage(message.action, normalizedPath, normalizedBasePath) else message

try {
val jsonMessage = mapper.writeValueAsString(message)
val jsonMessage = mapper.writeValueAsString(normalizedMessage)
val project = projects.find { it.basePath == message.baseDir } ?: return
projectSockets[project]?.emit("message", JSONObject(jsonMessage))
} catch (e: Exception) {
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
Start your AiderDesk and the plugin will automatically connect on port 24337 to communicate with the server.<br/><br/>
]]></description>

<change-notes><![CDATA[
<p>0.1.1</p>
<ul>
<li>Add Windows support via fixing path handling.</li>
</ul>
]]></change-notes>

<change-notes><![CDATA[
<p>0.1.0</p>
<ul>
Expand Down