Skip to content

Commit 6388a6e

Browse files
committed
Clean up PaginatedModel alias, duplicate test, and verbose comment
Remove the PaginatedModel type alias (FinalModel interface suffices). Remove the duplicate TestPaginatedErrAccessor test that overlaps with TestPaginatedModelErr. Reduce the 5-line MaxWidth truncation comment to a single line. Co-authored-by: Isaac
1 parent cda931b commit 6388a6e

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

libs/tableview/paginated.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ type searchDebounceMsg struct {
4141
seq int
4242
}
4343

44-
// PaginatedModel is the exported alias used by callers (e.g. RenderIterator)
45-
// to inspect the final model returned by tea.Program.Run().
46-
type PaginatedModel = paginatedModel
47-
4844
type paginatedModel struct {
4945
cfg *TableConfig
5046
headers []string
@@ -165,9 +161,9 @@ func RunPaginated(ctx context.Context, w io.Writer, cfg *TableConfig, iter RowIt
165161
if err != nil {
166162
return err
167163
}
168-
if pm, ok := finalModel.(FinalModel); ok {
169-
if modelErr := pm.Err(); modelErr != nil {
170-
return modelErr
164+
if m, ok := finalModel.(FinalModel); ok {
165+
if fetchErr := m.Err(); fetchErr != nil {
166+
return fetchErr
171167
}
172168
}
173169
return nil
@@ -280,11 +276,7 @@ func (m paginatedModel) renderContent() string {
280276
fmt.Fprintln(tw, strings.Join(seps, "\t"))
281277

282278
// Data rows.
283-
// NOTE: MaxWidth truncation here is destructive, not display wrapping.
284-
// Values exceeding MaxWidth are cut and suffixed with "..." in the
285-
// rendered output. Horizontal scrolling cannot recover the hidden tail.
286-
// A future improvement could store full values and only truncate the
287-
// visible slice, but that requires per-cell width tracking.
279+
// MaxWidth truncation is destructive; horizontal scroll won't recover hidden text.
288280
for _, row := range m.rows {
289281
vals := make([]string, len(m.headers))
290282
for i := range m.headers {

libs/tableview/paginated_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,6 @@ func TestPaginatedFetchError(t *testing.T) {
116116
assert.Equal(t, "network error", pm.err.Error())
117117
}
118118

119-
func TestPaginatedErrAccessor(t *testing.T) {
120-
m := newTestModel(t, nil, 0)
121-
assert.NoError(t, m.Err())
122-
123-
m.err = errors.New("api timeout")
124-
assert.EqualError(t, m.Err(), "api timeout")
125-
}
126-
127119
func TestPaginatedCursorMovement(t *testing.T) {
128120
m := newTestModel(t, nil, 0)
129121
m.ready = true

0 commit comments

Comments
 (0)