Skip to content
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

Fix Generate Unit Test on Windows #1478

Merged
merged 8 commits into from
May 15, 2024
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ kotlin.stdlib.default.dependency=false
nodeBinaries.commit=8755ae4c05fd476cd23f2972049111ba436c86d4
nodeBinaries.version=v20.12.2
cody.autocomplete.enableFormatting=true
cody.commit=38885b4bd403acfca984afbe45cd50b600319ca1
cody.commit=bcbd5ee0dfc2dcb5f126ca0388cadeabf8b92875
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class CodyAgentService(private val project: Project) : Disposable {
}

agent.client.onOpenUntitledDocument = Function { params ->
// We always get a file which does not start with file:// there.
// They start with untitled:// which is VSCode-specific way
// to say that files does not exist on the disk yet.
val uri = URI.create(params.uri).withScheme("file")
if (CodyEditorUtil.createFileIfNeeded(project, uri, params.content) == null)
return@Function false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package com.sourcegraph.cody.agent.protocol
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.vfs.VirtualFile
import com.sourcegraph.cody.agent.protocol.util.Rfc3986UriEncoder
import java.nio.file.FileSystems
import java.util.Locale

class ProtocolTextDocument
private constructor(
Expand Down Expand Up @@ -47,8 +48,13 @@ private constructor(
return ProtocolTextDocument(uriFor(file), text, selection)
}

fun uriFor(file: VirtualFile): String {
return Rfc3986UriEncoder.encode(file.url)
private fun uriFor(file: VirtualFile): String {
val uri = FileSystems.getDefault().getPath(file.path).toUri().toString()
return uri.replace(Regex("file:///(\\w):/")) {
val driveLetter =
it.groups[1]?.value?.lowercase(Locale.getDefault()) ?: return@replace it.value
"file:///$driveLetter%3A/"
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,10 @@ abstract class FixupSession(
val future = group.show(range)
// Make sure the lens is visible.
ApplicationManager.getApplication().invokeLater {
val logicalPosition = LogicalPosition(range.start.line, range.start.character)
editor.scrollingModel.scrollTo(logicalPosition, ScrollType.CENTER)
if (!editor.isDisposed) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrel fix


The error appears when closing the file that contains the content being generated. This fixes it.

val logicalPosition = LogicalPosition(range.start.line, range.start.character)
editor.scrollingModel.scrollTo(logicalPosition, ScrollType.CENTER)
}
}
if (!ApplicationManager.getApplication().isDispatchThread) { // integration test
future.get()
Expand Down

This file was deleted.

Loading