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
This commit is contained in:
gmp
2026-06-05 09:11:32 -04:00
parent c941a02f1a
commit 615957196e
16 changed files with 1949 additions and 423 deletions
+16
View File
@@ -1,6 +1,7 @@
package real
import (
"io"
"os"
"path/filepath"
"pad/internal/io/pool/types"
@@ -37,6 +38,21 @@ func (fs *RealFileSystem) ReadFile(path string) ([]byte, error) {
return os.ReadFile(filepath.Join(fs.Root, path))
}
func (fs *RealFileSystem) ReadFileAt(path string, offset, size int) ([]byte, error) {
fullPath := filepath.Join(fs.Root, path)
f, err := os.Open(fullPath)
if err != nil {
return nil, err
}
defer f.Close()
buf := make([]byte, size)
n, err := f.ReadAt(buf, int64(offset))
if err != nil && err != io.EOF {
return nil, err
}
return buf[:n], nil
}
func (fs *RealFileSystem) WriteFile(path string, content []byte) error {
// Simple write for backward compatibility if needed,
// but defer to Atomic implementation.