File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -142,11 +142,17 @@ func (m Model) submitResults(ctx context.Context) tea.Cmd {
142142}
143143
144144func (m Model ) View () string {
145+ statusBar := m .statusBarView ()
146+
147+ bottom := statusBar
148+ if m .Help .Visible () {
149+ bottom = lipgloss .JoinVertical (lipgloss .Left , statusBar , m .helpView ())
150+ }
151+
145152 return lipgloss .JoinVertical (
146153 lipgloss .Left ,
147154 m .configeditor .View (),
148- m .statusBarView (),
149- m .helpView (),
155+ bottom ,
150156 )
151157}
152158
@@ -156,17 +162,24 @@ func (m Model) statusBarView() string {
156162 return m .statusBar .RenderWithNote ("menu" , m .theme .Ellipsis )
157163}
158164
165+ const statusBarHeight = 1
166+
167+ func (m Model ) chromeHeight () int {
168+ helpHeight := m .Help .Height ()
169+ if helpHeight > 0 {
170+ helpHeight ++ // Account for separator line between status bar and help.
171+ }
172+
173+ return statusBarHeight + helpHeight
174+ }
175+
159176func (m * Model ) SetSize (w , h int ) tea.Cmd {
160177 m .width = w
161178 m .height = h
162179 m .Help .SetWidth (w )
163180 m .statusBar .SetWidth (w )
164181
165- if helpH := m .Help .Height (); helpH > 0 {
166- m .configeditor .SetHeight (h - helpH - 2 )
167- } else {
168- m .configeditor .SetHeight (h - 1 )
169- }
182+ m .configeditor .SetHeight (h - m .chromeHeight ())
170183
171184 return nil
172185}
Original file line number Diff line number Diff line change @@ -192,41 +192,39 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd {
192192}
193193
194194func (m Model ) View () string {
195+ var bottomBar string
195196 if m .ViewState == StateSearching {
196- return lipgloss .JoinVertical (
197- lipgloss .Top ,
198- m .viewport .View (),
199- m .searchBarView (),
200- m .helpView (),
201- )
197+ bottomBar = m .searchBarView ()
198+ } else {
199+ bottomBar = m .statusBarView ()
200+ }
201+
202+ bottom := bottomBar
203+ if m .Help .Visible () {
204+ bottom = lipgloss .JoinVertical (lipgloss .Top , bottomBar , m .helpView ())
202205 }
203206
204207 return lipgloss .JoinVertical (
205208 lipgloss .Top ,
206209 m .viewport .View (),
207- m .statusBarView (),
208- m .helpView (),
210+ bottom ,
209211 )
210212}
211213
214+ func (m Model ) chromeHeight () int {
215+ return statusBarHeight + m .Help .Height ()
216+ }
217+
212218func (m * Model ) SetSize (w , h int ) tea.Cmd {
213219 m .width = w
214220 m .height = h
215221 m .Help .SetWidth (w )
216222 m .statusBar .SetWidth (w )
217223
218- // Calculate viewport dimensions.
219- viewportHeight := h - statusBarHeight
220-
221- // Subtract help height if visible.
222- if helpH := m .Help .Height (); helpH > 0 {
223- viewportHeight -= (statusBarHeight + helpH )
224- }
225-
226224 m .searchInput .SetWidth (w - ansi .StringWidth (m .searchInput .Prompt ))
227225
228226 m .viewport .SetWidth (w )
229- m .viewport .SetHeight (viewportHeight )
227+ m .viewport .SetHeight (h - m . chromeHeight () )
230228
231229 return nil
232230}
You can’t perform that action at this time.
0 commit comments