Skip to content

Commit ccabdbb

Browse files
committed
fix(sketch): make bottom border configurable in action bar
Make the bottom border in setupActionBar optional with a showBottomBorder parameter (defaulting to true) and use it when a devInsCollapsedPanel is present. Also fix a variable reassignment issue in SketchToolWindow.
1 parent bcceecb commit ccabdbb

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

core/src/main/kotlin/cc/unitmesh/devti/sketch/SketchToolWindow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ open class SketchToolWindow(
376376
val codes = CodeFence.parseAll(code.text)
377377

378378
val panels = codes.map { code ->
379-
var panel: JComponent = when (code.originLanguage) {
379+
val panel: JComponent = when (code.originLanguage) {
380380
"diff", "patch" -> {
381381
val langSketch = LanguageSketchProvider.provide("patch")?.create(project, code.text)
382382
?: return@map null

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ interface LangSketch : Disposable {
3030
fun onDoneStream(allText: String) {}
3131
fun onComplete(code: String) {}
3232

33-
fun setupActionBar(project: Project, editor: Editor, isDeclarePackageFile: Boolean): ActionToolbar? {
34-
val toolbar = collectActionBar(isDeclarePackageFile) ?: return null
33+
fun setupActionBar(project: Project, editor: Editor, isPackageFile: Boolean, showBottomBorder: Boolean = true): ActionToolbar? {
34+
val toolbar = collectActionBar(isPackageFile) ?: return null
3535

3636
if (editor is EditorEx) {
3737
toolbar.component.setBackground(editor.backgroundColor)
@@ -41,7 +41,9 @@ interface LangSketch : Disposable {
4141
toolbar.targetComponent = editor.contentComponent
4242
editor.headerComponent = toolbar.component
4343

44-
toolbar.component.border = JBUI.Borders.customLine(UIUtil.getBoundsColor(), 0, 0, 1, 0)
44+
if (showBottomBorder) {
45+
toolbar.component.border = JBUI.Borders.customLine(UIUtil.getBoundsColor(), 0, 0, 1, 0)
46+
}
4547

4648
val connect = project.messageBus.connect(this)
4749
val topic: Topic<EditorColorsListener> = EditorColorsManager.TOPIC

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
@@ -141,7 +141,7 @@ open class CodeHighlightSketch(
141141

142142
if (textLanguage != null && lowercase != "markdown" && lowercase != "plain text") {
143143
if (showToolbar && lowercase != "devin") {
144-
toolbar = setupActionBar(project, editor, isDeclarePackageFile)
144+
toolbar = setupActionBar(project, editor, isDeclarePackageFile, showBottomBorder = devInsCollapsedPanel != null)
145145
}
146146
} else {
147147
editorFragment?.editor?.backgroundColor = JBColor.PanelBackground

0 commit comments

Comments
 (0)