Pad/internal/editor/deterministic_file.go
Greg Pomerantz 615957196e feat: virtual scrolling with chunked buffer for large files
- Add ChunkedBuffer for 64KB chunked file access with dirty-chunk
  eviction protection
- Add LineIndex for precise byte-offset-to-line-number mapping
- Refactor IO task system with context cancellation, typed priorities,
  and new task types (ReadChunk, BuildLineIndex, StatFile)
- Add ReadFileAt to FileSystem interface (mock + real implementations)
- Integrate virtual scrolling into editor layout
- Add comprehensive tests for chunked buffer eviction, dirty-chunk
  safety, and full edit lifecycle
2026-06-05 09:11:32 -04:00

29 lines
880 B
Go

package editor
import (
"bytes"
"fmt"
)
// NewDeterministicFile generates a large byte slice using a repeating pattern.
// Same parameters always produce identical content.
func NewDeterministicFile(seed uint64, blockSize int, repeatCount int) []byte {
block := make([]byte, blockSize)
for i := 0; i < blockSize; i++ {
// Simple deterministic pattern based on seed and index
block[i] = byte((seed + uint64(i)) % 256)
}
return bytes.Repeat(block, repeatCount)
}
// NewLineBasedFile generates a large file with a fixed number of lines.
// Each line is predictably formatted: "Line <num>: <seed-based-data>\n".
func NewLineBasedFile(seed uint64, lineCount int) []byte {
var buf bytes.Buffer
for i := 0; i < lineCount; i++ {
line := fmt.Sprintf("Line %d: seed=%d, data=some-deterministic-filler-text-here\n", i, seed)
buf.WriteString(line)
}
return buf.Bytes()
}