on main help sign in
fix(dialogs): prevent panic due to negative index
44e1ca7Andrey Nering
internal/ui/dialog/api_key_input.go+1−1
@@ -71,7 +71,7 @@ func NewAPIKeyInput(com *common.Common, provider catwalk.Provider, model config.
71 m.input.Placeholder = "Enter you API key..."
71 m.input.Placeholder = "Enter you API key..."
72 m.input.SetStyles(com.Styles.TextInput)
72 m.input.SetStyles(com.Styles.TextInput)
73 m.input.Focus()
73 m.input.Focus()
74− m.input.SetWidth(innerWidth - t.Dialog.InputPrompt.GetHorizontalFrameSize() - 1) // (1) cursor padding
74+ m.input.SetWidth(max(0, innerWidth-t.Dialog.InputPrompt.GetHorizontalFrameSize()-1)) // (1) cursor padding
75
75
76 m.spinner = spinner.New(
76 m.spinner = spinner.New(
77 spinner.WithSpinner(spinner.Dot),
77 spinner.WithSpinner(spinner.Dot),
internal/ui/dialog/commands.go+1−1
@@ -256,7 +256,7 @@ func (c *Commands) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
256 t.Dialog.HelpView.GetVerticalFrameSize() +
256 t.Dialog.HelpView.GetVerticalFrameSize() +
257 t.Dialog.View.GetVerticalFrameSize()
257 t.Dialog.View.GetVerticalFrameSize()
258
258
259− c.input.SetWidth(innerWidth - t.Dialog.InputPrompt.GetHorizontalFrameSize() - 1) // (1) cursor padding
259+ c.input.SetWidth(max(0, innerWidth-t.Dialog.InputPrompt.GetHorizontalFrameSize()-1)) // (1) cursor padding
260
260
261 c.list.SetSize(innerWidth, height-heightOffset)
261 c.list.SetSize(innerWidth, height-heightOffset)
262 c.help.SetWidth(innerWidth)
262 c.help.SetWidth(innerWidth)
internal/ui/dialog/models.go+1−1
@@ -251,7 +251,7 @@ func (m *Models) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
251 t.Dialog.InputPrompt.GetVerticalFrameSize() + inputContentHeight +
251 t.Dialog.InputPrompt.GetVerticalFrameSize() + inputContentHeight +
252 t.Dialog.HelpView.GetVerticalFrameSize() +
252 t.Dialog.HelpView.GetVerticalFrameSize() +
253 t.Dialog.View.GetVerticalFrameSize()
253 t.Dialog.View.GetVerticalFrameSize()
254− m.input.SetWidth(innerWidth - t.Dialog.InputPrompt.GetHorizontalFrameSize() - 1) // (1) cursor padding
254+ m.input.SetWidth(max(0, innerWidth-t.Dialog.InputPrompt.GetHorizontalFrameSize()-1)) // (1) cursor padding
255 m.list.SetSize(innerWidth, height-heightOffset)
255 m.list.SetSize(innerWidth, height-heightOffset)
256 m.help.SetWidth(innerWidth)
256 m.help.SetWidth(innerWidth)
257
257
internal/ui/dialog/sessions.go+1−1
@@ -148,7 +148,7 @@ func (s *Session) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
148 t.Dialog.InputPrompt.GetVerticalFrameSize() + inputContentHeight +
148 t.Dialog.InputPrompt.GetVerticalFrameSize() + inputContentHeight +
149 t.Dialog.HelpView.GetVerticalFrameSize() +
149 t.Dialog.HelpView.GetVerticalFrameSize() +
150 t.Dialog.View.GetVerticalFrameSize()
150 t.Dialog.View.GetVerticalFrameSize()
151− s.input.SetWidth(innerWidth - t.Dialog.InputPrompt.GetHorizontalFrameSize() - 1) // (1) cursor padding
151+ s.input.SetWidth(max(0, innerWidth-t.Dialog.InputPrompt.GetHorizontalFrameSize()-1)) // (1) cursor padding
152 s.list.SetSize(innerWidth, height-heightOffset)
152 s.list.SetSize(innerWidth, height-heightOffset)
153 s.help.SetWidth(innerWidth)
153 s.help.SetWidth(innerWidth)
154
154