@@ -212,7 +212,7 @@ func (m *ModelGithubTrigger) View() string {
212212
213213 var selectedRow = m .tableTrigger .SelectedRow ()
214214 var selector = m .emptySelector ()
215- if len (m .tableTrigger .Rows ()) > 0 {
215+ if len (m .tableTrigger .Rows ()) > 0 && len ( selectedRow ) > 1 {
216216 if selectedRow [1 ] == "input" {
217217 selector = m .inputSelector ()
218218 } else {
@@ -227,6 +227,10 @@ func (m *ModelGithubTrigger) View() string {
227227
228228func (m * ModelGithubTrigger ) switchBetweenInputAndTable () {
229229 var selectedRow = m .tableTrigger .SelectedRow ()
230+
231+ if len (selectedRow ) < 5 {
232+ return // Insufficient data to operate safely
233+ }
230234
231235 if selectedRow [1 ] == "input" || selectedRow [1 ] == "bool" {
232236 m .textInput .Focus ()
@@ -235,7 +239,7 @@ func (m *ModelGithubTrigger) switchBetweenInputAndTable() {
235239 m .textInput .Blur ()
236240 m .tableTrigger .Focus ()
237241 }
238- m .textInput .SetValue (m . tableTrigger . SelectedRow () [4 ])
242+ m .textInput .SetValue (selectedRow [4 ])
239243 m .textInput .SetCursor (len (m .textInput .Value ()))
240244}
241245
@@ -246,8 +250,8 @@ func (m *ModelGithubTrigger) inputController(_ context.Context) {
246250
247251 if len (m .tableTrigger .Rows ()) > 0 {
248252 var selectedRow = m .tableTrigger .SelectedRow ()
249- if len (selectedRow ) == 0 {
250- return
253+ if len (selectedRow ) < 5 {
254+ return // Need at least 5 elements for safe access
251255 }
252256
253257 switch selectedRow [1 ] {
@@ -297,14 +301,14 @@ func (m *ModelGithubTrigger) inputController(_ context.Context) {
297301 var selectedRow = m .tableTrigger .SelectedRow ()
298302 var rows = m .tableTrigger .Rows ()
299303
300- if len (selectedRow ) == 0 || len (rows ) == 0 {
304+ if len (selectedRow ) < 5 || len (rows ) == 0 || m . optionCursor >= len ( m . optionValues ) {
301305 return
302306 }
303307 if fmt .Sprintf ("%d" , choice .ID ) == selectedRow [0 ] {
304308 m .workflowContent .Choices [i ].SetValue (m .optionValues [m .optionCursor ])
305309
306310 for i , row := range rows {
307- if row [0 ] == selectedRow [0 ] {
311+ if len ( row ) >= 5 && row [0 ] == selectedRow [0 ] {
308312 rows [i ][4 ] = m .optionValues [m .optionCursor ]
309313 }
310314 }
@@ -317,14 +321,14 @@ func (m *ModelGithubTrigger) inputController(_ context.Context) {
317321 for i , boolean := range m .workflowContent .Boolean {
318322 var selectedRow = m .tableTrigger .SelectedRow ()
319323 var rows = m .tableTrigger .Rows ()
320- if len (selectedRow ) == 0 || len (rows ) == 0 {
324+ if len (selectedRow ) < 5 || len (rows ) == 0 || m . optionCursor >= len ( m . optionValues ) {
321325 return
322326 }
323327 if fmt .Sprintf ("%d" , boolean .ID ) == selectedRow [0 ] {
324328 m .workflowContent .Boolean [i ].SetValue (m .optionValues [m .optionCursor ])
325329
326330 for i , row := range rows {
327- if row [0 ] == selectedRow [0 ] {
331+ if len ( row ) >= 5 && row [0 ] == selectedRow [0 ] {
328332 rows [i ][4 ] = m .optionValues [m .optionCursor ]
329333 }
330334 }
@@ -341,7 +345,7 @@ func (m *ModelGithubTrigger) inputController(_ context.Context) {
341345
342346 var selectedRow = m .tableTrigger .SelectedRow ()
343347 var rows = m .tableTrigger .Rows ()
344- if len (selectedRow ) == 0 || len (rows ) == 0 {
348+ if len (selectedRow ) < 5 || len (rows ) == 0 {
345349 return
346350 }
347351
@@ -351,7 +355,7 @@ func (m *ModelGithubTrigger) inputController(_ context.Context) {
351355 m .workflowContent .Inputs [i ].SetValue (m .textInput .Value ())
352356
353357 for i , row := range rows {
354- if row [0 ] == selectedRow [0 ] {
358+ if len ( row ) >= 5 && row [0 ] == selectedRow [0 ] {
355359 rows [i ][4 ] = m .textInput .Value ()
356360 }
357361 }
@@ -366,7 +370,7 @@ func (m *ModelGithubTrigger) inputController(_ context.Context) {
366370 m .workflowContent .KeyVals [i ].SetValue (m .textInput .Value ())
367371
368372 for i , row := range rows {
369- if row [0 ] == selectedRow [0 ] {
373+ if len ( row ) >= 5 && row [0 ] == selectedRow [0 ] {
370374 rows [i ][4 ] = m .textInput .Value ()
371375 }
372376 }
0 commit comments