refactor: Improve the diff block logic for inline chat
This commit is contained in:
parent
28c84c8211
commit
b4000e1e8e
2 changed files with 4 additions and 3 deletions
|
|
@ -51,7 +51,7 @@ class EditorComponentInlaysManager(val editor: EditorImpl, private val onlyOneIn
|
|||
}
|
||||
|
||||
val wrappedComponent = ComponentWrapper(component)
|
||||
val offset = editor.document.getLineEndOffset(lineIndex)
|
||||
val offset = editor.document.getLineStartOffset(lineIndex)
|
||||
|
||||
return EditorEmbeddedComponentManager.getInstance()
|
||||
.addComponent(
|
||||
|
|
@ -59,7 +59,7 @@ class EditorComponentInlaysManager(val editor: EditorImpl, private val onlyOneIn
|
|||
EditorEmbeddedComponentManager.Properties(
|
||||
EditorEmbeddedComponentManager.ResizePolicy.none(),
|
||||
null,
|
||||
true,
|
||||
!editor.inlayModel.getBlockElementsInRange(offset,offset).isEmpty(),
|
||||
showAbove,
|
||||
0,
|
||||
offset
|
||||
|
|
|
|||
|
|
@ -59,11 +59,12 @@ class VerticalDiffBlock(
|
|||
|
||||
fun deleteLineAt(line: Int) {
|
||||
val startOffset = editor.document.getLineStartOffset(line)
|
||||
val endOffset = editor.document.getLineEndOffset(line) + 1
|
||||
val endOffset = min(editor.document.getLineEndOffset(line) + 1, editor.document.textLength)
|
||||
val deletedText = editor.document.getText(TextRange(startOffset, endOffset))
|
||||
|
||||
deletedLines.add(deletedText.trimEnd())
|
||||
|
||||
// Unable to ensure that text length has not changed, so we need to get it again
|
||||
editor.document.deleteString(startOffset, min(endOffset, editor.document.textLength))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue