fix: long threads out of bounds
This commit is contained in:
47
tui.go
47
tui.go
@@ -1906,6 +1906,12 @@ func (m App) dashboardMaxScroll() int {
|
||||
}
|
||||
|
||||
func (m App) detailPaneSize() (int, int) {
|
||||
if m.contentTop == 0 &&
|
||||
len(m.difflet.frameLines()) == diffletHeight &&
|
||||
!m.diffletHiddenForCurrentView() &&
|
||||
m.screen != dashboardScreen {
|
||||
m, _ = m.diffletContentModel()
|
||||
}
|
||||
topLines := m.threadTopLineCount()
|
||||
height := max(3, m.height-topLines-1)
|
||||
if m.width < 70 || m.listHidden {
|
||||
@@ -1958,20 +1964,39 @@ func (m App) View() string {
|
||||
if m.screen == dashboardScreen {
|
||||
return m.viewDashboardWithLines(m.dashboardLinesWithDifflet(mascot))
|
||||
}
|
||||
gap := diffletGap
|
||||
content, hasHeader := m.diffletContentModel()
|
||||
if !hasHeader {
|
||||
return lipgloss.NewStyle().Width(m.width).Height(m.height).Render(
|
||||
strings.Join(mascot, "\n") + "\n\n" + content.viewContent(),
|
||||
)
|
||||
}
|
||||
rendered := content.viewContent()
|
||||
header, body, ok := splitHeader(rendered)
|
||||
if !ok {
|
||||
return lipgloss.NewStyle().Width(m.width).Height(m.height).Render(
|
||||
strings.Join(mascot, "\n") + "\n\n" + rendered,
|
||||
)
|
||||
}
|
||||
headerBand := renderHeaderWithDifflet(
|
||||
header, mascot, m.width, content.headerWidth, diffletGap,
|
||||
)
|
||||
return lipgloss.NewStyle().Width(m.width).Height(m.height).Render(
|
||||
headerBand + "\n\n" + body,
|
||||
)
|
||||
}
|
||||
|
||||
func (m App) diffletContentModel() (content App, hasHeader bool) {
|
||||
headerWidth := diffletHeaderWidth(m.width)
|
||||
if headerWidth < 1 {
|
||||
headerWidth = m.width
|
||||
}
|
||||
content := m
|
||||
content = m
|
||||
content.headerWidth = headerWidth
|
||||
headerLineCount, hasHeader := content.diffletHeaderLineCount()
|
||||
if !hasHeader {
|
||||
content.height = max(1, m.height-diffletHeight-1)
|
||||
content.contentTop = diffletHeight + 1
|
||||
return lipgloss.NewStyle().Width(m.width).Height(m.height).Render(
|
||||
strings.Join(mascot, "\n") + "\n\n" + content.viewContent(),
|
||||
)
|
||||
return content, hasHeader
|
||||
}
|
||||
bandHeight := max(diffletHeight, headerLineCount)
|
||||
addedRows := bandHeight - headerLineCount
|
||||
@@ -1980,17 +2005,7 @@ func (m App) View() string {
|
||||
}
|
||||
content.height = max(1, m.height-addedRows)
|
||||
content.contentTop = addedRows
|
||||
rendered := content.viewContent()
|
||||
header, body, ok := splitHeader(rendered)
|
||||
if !ok {
|
||||
return lipgloss.NewStyle().Width(m.width).Height(m.height).Render(
|
||||
strings.Join(mascot, "\n") + "\n\n" + rendered,
|
||||
)
|
||||
}
|
||||
headerBand := renderHeaderWithDifflet(header, mascot, m.width, headerWidth, gap)
|
||||
return lipgloss.NewStyle().Width(m.width).Height(m.height).Render(
|
||||
headerBand + "\n\n" + body,
|
||||
)
|
||||
return content, hasHeader
|
||||
}
|
||||
|
||||
func (m App) diffletHiddenForCurrentView() bool {
|
||||
|
||||
Reference in New Issue
Block a user