Skip to content

Commit

Permalink
🐛 Fix body text exceeding viewport height
Browse files Browse the repository at this point in the history
If the viewport of the body exceeds the displayed output, the commit
message will be missing the text that was not shown when accepting the
commit.
  • Loading branch information
mikelorant committed Feb 16, 2023
1 parent cee22d8 commit 0627636
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions internal/ui/body/body.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ package body

import (
"strings"
"unicode"

"github.com/acarl005/stripansi"
"github.com/charmbracelet/bubbles/cursor"
"github.com/charmbracelet/bubbles/textarea"
tea "github.com/charmbracelet/bubbletea"
"github.com/mikelorant/committed/internal/commit"
"github.com/mikelorant/committed/internal/ui/colour"
"github.com/muesli/reflow/wordwrap"
)

type Model struct {
Expand Down Expand Up @@ -112,15 +110,9 @@ func (m Model) Focused() bool {
}

func (m Model) Value() string {
if m.textArea.Value() == "" {
return ""
}

m.textArea.Cursor.SetMode(cursor.CursorHide)
res := strings.TrimRightFunc(stripansi.Strip(m.textArea.View()), unicode.IsSpace)
m.textArea.Cursor.SetMode(cursor.CursorBlink)
txt := wordwrap.String(m.textArea.Value(), 72)

return res
return strings.TrimSpace(txt)
}

func (m Model) RawValue() string {
Expand Down

0 comments on commit 0627636

Please sign in to comment.