Skip to content

Commit 9d144e6

Browse files
committed
fix(editor): update expand/collapse logic and threshold
- Set editor to collapsed state after resizing. - Adjust expand/collapse label visibility and text based on collapsed state. - Increase `minDevinLineThreshold` from 1 to 5 for better usability.
1 parent 258020f commit 9d144e6

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/code/CodeHighlightSketch.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ open class CodeHighlightSketch(
4747
val editorLineThreshold: Int = 6
4848
) : JBPanel<CodeHighlightSketch>(BorderLayout()), DataProvider, LangSketch, Disposable {
4949
private val devinLineThreshold = 10
50-
private val minDevinLineThreshold = 1
50+
private val minDevinLineThreshold = 5
5151
private var isDevIns = false
5252

5353
private var textLanguage: String? = null

core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/code/EditorFragment.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,12 @@ class EditorFragment(var editor: EditorEx, private val editorLineThreshold: Int
106106
fun resizeForNewThreshold(newThreshold: Int) {
107107
content.preferredSize = calculatePreferredSize(content.preferredSize, newThreshold)
108108

109+
setCollapsed(true)
110+
109111
val linesCount = editor.document.lineCount
110-
expandCollapseTextLabel.isVisible = linesCount > newThreshold
111-
expandCollapseTextLabel.text = "More lines"
112-
expandCollapseTextLabel.icon = AllIcons.General.ChevronDown
112+
expandCollapseTextLabel.isVisible = linesCount > editorLineThreshold
113+
expandCollapseTextLabel.text = if (collapsed) "More lines" else ""
114+
expandCollapseTextLabel.icon = if (collapsed) AllIcons.General.ChevronDown else AllIcons.General.ChevronUp
113115

114116
content.revalidate()
115117
content.repaint()

0 commit comments

Comments
 (0)