yorukot/superfile · error
invalid row range [%v, %v], line count : %v
Error message
invalid row range [%v, %v], line count : %v
What it means
extractComponent slices a rectangular region out of rendered lines and first validates the row bounds. This error is thrown when pos.stRow is negative, stRow > endRow, or endRow is beyond the last line (len(lines)). The message includes the requested range and the actual line count for debugging.
Source
Thrown at src/internal/validation.go:401
func (m *model) validateComponentPlacement(lines []string, pos compPosition, border bool) error {
extractedLines, err := m.extractComponent(lines, pos)
if err != nil {
return fmt.Errorf("failure while extracting content : %w", err)
}
cntRow := pos.endRow - pos.stRow + 1
cntCol := pos.endCol - pos.stCol + 1
extractedOut := strings.Join(extractedLines, "\n")
if err := validateRender(extractedOut, cntRow, cntCol, border); err != nil {
return fmt.Errorf("failure in extracted content : %w", err)
}
return nil
}
// Inclusive
func (m *model) extractComponent(lines []string, pos compPosition) ([]string, error) {
if 0 > pos.stRow || pos.stRow > pos.endRow || pos.endRow >= len(lines) {
return nil, fmt.Errorf("invalid row range [%v, %v], line count : %v",
pos.stRow, pos.endRow, len(lines))
}
firstLineWidth := ansi.StringWidth(lines[0])
if 0 > pos.stCol || pos.stCol > pos.endCol || pos.endCol >= firstLineWidth {
return nil, fmt.Errorf("invalid col range [%v, %v], first line width : %v",
pos.stCol, pos.endCol, firstLineWidth)
}
cntRow := pos.endRow - pos.stRow + 1
extractedLines := make([]string, cntRow)
for i := range cntRow {
orgIdx := pos.stRow + i
extractedLines[i] = ansi.Cut(lines[orgIdx], pos.stCol, pos.endCol+1)
}
return extractedLines, nil
}
type compPosition struct {View on GitHub (pinned to b72f550bc6)
Solutions
- Clamp endRow to len(lines)-1 and stRow to >= 0 before calling validateComponentPlacement
- Check terminal size handling: ensure the layout doesn't allocate more rows than available
- Log len(lines) vs requested rows to find the off-by-one
- Recompute compPosition from the freshly rendered content instead of cached values
Example fix
// before
m.validateComponentPlacement(lines, pos, border)
// after
if pos.endRow >= len(lines) {
pos.endRow = len(lines) - 1
}
if pos.stRow < 0 {
pos.stRow = 0
}
if pos.stRow <= pos.endRow {
m.validateComponentPlacement(lines, pos, border)
} Defensive patterns
Strategy: validation
Validate before calling
func rowsInRange(lines []string, pos compPosition) bool {
return pos.stRow >= 0 && pos.stRow <= pos.endRow && pos.endRow < len(lines)
} Try / catch
if err := m.validateComponentPlacement(lines, pos, border); err != nil {
var rngErr = err // message contains range and line count
log.Printf("row bounds violated: %v", rngErr)
return fmt.Errorf("skipping validation for %v: %w", pos, err)
} Prevention
- Always clamp endRow to len(lines)-1 before extraction
- Handle empty render output (len(lines)==0) explicitly
- Verify terminal size is known before layout math
- Prefer computing rows from the rendered slice length, not the desired height
When it happens
Trigger: Calling validateComponentPlacement (which calls extractComponent) with a compPosition whose rows exceed the rendered content — e.g., endRow >= len(lines) after a component shrank, or a negative stRow from a bad layout computation.
Common situations: Terminal too small so the rendered content has fewer lines than the component's allocated rows; stale position data after re-render; arithmetic error in layout math producing negative start row.
Related errors
- failure while extracting content : %w
- invalid col range [%v, %v], first line width : %v
- source path does not exist: %s
- failure in extracted content : %w
- dimensions must be positive (maxWidth=%d, maxHeight=%d)
AI-assisted analysis of yorukot/superfile@b72f550bc6 (2026-09-01).
Data as JSON: /api/errors/1cf5f6dc6928b285.
Report an issue: GitHub.