Skip to content
Myr

Fix panic on extremely short terminals

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix #3889

authored by Junegunn Choi · committed by Junegunn Choi · parent bee7bc5 · Browse files · 1 file+21 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+21 added−5 removed

  • other:+21 added−5 removed

1 file+21 added−5 removed

modified:src/terminal.go+21 added-5 removed
1722 unmodified lines
17231724func (t *Terminal) promptLine() int {1725 if t.headerFirst {1726 max := t.window.Height() - 11727 if max <= 0 { // Extremely short terminal1728 return 01729 }1730 if !t.noSeparatorLine() {1731 max--1732 }1733 return util.Min(t.visibleHeaderLines(), max)
27 unmodified lines
17611762func (t *Terminal) printInfo() {1763 pos := 01764 line := t.promptLine()1765 maxHeight := t.window.Height()1762 move := func(y int, x int, clear bool) {1766 move := func(y int, x int, clear bool) bool {1767 if y < 0 || y >= maxHeight {1768 return false1769 }1770 t.move(y, x, clear)1771 t.markOtherLine(y)1772 return true1773 }1774 printSpinner := func() {1775 if t.reading {1776 duration := int64(spinnerDuration)
30 unmodified lines
1807 }18081809 if t.infoStyle == infoHidden {1810 if t.separatorLen > 0 {1803 move(line+1, 0, false)1811 if !move(line+1, 0, false) {1812 return1813 }1814 printSeparator(t.window.Width()-1, false)1815 }1816 return1817 }
35 unmodified lines
1853 }18541855 switch t.infoStyle {1856 case infoDefault:1847 move(line+1, 0, t.separatorLen == 0)1857 if !move(line+1, 0, t.separatorLen == 0) {1858 return1859 }1860 printSpinner()1861 t.window.Print(" ") // Margin1862 pos = 21863 case infoRight:1852 move(line+1, 0, false)1864 if !move(line+1, 0, false) {1865 return1866 }1867 case infoInlineRight:1868 pos = t.promptLen + t.queryLen[0] + t.queryLen[1] + 11869 case infoInline:1870 pos = t.promptLen + t.queryLen[0] + t.queryLen[1] + 1
63 unmodified lines
1934 }19351936 if t.infoStyle == infoInlineRight {1937 if t.separatorLen > 0 {1924 move(line+1, 0, false)1938 if !move(line+1, 0, false) {1939 return1940 }1941 printSeparator(t.window.Width()-1, false)1942 }1943 return1944 }
2996 unmodified lines