Fix scroll & copy buttons

Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2026-05-19 20:25:50 +02:00
parent 69d5d0ffec
commit 2c3e19258f
11 changed files with 195 additions and 35 deletions
+11 -1
View File
@@ -113,6 +113,14 @@ type FindingsLoadedMsg struct {
}
func (m *Model) refreshBody() {
m.refreshBodyScroll(true)
}
func (m *Model) refreshBodyKeepScroll() {
m.refreshBodyScroll(false)
}
func (m *Model) refreshBodyScroll(reset bool) {
if len(m.findings) == 0 {
m.bodyViewport.SetContent("")
return
@@ -120,7 +128,9 @@ func (m *Model) refreshBody() {
f := m.findings[m.cursor]
rendered := m.renderMarkdownCached(f.Description, m.bodyViewport.Width())
m.bodyViewport.SetContent(rendered)
m.bodyViewport.GotoTop()
if reset {
m.bodyViewport.GotoTop()
}
}
func (m *Model) renderMarkdownCached(src string, width int) string {
+13 -1
View File
@@ -15,6 +15,10 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
log.Printf("findings load error: %v", msg.Err)
return m, nil
}
var prevID int64
if len(m.findings) > 0 && m.cursor < len(m.findings) {
prevID = m.findings[m.cursor].ID
}
m.findings = msg.Findings
if m.cursor >= len(m.findings) {
m.cursor = max(0, len(m.findings)-1)
@@ -26,7 +30,15 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.pager.SetTotalPages(len(m.findings))
}
m.refreshListViewport()
m.refreshBody()
var newID int64
if len(m.findings) > 0 && m.cursor < len(m.findings) {
newID = m.findings[m.cursor].ID
}
if newID != prevID {
m.refreshBody()
} else {
m.refreshBodyKeepScroll()
}
return m, nil
case tea.MouseWheelMsg: