Repository navigation
fix(diff,review): track DiffDocState revisions in plugin deps and harden row bounds - #2570
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DiffViewer::file_header) callsDiffDocState::set_collapsed, which rebuildsrows/keys(shrinking single-file preview or 1-file diffs fromNrows to1row,[DiffRow::File(f)]) and bumpsrev/keys_revwithout bumpingSessionReview::stamp. Becausenative::diff::version(Dep::Diff) omitteddiffs.keys_rev()anddiffs.rev(), bothside-region'sregion_withandsurfaces::render_opt_lazy'smemo_with_hashreturned the cachedEltree with the stalevirtual_rowscount andvirtual_rows_version. Rune's virtualizer then invokedInner::row(s, 1)against the 1-elementst.rowsslice, panicking atcrates/opencode-code-view/src/diff/view.rs:370:24(index out of bounds: the len is 1 but the index is 1).DiffDocState::reveal),scroll_to_lineauto-expand, offlinetext_failed, plugin custom diffs (native::custom_diff::version/watched_stampforDep::CustomDiff), and unwrapped narrow review diffs (native::diff::narrow_versionforDep::NarrowReview, now also zero-alloc).visible_rowsto0..rows.len()inrebuildandset_visible_rows, clearedsticky()for collapsed or off-preview files, skipped off-previewfile_rowsentries inscroll_to_file(which can equalrows.len()), guardedst.files().get(f)innumber_celldrag andcode_celltouch-tap handlers, and used.get(i)inrow_keys/Inner::row(matchingnative::tree).Changes
crates/opencode-code-view/src/diff/state.rs: exposerev()/keys_rev(); clampvisible_rowsinrebuildandset_visible_rows; use.get()forself.nav; guardsticky()against collapsed, off-preview, or past-end state.crates/opencode-code-view/src/diff/nav.rs: guardscroll_to_fileagainst off-preview files andfile_rows[file] >= rows.len().crates/opencode-code-view/src/diff/view.rs: use.get(i)inrow_keysandInner::rowwith stale-key / empty-Elfallbacks.crates/opencode-code-view/src/diff/chrome.rs: usest.files().get(f)innumber_cell::on_dragandcode_cell::on_background_press_tx.features/review/src/mobile.rs: exposeNarrowReview::open_diffs.apps/desktop/src/plugin_host/native/diff.rs: includediffs.keys_rev()anddiffs.rev()inDiffVersion/version(keeping.0assr.stampforDiff.Changed); hashsr.stampand each open narrow diff's(path, keys_rev, rev)innarrow_version.apps/desktop/src/plugin_host/native/custom_diff.rs: includediffs.keys_rev()anddiffs.rev()inversionandwatched_stamp.Verification
pwsh -NoProfile -File scripts/guardrails.ps1passed 12/12 (92/94effectiveAppfields, all touched files<= 800lines).Fixes #2562
Reported by @RUBisco0211