mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-21 11:05:59 +00:00
fix: prevent negative offset in caret movement
This commit is contained in:
parent
8e2e384e32
commit
cf685a9e72
1 changed files with 2 additions and 1 deletions
|
|
@ -41,6 +41,7 @@ import javax.swing.JComponent
|
|||
import javax.swing.JPanel
|
||||
import javax.swing.SwingUtilities
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
|
||||
class CodeSuggestionDiffViewer(
|
||||
request: DiffRequest,
|
||||
|
|
@ -222,7 +223,7 @@ class CodeSuggestionDiffViewer(
|
|||
val previousChar = document.getText(TextRange(changeEndOffset - 1, changeEndOffset))
|
||||
val offset = if (previousChar == "\n") changeEndOffset - 1 else changeEndOffset
|
||||
|
||||
mainEditor.caretModel.moveToOffset(offset)
|
||||
mainEditor.caretModel.moveToOffset(max(offset, 0))
|
||||
|
||||
val offsetPosition = mainEditor.offsetToXY(offset)
|
||||
val offsetVisible = mainEditor.scrollingModel.visibleArea.contains(offsetPosition)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue