Skip to content

Commit

Permalink
Simplified word wrapping. (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
janderland authored Sep 3, 2023
1 parent fee8246 commit 681844c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 0 additions & 2 deletions internal/app/fullscreen/results/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/apple/foundationdb/bindings/go/src/fdb/directory"
"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
"github.com/muesli/reflow/wordwrap"
"github.com/muesli/reflow/wrap"
"github.com/rs/zerolog"

Expand Down Expand Up @@ -275,7 +274,6 @@ func (x *Model) render(e *list.Element) []string {
indent := strings.Repeat(" ", len(prefix))

str := x.str(res.value)
str = wordwrap.String(str, x.wrapWidth-len(prefix))
str = wrap.String(str, x.wrapWidth-len(prefix))
lines := strings.Split(str, "\n")

Expand Down
16 changes: 14 additions & 2 deletions internal/app/fullscreen/results/results_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ func TestWrapWidth(t *testing.T) {
xxx`[1:]

require.Equal(t, expected, x.View())

x.Reset()
x.Push("xxxxxxxxxx xxx")
x.WrapWidth(8)

expected = `
1 # xxx
xxxxx
xx xx
x`[1:]

require.Equal(t, expected, x.View())
}

func TestReset(t *testing.T) {
Expand Down Expand Up @@ -175,10 +187,10 @@ func TestLineScroll(t *testing.T) {
x.WrapWidth(10)

x.Push("xxx xxx")
require.Equal(t, "1 # xxx\n xxx", x.View())
require.Equal(t, "1 # xxx x\n xx", x.View())

x.scrollUpLines(1)
require.Equal(t, "1 # xxx\n xxx", x.View())
require.Equal(t, "1 # xxx x\n xx", x.View())
}

func setup() Model {
Expand Down

0 comments on commit 681844c

Please sign in to comment.