Skip to content

Commit

Permalink
Do not override content of the existing files
Browse files Browse the repository at this point in the history
  • Loading branch information
pkukielka committed Aug 1, 2024
1 parent 79340ff commit ba52822
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/main/kotlin/com/sourcegraph/utils/CodyEditorUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.ex.temp.TempFileSystem
import com.intellij.util.concurrency.annotations.RequiresEdt
import com.intellij.util.withScheme
import com.sourcegraph.cody.agent.protocol_extensions.*
import com.sourcegraph.cody.agent.protocol_extensions.toOffset
import com.sourcegraph.cody.agent.protocol_generated.Range
import com.sourcegraph.config.ConfigUtil
import java.net.URI
Expand Down Expand Up @@ -211,13 +211,16 @@ object CodyEditorUtil {
if (!fileUri.toPath().exists()) {
fileUri.toPath().parent?.createDirectories()
fileUri.toPath().createFile()
}
val vf = LocalFileSystem.getInstance().refreshAndFindFileByNioFile(fileUri.toPath())

val vf = LocalFileSystem.getInstance().refreshAndFindFileByNioFile(fileUri.toPath())
content?.let {
WriteCommandAction.runWriteCommandAction(project) { vf?.setBinaryContent(it.toByteArray()) }
content?.let {
WriteCommandAction.runWriteCommandAction(project) {
vf?.setBinaryContent(it.toByteArray())
}
}
}
return vf

return LocalFileSystem.getInstance().refreshAndFindFileByNioFile(fileUri.toPath())
} catch (e: URISyntaxException) {
val fileName = uriString.substringAfterLast(':').trimStart('/', '\\')
val fileType = FileTypeRegistry.getInstance().getFileTypeByFileName(fileName)
Expand Down

0 comments on commit ba52822

Please sign in to comment.