Merge pull request #2943 from continuedev/pe/jb-osr-bugfixes
bugfix: EDT issues w/ diff streaming
This commit is contained in:
commit
b74191b443
3 changed files with 28 additions and 13 deletions
|
|
@ -109,14 +109,14 @@ class DiffStreamHandler(
|
|||
}
|
||||
|
||||
updateProgressHighlighters(type)
|
||||
|
||||
// Since we only call onLastDiffLine() when we reach a "same" line, we need to handle the case where
|
||||
// we reach EOF while in a diff block, since we won't encounter a "same" line.
|
||||
if (curLine.index >= editor.document.lineCount - 1) {
|
||||
curLine.diffBlock?.onLastDiffLine()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
println("Error handling diff line: ${curLine.index}, $type, $text, ${e.message}")
|
||||
println(
|
||||
"Error handling diff line - " +
|
||||
"Line index: ${curLine.index}, " +
|
||||
"Line type: $type, " +
|
||||
"Line text: $text, " +
|
||||
"Error message: ${e.message}"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +139,7 @@ class DiffStreamHandler(
|
|||
val diffBlock = VerticalDiffBlock(
|
||||
editor, project, curLine.index, ::handleDiffBlockAcceptOrReject
|
||||
)
|
||||
|
||||
|
||||
diffBlocks.add(diffBlock)
|
||||
|
||||
return diffBlock
|
||||
|
|
@ -251,9 +251,12 @@ class DiffStreamHandler(
|
|||
}
|
||||
|
||||
private fun handleFinishedResponse() {
|
||||
onFinish()
|
||||
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
// Since we only call onLastDiffLine() when we reach a "same" line, we need to handle the case where
|
||||
// the last line in the diff stream is in the middle of a diff block.
|
||||
curLine.diffBlock?.onLastDiffLine()
|
||||
|
||||
onFinish()
|
||||
cleanupProgressHighlighters()
|
||||
}
|
||||
}
|
||||
|
|
@ -267,9 +270,12 @@ class DiffStreamHandler(
|
|||
private fun handleDiffLineResponse(parsed: Map<*, *>) {
|
||||
val data = parsed["content"] as Map<*, *>
|
||||
val diffLineType = getDiffLineType(data["type"] as String)
|
||||
val lineText = data["line"] as String
|
||||
|
||||
WriteCommandAction.runWriteCommandAction(project) {
|
||||
handleDiffLine(diffLineType, data["line"] as String)
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
WriteCommandAction.runWriteCommandAction(project) {
|
||||
handleDiffLine(diffLineType, lineText)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ fun makeTextArea(): JTextArea {
|
|||
isOpaque = false
|
||||
background = GetTheme().getSecondaryDark()
|
||||
maximumSize = Dimension(400, Short.MAX_VALUE.toInt())
|
||||
margin = JBUI.insets(6, 8, 6, 4)
|
||||
margin = JBUI.insets(6, 8, 2, 4)
|
||||
font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, MAIN_FONT_SIZE)
|
||||
preferredSize = Dimension(400, 75)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class VerticalDiffBlock(
|
|||
private val rejectButton: JButton
|
||||
private var deletionInlay: Disposable? = null
|
||||
private var textArea: JTextArea? = null // Used for calculation of the text area height when rendering buttons
|
||||
private var hasRenderedDiffBlock: Boolean = false
|
||||
private val editorComponentInlaysManager = EditorComponentInlaysManager.from(editor, false)
|
||||
private val greenKey = createTextAttributesKey("CONTINUE_DIFF_NEW_LINE", 0x3000FF00, editor)
|
||||
|
||||
|
|
@ -81,11 +82,19 @@ class VerticalDiffBlock(
|
|||
}
|
||||
|
||||
fun onLastDiffLine() {
|
||||
// Handles the case where we are invoking one last time on last line of diff stream, but the block has
|
||||
// already been rendered
|
||||
if (hasRenderedDiffBlock) {
|
||||
return
|
||||
}
|
||||
|
||||
if (deletedLines.size > 0) {
|
||||
renderDeletedLinesInlay()
|
||||
}
|
||||
|
||||
renderButtons()
|
||||
|
||||
hasRenderedDiffBlock = true
|
||||
}
|
||||
|
||||
fun handleReject() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue