on main help sign in
fix(selection): fix panic that can happen on selection
commitfd890f19c893325eb80aa0d6f0edade3f40b6b47 authorAndrey Nering <andreynering@users.noreply.github.com> dateThu 7 Aug 2025, 17:12 (1 year ago) parent13a3e6a
1 file changed+8−4
internal/tui/exp/list/list.go+8−4
internal/tui/exp/list/list.go+8−4
@@ -1306,6 +1306,10 @@ func (l *list[T]) findWordBoundaries(col, line int) (startCol, endCol int) {
13061306 }
13071307 }
13081308
1309+ if line < 0 || line >= len(lines) {
1310+ return 0, 0
1311+ }
1312+
13091313 currentLine := lines[line]
13101314 gr := uniseg.NewGraphemes(currentLine)
13111315 startCol = -1
@@ -1340,10 +1344,6 @@ func (l *list[T]) findParagraphBoundaries(line int) (startLine, endLine int, fou
13401344 line = (len(lines) - 1) - l.height + line + 1
13411345 }
13421346
1343− if strings.TrimSpace(lines[line]) == "" {
1344− return 0, 0, false
1345− }
1346−
13471347 if l.offset > 0 {
13481348 if l.direction == DirectionBackward {
13491349 line -= l.offset
@@ -1357,6 +1357,10 @@ func (l *list[T]) findParagraphBoundaries(line int) (startLine, endLine int, fou
13571357 return 0, 0, false
13581358 }
13591359
1360+ if strings.TrimSpace(lines[line]) == "" {
1361+ return 0, 0, false
1362+ }
1363+
13601364 // Find start of paragraph (search backwards for empty line or start of text)
13611365 startLine = line
13621366 for startLine > 0 && strings.TrimSpace(lines[startLine-1]) != "" {