Extract inputBorderFacesList helper

Facing-side rule was written out separately in options.go and
terminal.go; single helper prevents the two from drifting apart
This commit is contained in:
Junegunn Choi
2026-07-18 01:43:12 +09:00
parent 711f810630
commit 5aab8979c6
2 changed files with 14 additions and 10 deletions
+1 -8
View File
@@ -3699,14 +3699,7 @@ func (opts *Options) noSeparatorLine() bool {
// NOTE: This does not know that the default separator can be suppressed at
// runtime (see Terminal.separatorLength), so the minimum heights derived
// from it can be one line taller than strictly necessary.
//
// Whether the input border draws a line on the side facing the list
// section; BorderLine always resolves to that side (see NewTerminal)
shape := opts.InputBorderShape
facingLine := shape == tui.BorderLine ||
opts.Layout == layoutReverse && shape.HasBottom() ||
opts.Layout != layoutReverse && shape.HasTop()
sep := opts.Separator == nil && !facingLine || opts.Separator != nil && len(*opts.Separator) > 0
sep := opts.Separator == nil && !inputBorderFacesList(opts.Layout, opts.InputBorderShape) || opts.Separator != nil && len(*opts.Separator) > 0
return noSeparatorLine(opts.InfoStyle, sep)
}
+13 -2
View File
@@ -1713,10 +1713,21 @@ func (t *Terminal) separatorLength() int {
// The default horizontal separator is redundant if the input section is
// already visually separated from the list section by a border line
// Whether the input border draws a line on the side facing the list section.
// BorderLine is placed on the facing side when resolved in NewTerminal.
func inputBorderFacesList(layout layoutType, shape tui.BorderShape) bool {
if shape == tui.BorderLine {
return true
}
if layout == layoutReverse {
return shape.HasBottom()
}
return shape.HasTop()
}
func (t *Terminal) separatedByBorder() bool {
// The input border itself draws a line on the side facing the list section
if t.layout == layoutReverse && t.inputBorderShape.HasBottom() ||
t.layout != layoutReverse && t.inputBorderShape.HasTop() {
if inputBorderFacesList(t.layout, t.inputBorderShape) {
return true
}
for po := &t.previewOpts; po != nil; po = po.alternative {