Skip to content

fix: Validate restored sessions and fix inline preview autocmd leak#37

Merged
mhiro2 merged 2 commits into
mainfrom
fix/harden-disk-restore-and-preview-leak
Jun 2, 2026
Merged

fix: Validate restored sessions and fix inline preview autocmd leak#37
mhiro2 merged 2 commits into
mainfrom
fix/harden-disk-restore-and-preview-leak

Conversation

@mhiro2
Copy link
Copy Markdown
Owner

@mhiro2 mhiro2 commented Jun 2, 2026

Summary

  • Validate session items read from disk before restoring so a single corrupt entry no longer aborts the whole restore
  • Harden normalize_range as the validation chokepoint for untrusted data, coercing corrupt ranges to safe defaults
  • Fix a leak where the inline preview's once close-event autocmds stayed armed after close()

Changes

  • 254f06b : fix(persist): validate session items and ranges restored from disk
    • Type-check each item (uri string / range table) in the restore loop and isolate it in pcall so one corrupt entry cannot abort restoring the rest of the session
    • Count only items that actually produce a popup as restored, so the skipped-item warning, PeekstackRestore item_count, and on_done result reflect the real outcome
    • Add type validation to normalize_range, coercing non-table range/start/end and non-numeric line/character to safe defaults
  • 31a4d64 : fix(ui): clear inline preview augroup on close to prevent autocmd leak
    • Delete the PeekstackInlinePreview augroup in close() so the remaining once close-event autocmds are disarmed when one of them fires, instead of staying armed and triggering on unrelated later activity

mhiro2 added 2 commits June 3, 2026 08:13
Restore now type-checks each stored item (uri string, range table) and
isolates per-item restoration in pcall so a single corrupt entry no
longer aborts the whole session. Only items that actually produce a
popup count as restored, so the skipped-item warning, PeekstackRestore
item_count, and on_done result reflect the real outcome. normalize_range
becomes the validation chokepoint for untrusted data, coercing corrupt
range/position shapes to safe defaults instead of crashing downstream.
close() now deletes the PeekstackInlinePreview augroup so the remaining
`once` close-event autocmds are disarmed when one of them fires, instead
of staying armed and triggering close on unrelated later activity.
@mhiro2 mhiro2 self-assigned this Jun 2, 2026
@mhiro2 mhiro2 added the bug Something isn't working label Jun 2, 2026
@mhiro2 mhiro2 merged commit 33f3b38 into main Jun 2, 2026
3 checks passed
@mhiro2 mhiro2 deleted the fix/harden-disk-restore-and-preview-leak branch June 2, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant