File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -329,7 +329,11 @@ func (m Model) View() string {
329329 }
330330 padding := ""
331331 if contentLines < diffHeight {
332- padding = strings .Repeat ("\n " , diffHeight - contentLines )
332+ paddingLines := diffHeight - contentLines
333+ if contentLines == 0 && paddingLines > 0 {
334+ paddingLines --
335+ }
336+ padding = strings .Repeat ("\n " , paddingLines )
333337 }
334338
335339 return header + "\n " + content + padding + "\n " + footer
Original file line number Diff line number Diff line change 11package ui
22
33import (
4+ "strings"
45 "testing"
56
67 "github.com/Astro-Han/diffpane/internal"
@@ -249,6 +250,26 @@ func TestModelViewSmallHeightDoesNotPanic(t *testing.T) {
249250 _ = model .View ()
250251}
251252
253+ // TestModelViewEmptyStateFitsViewport verifies the empty-state header and footer
254+ // both remain visible within the terminal height instead of scrolling off-screen.
255+ func TestModelViewEmptyStateFitsViewport (t * testing.T ) {
256+ model := NewModel ("repo" , "/tmp/repo" , "sha" , nil )
257+ model .Width = 80
258+ model .Height = 4
259+
260+ view := model .View ()
261+ lines := strings .Split (view , "\n " )
262+ if len (lines ) != 4 {
263+ t .Fatalf ("line count = %d, want 4; view = %q" , len (lines ), view )
264+ }
265+ if ! strings .Contains (lines [0 ], "repo" ) || ! strings .Contains (lines [0 ], "watching" ) {
266+ t .Fatalf ("first line = %q, want empty-state header" , lines [0 ])
267+ }
268+ if ! strings .Contains (lines [3 ], "q quit" ) {
269+ t .Fatalf ("last line = %q, want footer" , lines [3 ])
270+ }
271+ }
272+
252273// TestModelScrollOffsetStaysWithinContent verifies repeated down-navigation does
253274// not grow scroll state beyond the visible diff content.
254275func TestModelScrollOffsetStaysWithinContent (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments