B:BD[
3.702] → [
3.702:742]
| some s => (s, currentSt)
| some (s, cachedScrollCol, cachedWidth) =>
if cachedScrollCol == view.scrollCol.val && cachedWidth == availableWidth then
(s, currentSt)
else
-- Cache miss; fall through to recompute.
match getLineFromBuffer buf lineIdx with
| some lineStr =>
let sub := lineStr.toRawSubstring.drop view.scrollCol.val
let dl := takeVisual sub availableWidth
let updatedBuf := { buf with cache := buf.cache.update lineIdx dl view.scrollCol.val availableWidth }
let s' := currentSt.updateCurrentWorkgroup fun wg =>
{ wg with buffers := wg.buffers.map (fun (b : FileBuffer) => if b.id == buf.id then updatedBuf else b) }
(dl, s')
| none => ("", currentSt)