Skip to content

Commit

Permalink
Add workaround for PyCharm 2024.2.1 bug (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
srwi committed Sep 11, 2024
1 parent 3cb49d2 commit 5354c7d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

## [Unreleased]

## [0.2.3]

### Fixed

- Implemented a workaround for a bug in PyCharm 2024.2.1 that affects the ability to view images when debugging via SSH

## [0.2.2] - 2024-09-08

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = com.github.srwi.pixellens
pluginName = PixelLens
pluginRepositoryUrl = https://github.com/srwi/PyCharm-PixelLens
# SemVer format -> https://semver.org
pluginVersion = 0.2.2
pluginVersion = 0.2.3

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 232
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.srwi.pixellens.dataTransmitters

import com.intellij.openapi.application.ApplicationInfo
import com.github.srwi.pixellens.interop.Python
import com.intellij.openapi.progress.ProgressIndicator
import com.jetbrains.python.debugger.PyFrameAccessor
Expand All @@ -9,7 +10,7 @@ import kotlin.math.min

class EvaluateDataTransmitter : DataTransmitter() {
override fun getJsonData(frameAccessor: PyFrameAccessor, progressIndicator: ProgressIndicator, variableName: String): String {
val chunkSize = 2_000_000
val chunkSize = getChunkSize()

progressIndicator.text = "Receiving data..."
progressIndicator.fraction = 0.0
Expand All @@ -35,6 +36,19 @@ class EvaluateDataTransmitter : DataTransmitter() {
return base64Data.toString()
}

private fun getChunkSize(): Int
{
// Dirty fix for https://youtrack.jetbrains.com/issue/PY-75568/Large-strings-truncated-when-displayed-in-debug-output-or-evaluate-windows-again
val appInfo = ApplicationInfo.getInstance()
val fullVersion = appInfo.fullVersion

return if (fullVersion == "2024.2.1") {
256
} else {
2_000_000
}
}

private fun getChunk(frameAccessor: PyFrameAccessor, variableName: String, start: Int, end: Int): String {
return Python.evaluateExpression(frameAccessor, "$variableName[$start:$end]").value
?: throw IOException("Failed to transmit chunk")
Expand Down

0 comments on commit 5354c7d

Please sign in to comment.