@@ -1306,6 +1306,10 @@ func (l *list[T]) findWordBoundaries(col, line int) (startCol, endCol int) {
1309+ if line < 0 || line >= len(lines) {
1309 currentLine := lines[line]
1313 currentLine := lines[line]
1310 gr := uniseg.NewGraphemes(currentLine)
1314 gr := uniseg.NewGraphemes(currentLine)
1311 startCol = -1
1315 startCol = -1
@@ -1340,10 +1344,6 @@ func (l *list[T]) findParagraphBoundaries(line int) (startLine, endLine int, fou
1340 line = (len(lines) - 1) - l.height + line + 1
1344 line = (len(lines) - 1) - l.height + line + 1
1343− if strings.TrimSpace(lines[line]) == "" {
1347 if l.offset > 0 {
1347 if l.offset > 0 {
1348 if l.direction == DirectionBackward {
1348 if l.direction == DirectionBackward {
1349 line -= l.offset
1349 line -= l.offset
@@ -1357,6 +1357,10 @@ func (l *list[T]) findParagraphBoundaries(line int) (startLine, endLine int, fou
1357 return 0, 0, false
1357 return 0, 0, false
1360+ if strings.TrimSpace(lines[line]) == "" {
1360 // Find start of paragraph (search backwards for empty line or start of text)
1364 // Find start of paragraph (search backwards for empty line or start of text)
1361 startLine = line
1365 startLine = line
1362 for startLine > 0 && strings.TrimSpace(lines[startLine-1]) != "" {
1366 for startLine > 0 && strings.TrimSpace(lines[startLine-1]) != "" {