Compare commits
5 Commits
448c3bf477
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| e3d44f24c0 | |||
| 496c93774f | |||
| c6901eaaa6 | |||
| ce434a1c17 | |||
| 846803a3e2 |
@@ -34,6 +34,8 @@ Use the persistent **Review ID** printed by `list`, not a list position. IDs are
|
||||
|
||||
`show` includes unresolved comments by default; `--all` includes resolved comments too. Human-readable output is the default, with source excerpts in language-tagged Markdown code blocks. JSON includes the canonical repository root, storage review ID/revision, summary/verdict, total/resolved/unresolved counts, and comments with exact zero-based, end-exclusive grapheme anchors and raw selected source excerpts—not whole source files or Markdown fences. `list --json` returns the repository and review metadata/counts without comments. Explicit editor JSON exports still contain complete anchor source text.
|
||||
|
||||
`list` omits reviews with no comments in both text and JSON output. Reviews containing only resolved comments remain listed. Commentless reviews remain stored to preserve file checkmarks, summaries, and verdicts; the editor can still resume them, and `show ID` can inspect them directly.
|
||||
|
||||
`list` and `show` are read-only. `delete REVIEW_ID COMMENT_ID` immediately commits deletion of one resolved or unresolved comment. `resolve REVIEW_ID COMMENT_ID` instead marks that comment resolved, preserving its body and original anchor. Repeating resolution succeeds without writing or advancing the review revision. Both commands print the updated review with its remaining unresolved comments (`--json` is supported); use `show REVIEW_ID --all` to verify resolved feedback. Both IDs are required; missing reviews/comments and repository mismatches fail without changing stored reviews or creating missing storage. Deleting the last comment keeps the review, summary, and verdict. Concurrent saves use the same revision-conflict protection as the editor; an already-open editor must reload before saving after a CLI change. Existing JSON exports are not modified.
|
||||
|
||||
`vamp review` still opens a file named `review`; `vamp -- --review` opens a file named `--review`.
|
||||
|
||||
@@ -1,26 +1,6 @@
|
||||
- [x] improve: conflict resolution view.
|
||||
- two-pane mode:
|
||||
- currently, we display the two panes as if it were a diff, where the left side will be displayed as if the code in question will be removed, and the left pane will display the code in question as if it will be added.
|
||||
- this doesn't really make sense, since code on either side (either version) will be added/removed.
|
||||
- i'm wondering if it would make sense to display in both panels both changes that would and changes that would add code, meaning:
|
||||
- if some code would be removed, it would display in red with a minus
|
||||
- if some code would be added, it would display in green with a plus
|
||||
- this would be the case for both panes
|
||||
- probably something similar for three-pane mode would make sense.
|
||||
- [x] improve: code commenting format. example of comment in current format:
|
||||
<attachment>
|
||||
Comment 14 [unresolved] source/sema/resolve.hon (after) 22:9–22:19 @ working:a3b4159a340b3546e2108bc2dc0e7c302fc6d84b
|
||||
[8]Builtin
|
||||
can't we do `[_]Builtin` here instead for array size inference? if not, this is probably an oversight in the brolang compiler 🤔
|
||||
</attachment>
|
||||
- would probably be nice to instead do this though, if possible, i.e. wrapping the code snippet in question in a codeblock annotated with the right language, e.g.:
|
||||
<attachment>
|
||||
Comment 14 [unresolved] source/sema/resolve.hon (after) 22:9–22:19 @ working:a3b4159a340b3546e2108bc2dc0e7c302fc6d84b
|
||||
```hon
|
||||
[8]Builtin
|
||||
```
|
||||
can't we do `[_]Builtin` here instead for array size inference? if not, this is probably an oversight in the brolang compiler 🤔
|
||||
</attachment>
|
||||
- [x] improve: diff picker - if jj managed, present as jj log.
|
||||
- this makes it much easier to determine which revisions to actually pick for before/after
|
||||
- the bookmarks only view could simply filter out unbookmarked revisions but otherwise display in the same way
|
||||
- [ ] feature: diff view - GitHub code review integration after the local review UX is usable.
|
||||
- publish local reviews explicitly: general PR comments, inline line/range comments, review summaries, approval, and requests for changes.
|
||||
- preserve explicit PR identity and reviewed commit IDs; validate anchors against GitHub's PR diff and recheck the PR head before submission.
|
||||
|
||||
@@ -20,6 +20,7 @@ One editor crate; the workspace also includes its patched Crossterm dependency.
|
||||
- `review`: owns the validated local review model, exact immutable anchors, persisted file checkmarks, SQLite storage through bundled rusqlite, and atomic JSON import/export with external-change protection. Schema 4 stores review identity, repository, revision, summary, verdict, and nullable ordered comparison endpoints in `reviews`; null endpoints identify source reviews. `comments` stores ordered comment IDs, bodies, resolution states, and explicit immutable anchor fields. `reviewed_files` stores revision pairs, paths, optional old paths, and optional exact live After text. Foreign keys, unique keys, and checks enforce relationships and scalar invariants. Full `u64` comment IDs use checked decimal text because SQLite integers are signed. No JSON documents are stored in SQLite.
|
||||
`Store` retains compare-and-swap review revisions and atomic whole-review saves: metadata and replacement comment/checkmark rows commit together. A stored review cannot be reassigned to another scope. Read transactions reconstruct validated reviews from one consistent snapshot, including when listing in descending ID order. Stored text is bounded to 64 MiB per review, including a fixed per-comment/checkmark overhead. JSON version 5 is an independent import/export format. Incompatible databases, including schema 3, are rejected and preserved without migration or reset. CLI metadata and selectors reuse loaded reviews; selector choices live only in the displayed buffer.
|
||||
The review CLI keeps `list`/`show` read-only. Comment deletion and resolution validate the explicit review/comment IDs through an existing read-only store before opening it for a compare-and-swap save; absent storage and invalid targets do not create reviews or a database. Resolution preserves comment bodies and immutable anchors; already-resolved comments succeed without writing or advancing the revision.
|
||||
CLI listings exclude reviews with zero comments, not reviews with zero unresolved comments. Filtering stays at the CLI boundary: storage listing and editor restoration retain commentless reviews and their file checkmarks, summaries, and verdicts.
|
||||
`editor_review` owns tab-local review state selected by canonical repository root and ordered resolved comparison identities, or a separate source scope for ordinary repository buffers. A sole scope-matching review restores automatically; multiple matches open the floating selector. `diff` freezes initial review endpoints through in-place Working refreshes; explicit comparisons and moved bookmark endpoints resolve their own scope. Source and comparison panes share the comment editor, immutable anchors, storage, and review commands, not their review documents. Dirty drafts block scope changes, and stored/JSON opens reject mismatched scopes before replacing state. Comment/summary text saves explicitly; dismissing discards that editor's unsaved text, while switching may retain hidden drafts. Verdicts/deletions/resolution changes commit immediately without saving drafts. Exports retain their own file baseline and do not become automatic persistence targets; imports get fresh database identities. Review editors remain tab-owned native panes outside the workspace `PaneTree`. The session supplies the configured or XDG default directory; direct `Editor` callers inject a directory with `set_review_directory` to enable persistence.
|
||||
Successful SQLite autosaves and JSON-only saves share one acknowledgement operation: clear review dirtiness and advance the owning tab's native draft saved baselines only after persistence succeeds. Failed writes retain unsaved state; JSON exports do not acknowledge a pending SQLite save.
|
||||
Review replacement and comment deletion are private editor-owned operations. Replacement loads and validates its Stored/JSON/New source before retiring old bindings, installing the document, and resetting selection/navigation. Deletion retires and acknowledges only the matching comment drafts, preventing stale text from overwriting reused IDs. Both persist before opening the overview; a post-mutation save failure retains the applied, unsaved identity change. Native text/undo and general transition guards remain unchanged.
|
||||
@@ -64,7 +65,7 @@ Frontends inspect `file_picker()` for query, presentation, view, explorer-local
|
||||
Frontends inspect `diagnostics()` and `diagnostic_at_cursor()` for validated active-buffer annotations. Diagnostics are owned by core LSP or a plugin and buffer revision; text changes clear them. Native server retirement removes only that server's contribution, preserving sibling diagnostics. The TUI underlines annotated text, colors affected gutter numbers by severity, and displays the primary caret's diagnostic message without replacing search/selection backgrounds.
|
||||
Frontends borrow `semantic_tokens()` for sorted, single-line grapheme spans from the active buffer. Immutable `Arc` slices are shared by native LSP and buffer storage; painting does not copy tokens. Text replacements retain tokens outside the changed range and shift following positions using whole graphemes, including newline changes. Tokens overlapping the changed range are dropped; disjoint edits conservatively invalidate the range between their first and last changes. This applies to typing, undo/redo, completion, plugin replacements, and disk reloads. Path changes discard overlays. Native updates validate the whole applicable annotation batch before mutation. The TUI merges semantic styling into its existing glyph pass above syntax foregrounds but below diagnostic/search/selection/caret styling.
|
||||
Frontends inspect `hover()` for optional read-only content and logical-line/grapheme scroll offsets. Popup request eligibility, dismissal, and scrolling stay editor/session-owned; the TUI clips the panel inside the full editor area without changing the primary cursor or viewport. Its hover-local syntax cache treats content as Markdown, including named fenced-code injections, and rebuilds only when content changes. The popup shares the document syntax palette and preserves raw Markdown text and logical scroll coordinates.
|
||||
Frontends borrow `completion()` for the read-only item list and selected index: zero is Original text, and other indices select `items[selected - 1]`. The editor owns the immutable original document/carets, atomic candidate transactions, cycling/dismissal, pending Insert undo, and final-only repeat recording. It changes only the primary completion target and translates secondary carets through all edits. The TUI places a windowed list near the current caret, bounded by the full editor rather than its pane, sanitizes/clips labels and detail by grapheme, and preserves hardware cursor ownership; wheel input over the list is consumed without dispatching edits.
|
||||
Frontends borrow `completion()` for the read-only item list and selected index: zero is Original text, and other indices select `items[selected - 1]`. The editor owns the immutable original document/carets, atomic candidate transactions, cycling/dismissal, pending Insert undo, and final-only repeat recording. It changes only the primary completion target and translates secondary carets through all edits. The TUI places a windowed list near the current caret, bounded by the full editor rather than its pane, sanitizes/clips labels and detail by grapheme, and preserves logical cursor ownership; wheel input over the list is consumed without dispatching edits.
|
||||
Frontends borrow `snippet_selections()` for the active argument's end-exclusive grapheme ranges, including mirrors and empty tabstops. The editor caches those ranges after previews, argument edits, and navigation; rendering adds no snippet allocation. Template edits stay primary-only, translate other carets, and fold resolved replacement text and caret placement into the pending completion repeat step. Per-occurrence ancestry distinguishes nested arguments from adjacent empty stops, allowing enclosing replacements to retire only overwritten descendants.
|
||||
|
||||
## Terminal lifecycle and layout
|
||||
@@ -73,13 +74,13 @@ The terminal guard owns raw mode, alternate-screen state, bracketed paste, mouse
|
||||
|
||||
`tui::TerminalSession::run(inherited_screen, body)` scopes this ownership; `tui::run(&mut session, inherited_screen)` renders inside that active guard. On Unix, a fresh alternate screen pushes disambiguated keyboard flags so Ctrl+i stays distinct from Tab; final cleanup pops them. `TerminalSession::prepare_restart()` resets process-local input state without leaving the alternate screen or popping its keyboard flags. The replacement process inherits that stack entry rather than pushing another, and the guard stays armed if relaunch fails.
|
||||
|
||||
Redraws stage Ratatui's buffer diff, cursor placement, and DEC synchronized-update commands (mode 2026) in a reusable byte buffer, then write and flush the complete frame to the terminal. Frame computation never suspends terminal presentation; synchronization covers transmitted painting rather than layout/highlighting work. The hardware cursor is hidden before painting even when synchronization is unsupported. Terminal cleanup releases synchronization before leaving the alternate screen or invoking caller panic diagnostics. Backend-writer access is enabled solely for this staging seam.
|
||||
Redraws stage Ratatui's buffer diff, logical cursor placement, and DEC synchronized-update commands (mode 2026) in a reusable byte buffer, then write and flush the complete frame to the terminal. Frame computation never suspends terminal presentation; synchronization covers transmitted painting rather than layout/highlighting work. `WheelPanels::cursor` records the final focused cursor position; the software cursor is painted after overlays, using the same named ANSI mode palette as the bars. `SoftwareCursorBackend` delegates drawing and cursor coordinates but suppresses hardware-cursor visibility, retaining input-method placement without a second cursor or OSC 12 dependency. The hardware cursor stays hidden even when synchronization is unsupported. Terminal cleanup releases synchronization before leaving the alternate screen, then restores cursor visibility before returning or invoking caller panic diagnostics. Backend-writer access is enabled solely for this staging seam.
|
||||
|
||||
`terminal_colors` intercepts crossterm's key-shaped OSC 11/4 replies before editor dispatch, assembles a bounded RGB background/red/green triple, and preserves unrelated events and opaque bracketed paste. Queries never block input and start after painting, so syntax initialization does not spend their reply deadline. Startup, color-scheme notifications, and focus-regain queries replace cached diff tints atomically. While any rendered pane shows a diff, a one-second fallback probes for silent palette changes or missed notifications; ordinary editor views do not poll. Its injected-time deadline prevents overlapping periodic requests. An unanswered/partial query expires after 250 ms and removes stale tints rather than assuming a dark theme. Valid late replies are consumed without becoming editing commands. The frontend precomputes rounded RGB blends from the original background (18% row, 38% character), propagating them to active, parked, and newly created panes.
|
||||
|
||||
`vendor/crossterm` retains Crossterm 0.29.0's upstream source and MIT license, with a small Unix decoder patch exposing `Event::ColorSchemeChanged` for `CSI ? 997 ; 1/2 n`. The report signals a palette refresh, not a choice of hard-coded light/dark colors. Valid fragmented reports and malformed color reports leave following keys intact. Cargo patches both direct and Ratatui dependency paths to this one copy; remove the patch/workspace member once upstream supports these notifications.
|
||||
|
||||
The TUI allocates a flexible buffer viewport and optional one-row top/bottom bars, with no reserved prompt/message footer. Both bars derive visibility from configured content: empty content takes no row, and tabs-only content is hidden with a single tab in either position. Both render across ordinary, split, diff, and selector views. Ordered left/center/right groups use full-row centering, active-tab collision priority, internal padding, and independent styled edges. Floating Command/Search input owns the hardware cursor; non-focusable operation/diagnostic notifications anchor bottom-right inside the chrome-free workspace and hide obscured document carets. Higher-priority modal overlays suppress them without changing input state. Wheel hit regions clear each frame and consume reports over these popups. Zero-sized terminals render nothing; minimal-height input never reserves another row. Layout and terminal-cell text mapping remain frontend-owned.
|
||||
The TUI allocates a flexible buffer viewport and optional one-row top/bottom bars, with no reserved prompt/message footer. Both bars derive visibility from configured content: empty content takes no row, and tabs-only content is hidden with a single tab in either position. Both render across ordinary, split, diff, and selector views. Ordered left/center/right groups use full-row centering, active-tab collision priority, internal padding, and independent styled edges; accented content and edges share the focused mode's ANSI palette colors. Floating Command/Search input owns the software cursor; non-focusable operation/diagnostic notifications anchor bottom-right inside the chrome-free workspace and hide obscured document carets. Higher-priority modal overlays suppress them without changing input state. Wheel hit regions clear each frame and consume reports over these popups. Zero-sized terminals render nothing; minimal-height input never reserves another row. Layout and terminal-cell text mapping remain frontend-owned.
|
||||
|
||||
Comparison views reserve no separate metadata header or native-buffer help footer. Revision labels render bottom-left in pane borders (combined on single-pane views), with per-side editability top-right and focus indicated by border styling. Dock and document geometry use the reclaimed workspace rows; conditional loading/error/file notices remain separate from the border metadata.
|
||||
|
||||
|
||||
+12
-2
@@ -15,6 +15,8 @@ Vamp.configure do |config|
|
||||
config.clipboard_mode = "system"
|
||||
config.git_blame = true # false disables current-line attribution
|
||||
config.git_gutter = "bar" # or "symbols", "line_numbers", "none"
|
||||
config.cursor = {} # mode colors enabled; all modes use a block cursor
|
||||
# config.cursor = { mode_colors: false, insert: :bar, visual: :underline }
|
||||
config.scroll_distance = 0 # nonnegative edge distance, or nil to center
|
||||
config.scroll_step_lines = nil # Ctrl+u/d: half viewport, or a positive screen-row count
|
||||
config.highlight_trailing_whitespace = false # true marks line-end whitespace in red
|
||||
@@ -58,6 +60,12 @@ Plugin paths resolve relative to the config file, not the shell's working direct
|
||||
`config.file_explorer_side` defaults to `"right"`; other choices are `"left"`, `"top"`, and `"bottom"`. Independent `file_explorer_view` / `file_picker_view` preferences both default to `"tree"` and accept `"list"` as an alternative. Invalid preference strings report notices and retain defaults while valid bindings still install. Non-string/empty values disable the whole configuration like other Ruby type errors.
|
||||
`config.clipboard_mode` accepts `"system"` (default) or `"separate"`. An invalid policy string reports a notice and retains System while valid bindings still install; non-string/empty values reject the whole Ruby configuration.
|
||||
|
||||
`config.cursor` accepts a partial hash. `mode_colors` defaults to `true`: the primary software cursor and secondary text carets use the terminal's ANSI cyan in Normal, green in Insert, magenta in Visual (including Visual Line), yellow in Command, and blue in Search. These are palette entries from the current terminal color scheme, not fixed RGB colors. Set `config.cursor = { mode_colors: false }` for a neutral reverse-video block cursor (default text color for bar/underline); secondary carets retain their magenta highlight.
|
||||
|
||||
The `normal`, `insert`, `visual`, `command`, and `search` keys select software cursor shapes: `:block`, `:bar`, or `:underline` (strings also work). Every mode defaults to a steady block. Block and underline preserve the displayed grapheme; the bar draws `▏` over the hovered character until the cursor moves. For example, `config.cursor = { insert: :bar, visual: :underline }` changes those two shapes without disabling mode colors. Each assignment replaces the cursor configuration; omitted keys retain built-in defaults. Unknown keys, nonboolean `mode_colors`, unsupported shapes, and non-hash values reject the configuration.
|
||||
|
||||
Shapes apply to the primary cursor, including command/search prompts, pickers, and historical/diff text; secondary carets remain cell highlights. The cursor is painted after the focused view's overlays, takes precedence over syntax/search/selection colors, and disappears when its position is offscreen or covered by a notification. The hardware cursor stays hidden during editing; its logical position is retained for input methods, and normal exit/errors/panics restore its visibility. Vamp does not change terminal cursor color or shape settings, so multiplexers need no native cursor-color support. File contents and cursor positions remain unchanged.
|
||||
|
||||
`config.scroll_distance` defaults to `0`: keep the viewport still until its primary cursor or selected picker entry would leave it. A nonnegative integer reserves that many visible rows above/below the cursor, and terminal-cell columns left/right in unwrapped text. `nil` keeps it centered; integers at least half the current viewport dimension behave the same way until resizing makes that margin usable. The start of content limits centering, while trailing blank space allows centering near the end. Whole two-row picker entries stay aligned, using the nearest entry to the center when exact margins cannot fit.
|
||||
|
||||
The setting applies to ordinary and historical buffers, split/unified diff panes, file pickers and explorers, command/buffer palettes, completion lists, and revision selectors. Wrapped text measures visual rows, not source lines; picker distances use result rows, excluding borders, search fields, and help. Manual mouse-wheel scrolling remains detached until keyboard navigation resumes. Only `nil` or integers from `0` through the platform's Rust `usize` maximum (`18446744073709551615` on 64-bit systems) are accepted; other values reject the configuration.
|
||||
@@ -105,7 +113,7 @@ Indicators compare the current editor text (including unsaved edits) against Git
|
||||
|
||||
`config.diff_view_mode` selects the initial view for each new comparison: `"split"` (default) or `"unified"`. `config.diff_split_orientation` selects `"vertical"` (left/right, default) or `"horizontal"` (above/below) for split views. Invalid values reject the configuration. Normal-mode **Space v** cycles split/unified; **Space s** flips split orientation. These controls affect the current comparison, not startup defaults, and retain their choices across file switches and tabs. Orientation changes apply only in split view.
|
||||
|
||||
`config.diff_follow_working_copy` defaults to `true`. A Working-checkout After follows descendant checkouts automatically, including in inactive tabs; `false` disables endpoint following without disabling ordinary live-buffer editing or reload. Only literal booleans are accepted. Pinned After endpoints never move, but their checkout-aware editability checks remain enabled regardless of this setting. See [repository diff](editing.md#repository-diff) for ancestry and refresh behavior.
|
||||
`config.diff_follow_working_copy` defaults to `true`. The After picker calls its live-files choice **Follow checkout** when enabled, otherwise **Checkout snapshot**. Following advances to descendant checkouts automatically, including in inactive tabs; `false` disables endpoint following without disabling ordinary live-buffer editing or reload. Only literal booleans are accepted. Before is always frozen. Pinned After endpoints never move, but their checkout-aware editability checks remain enabled regardless of this setting. See [repository diff](editing.md#repository-diff) for ancestry and refresh behavior.
|
||||
|
||||
`config.pull_request_review_requested_symbol` and `config.pull_request_approved_symbol` control the markers before PR numbers in the pull-request picker. Defaults are `"🙏"` for an outstanding personal review request and `"👍"` for your active approval, using the API-authenticated account. Requests take precedence over approvals when both apply. Each option accepts a string without control characters; multi-character and wide Unicode symbols are supported. Set either to `""` to hide that state, or both to `""` to remove the marker gutter. PR numbers and metadata stay aligned by terminal-cell width, including rows without a marker. Non-strings and strings containing tabs, newlines, or other control characters reject the configuration.
|
||||
|
||||
@@ -135,6 +143,8 @@ config.bind "leader s", config.core.diff.orientation.toggle
|
||||
|
||||
`config.bar.top` and `config.bar.bottom` each accept ordered `left`, `center`, and `right` arrays of segment names. Both bars accept every builtin and custom segment, with the same anchors, title templates, margins, padding, styled edges, and collision handling. Left and right groups anchor to their respective edges; the center group is centered on the whole row, not on the gap remaining between the other groups. Array order is display order within each group. Omitted groups and segment options retain that bar's defaults; an empty array removes that group.
|
||||
|
||||
Accented segments (including active tabs, mode, position, and custom labels), their padding, and decorative edge colors follow the focused editing mode using the same ANSI palette as the software cursor. Both bars change together; inactive tabs, neutral text, separators, and margins retain their existing styling. Setting `config.cursor = { mode_colors: false }` affects cursors only, not the bars.
|
||||
|
||||
The renderer inserts one unstyled blank column between visible items in each group, including tab titles. Hidden items contribute no separator; there is no separator before the first or after the last item. Separator widths count toward anchoring and collision handling. Plain-text segments default to no padding or margins, so adjacent labels do not double their spacing.
|
||||
|
||||
Use the two setters independently; a combined `config.bar = { ... }` assignment is not supported.
|
||||
@@ -342,7 +352,7 @@ config.bind "ctrl+h", nil, mode: config.modes.tree
|
||||
|
||||
The diff's changed-file explorer and floating picker use these same tree and selection contexts, including remaps and disabled keys. Enter opens the selected file's comparison; writable After reuses its live buffer. The catalog contains only changed paths, with A/M/D/R status markers, rather than a disk scan.
|
||||
|
||||
Ordinary `config.core.file_picker` and `config.core.file_explorer` bindings work inside comparisons. Ctrl+w closes a focused picker/explorer, retaining its query, selection, and expansion state; the panes use the reclaimed width. Ctrl+e has no reserved diff behavior. Escape closes the revision selector in either stage, but an opened comparison still closes explicitly through `:diff.close`, its palette action, or the generated action value below. `config.core.diff` remains the opening action and exposes immutable `close`, `mode.toggle`, `view.toggle`, and `orientation.toggle` children. New comparisons default to Branch changes (merge base → selected After); Normal-mode Ctrl+b, `:diff.mode.toggle`, or the palette toggles to direct Snapshots and back, preserving the selected endpoints. Selecting Working checkout on either side forces Snapshots.
|
||||
Ordinary `config.core.file_picker` and `config.core.file_explorer` bindings work inside comparisons. Ctrl+w closes a focused picker/explorer, retaining its query, selection, and expansion state; the panes use the reclaimed width. Ctrl+e has no reserved diff behavior. Escape closes the revision selector in either stage, but an opened comparison still closes explicitly through `:diff.close`, its palette action, or the generated action value below. `config.core.diff` remains the opening action and exposes immutable `close`, `mode.toggle`, `view.toggle`, and `orientation.toggle` children. New comparisons default to Branch changes (merge base → selected After); Normal-mode Ctrl+b, `:diff.mode.toggle`, or the palette toggles to direct Snapshots and back, preserving the selected endpoints. Selecting Checkout snapshot or Follow checkout forces Snapshots.
|
||||
|
||||
`config.core.diff.review.toggle` is a non-mutating Normal-mode action, also available as `:diff.review.toggle` and in the palette. It marks/unmarks the highlighted changed-file leaf when the comparison's explorer is focused, or the current comparison file from a text pane. Read-only snapshots permit review marks. The default `c` shortcut applies only while browsing the diff's changed-file tree; explicit bindings and disabled keys override it. For example, `config.bind "ctrl+g", config.core.diff.review.toggle`; use the palette or a control-key binding while filtering, including List view, so printable input stays in the query.
|
||||
|
||||
|
||||
+2
-1
@@ -79,7 +79,8 @@ The two skipped shell cleanup checks execute `/bin/ps`, which macOS refuses to l
|
||||
- Battery checks inject samples and refresh gates, use temporary Linux sysfs fixtures, and validate native value types/bounds without depending on the machine's charge or clock. Unit sessions do not automatically read hardware. Live smoke should compare the default indicator with OS telemetry and observe a production refresh; no-battery, explicit overrides, and disabled anchors must not fabricate values.
|
||||
- Status redesign checks cover component-aware home abbreviation without save-path changes; floating command/search submit/cancel, Unicode/tiny/offset clipping and wheel isolation; footer-row reclamation; notification Escape/modal/prefix priority and covered-caret visibility; and ready-server metadata using real framed subprocess fixtures, including stacks, initialization gates, failure, and focus changes.
|
||||
- Unix terminal-hook checks use isolated child processes and real PTYs to keep process-global hooks out of the parallel runner. They cover raw/alternate-screen/mouse-capture cleanup on entry failure, normal return, I/O errors, and panics during frame construction, including original panic-payload propagation.
|
||||
- Redraw checks inspect actual Crossterm output during repeated scrolling: supporting terminals receive synchronized frames, terminals ignoring synchronization never paint with a visible hardware cursor, and the final caret remains visible. A protocol-state regression verifies that the terminal is not left in synchronized-output mode while the next frame is computed.
|
||||
- Redraw checks inspect actual Crossterm output during repeated scrolling: supporting terminals receive synchronized frames, terminals ignoring synchronization never paint with a visible hardware cursor, and the final software caret remains visible. A protocol-state regression verifies that the terminal is not left in synchronized-output mode while the next frame is computed.
|
||||
- Cursor checks render software block/bar/underline shapes, wide/combining graphemes, cell restoration after motion, neutral reverse-video blocks, and shared ANSI mode accents on both banners through Normal, Insert, Visual, Command, and Search. The production backend preserves logical cursor coordinates without showing the hardware cursor. Live PTY screen parsing and an isolated Herdr 0.9.5 full-client smoke verify that mode-colored cells survive multiplexing, match both banners, avoid OSC 12, leave source bytes unchanged, and restore hardware visibility on exit. Document-layer fixtures exclude the final cursor overlay; complete-frame checks use `BufferViewports` with the production backend adapter.
|
||||
- Wheel checks render document/panel views and cover three-row scrolling, unchanged carets/selections/text, first/last-page clamping, offscreen cursor hiding, no-op/custom-bound navigation reveal, manual persistence through idle/resize/palette updates, and floating/unfocused-docked explorer selection and focus preservation. Queued-input checks verify that the next frame shows ordered wheel steps without crossing a key or resize boundary.
|
||||
- Queued-navigation checks cover counted ordered motions through short rows, Normal/Visual ranges, remapped press/repeat keys, rendered caret visibility, edit/layout/prefix and non-key barriers, and the 64-key fairness bound. Burst smoke must verify the final cursor position as well as frame count; batching reduces queued redraws without increasing the OS/terminal repeat rate.
|
||||
- Native LSP integration checks launch framed-protocol fixture subprocesses, covering initialization/settings, opt-in startup, synchronization, UTF-16/file-URI conversion, dirty targets, stale requests/diagnostics, and transport failures. Stack checks cover independent initialization, diagnostic merging/clearing, sibling failure isolation in active/parked buffers, same-revision rename/close identity, aggregate limits, first-server position routing, and both shutdowns. Semantic ordering uses protocol/file gates; elapsed deadlines only bound stuck subprocesses.
|
||||
|
||||
+12
-8
@@ -74,7 +74,7 @@ With an enabled server that provides completion, Ctrl+n in Insert requests candi
|
||||
|
||||
Every candidate is applied from that same immutable original document, not on top of the previous candidate. A candidate's primary replacement and additional text edits are one atomic change. Other keys close the list without accepting it: plain-text completion retains ordinary typing, newline, and configured Tab insertion; snippet completion keeps its argument navigation described below. Escape returns to Normal retaining the displayed text. There is no automatic popup. Empty, unsupported, or invalid results leave the document unchanged and report a message.
|
||||
|
||||
Cycling creates no separate undo entries. Only the final chosen edits join the existing Insert undo group; choosing Original text adds no completion edit. Undo restores that group, and dot repeats the final resolved completion edits rather than requests or intermediate candidates. The list stays inside the document text workspace, does not cover the gutter or explorer, and never takes the hardware cursor. Wheel input over it is consumed without choosing a candidate.
|
||||
Cycling creates no separate undo entries. Only the final chosen edits join the existing Insert undo group; choosing Original text adds no completion edit. Undo restores that group, and dot repeats the final resolved completion edits rather than requests or intermediate candidates. The list stays inside the document text workspace, does not cover the gutter or explorer, and never takes the primary cursor. Wheel input over it is consumed without choosing a candidate.
|
||||
|
||||
Snippet candidates expand the full template immediately, including parentheses and argument defaults. The first numbered argument is highlighted; typing replaces it, then continues within that argument. Repeated occurrences of the same argument update together, without broadcasting to secondary carets. Backspace/Delete stay within the active argument; Enter can insert a newline there. **Tab** moves forward and **Shift+Tab** backward in ascending tabstop order. Replacing an enclosing argument removes its nested arguments, not adjacent independent ones. Reaching the final `$0` position ends navigation, so subsequent Tab uses the configured spaces-or-tab insertion. Escape, ordinary cursor motion, paste, commands, and focus/buffer changes also end navigation without removing the expanded text.
|
||||
|
||||
@@ -126,7 +126,7 @@ System clipboard publication must succeed before any deletion. Failure preserves
|
||||
|
||||
## Selections and multi-caret editing
|
||||
|
||||
Editing uses an ordered selection set with one primary target. Cursor and word motions apply to every target; Visual motions keep each target's anchor and move its active endpoint. Whole combining sequences and ZWJ emoji remain intact. `v` selects characterwise, inclusive of endpoints; `V` selects every complete row touched by the endpoints, including blank and empty final rows. Switching between `v` and `V` retains endpoints; pressing the current shape's selector again cancels. Read-only ranges are end-exclusive. Characterwise `$`/End can select the newline after a non-final row; selected newlines appear as a blue blank cell after the line. Linewise highlighting covers the copied text, including trailing whitespace, plus one blank cell for each copied newline; unused viewport space and the gutter remain unhighlighted. The status reads VISUAL LINE. Blue highlighting overrides yellow search highlighting; secondary carets are magenta, including on empty lines and at line ends. Only the primary owns the hardware cursor and viewport. The status line counts all targets, including offscreen targets.
|
||||
Editing uses an ordered selection set with one primary target. Cursor and word motions apply to every target; Visual motions keep each target's anchor and move its active endpoint. Whole combining sequences and ZWJ emoji remain intact. `v` selects characterwise, inclusive of endpoints; `V` selects every complete row touched by the endpoints, including blank and empty final rows. Switching between `v` and `V` retains endpoints; pressing the current shape's selector again cancels. Read-only ranges are end-exclusive. Characterwise `$`/End can select the newline after a non-final row; selected newlines appear as a blue blank cell after the line. Linewise highlighting covers the copied text, including trailing whitespace, plus one blank cell for each copied newline; unused viewport space and the gutter remain unhighlighted. The status reads VISUAL LINE. Blue highlighting overrides yellow search highlighting; secondary carets follow the mode palette (magenta in Visual), including on empty lines and at line ends. The primary software cursor overlays these text colors and alone drives the viewport; its shape and mode colors are [configurable](configuration.md#preferences). The status line counts all targets, including offscreen targets.
|
||||
|
||||
Ctrl+k/Ctrl+e clone each target to the adjacent row, preserving preferred terminal-cell columns (tabs use four-cell stops); Visual cloning preserves both endpoints. Duplicate carets and truly overlapping selections merge; adjacent ranges remain distinct. Visual Ctrl+l creates one Normal caret at the first nonblank of each touched row. Visual `I`/`A` similarly create one Insert caret per touched row at first nonblank/end. Occurrence actions use the primary selection as a literal, potentially multiline, grapheme-aligned query: Ctrl+n adds the next non-overlapping occurrence and wraps; Ctrl+s moves only the primary to that occurrence; Ctrl+a selects all occurrences.
|
||||
|
||||
@@ -390,16 +390,20 @@ The project root is the working directory captured at startup. Scanning uses the
|
||||
|
||||
Run `:diff` in Normal mode, choose **Before**, then **After**, and press Enter to compare. The command palette also exposes **Diff**; there is no default keybinding. Repository discovery starts at the active file's directory, or the startup project root for an unnamed buffer, and prefers jj over Git.
|
||||
|
||||
The floating selector has **Revisions / Bookmarks** tabs for jj, or **Commits / Branches / Tags** for Git. Both Before and After support case-insensitive fuzzy search by revision/change ID, commit ID, reference name, or description: `f1205pas` can find `sm/fin-1205-pilot-assignment-schema`. Space-separated tokens must all match, but can match different fields in any order; a single token cannot span unrelated fields. Exact, prefix, and contiguous matches rank ahead of scattered subsequences; otherwise equal matches favor names/IDs over descriptions, word boundaries, and tighter spans. Ties retain catalogue order, and an empty or whitespace-only query restores the original order. **Working checkout** stays first in every category, even when it does not match the query. As Before it is a disk snapshot, including eligible untracked files. As After it includes unsaved regular-text buffers and enables live editing; opening a comparison never saves them.
|
||||
The floating selector has **Revisions / Bookmarks** tabs for jj, or **Commits / Branches / Tags** for Git. jj results use a log graph: `@` marks the recorded checkout revision, `◆` immutable revisions, and `○` other revisions. Each revision shows its short change ID, author, date, bookmarks, commit ID, and description. Bookmarks uses the same graph with unbookmarked revisions omitted; `~` marks skipped ancestry. Multiple bookmarks on one revision remain individually selectable, preserving their symbolic follow behavior. Narrow windows use compact single-line entries.
|
||||
|
||||
New comparisons default to **Branch changes**: Before becomes the unique merge base of the selected Before and After revisions, and After stays the selected tip. Changes exclusive to the Before branch are excluded. The Before border identifies both selected names and the immutable merge-base commit ID. **Snapshots** compares the two selected snapshots directly. **Ctrl+b** toggles the mode, also available as **`:diff.mode.toggle`**, the palette action, and remappable **`config.core.diff.mode.toggle`**. Toggling an opened comparison recomputes using the original selected endpoints. Selecting **Working checkout** on either side immediately forces **Snapshots**; Branch changes is unavailable while it is selected. Missing or multiple merge bases produce an explicit, recoverable selector error rather than silently falling back; choose Snapshots to compare such histories. jj's synthetic root is the empty ancestor of every jj history.
|
||||
Both stages support case-insensitive fuzzy search by revision/change ID, commit ID, reference name, or description: `f1205pas` can find `sm/fin-1205-pilot-assignment-schema`. Space-separated tokens must all match, but can match different fields; a token cannot span unrelated fields. jj keeps graph order while filtering. Git ranks exact, prefix, and contiguous matches ahead of scattered subsequences, with names/IDs ahead of descriptions and catalogue order breaking ties. An empty query restores catalogue order. After choosing Before, its revision carries a **[Before]** badge instead of a separate summary row. It remains included through search and category changes, but scrolls normally.
|
||||
|
||||
The separate checkout choice stays first in every category regardless of the query. It is **Checkout snapshot** during Before selection: a frozen disk snapshot including eligible untracked files. During After selection it is **Follow checkout** when `config.diff_follow_working_copy` is enabled, otherwise **Checkout snapshot**. Either After choice includes unsaved regular-text buffers and enables live editing; opening a comparison never saves them. Unlike this live-files choice, selecting `@` in the graph pins the recorded revision.
|
||||
|
||||
New comparisons default to **Branch changes**: Before becomes the unique merge base of the selected Before and After revisions, and After stays the selected tip. Changes exclusive to the Before branch are excluded. The Before border identifies both selected names and the immutable merge-base commit ID. **Snapshots** compares the two selected snapshots directly. **Ctrl+b** toggles the mode, also available as **`:diff.mode.toggle`**, the palette action, and remappable **`config.core.diff.mode.toggle`**. Toggling an opened comparison recomputes using the original selected endpoints. Selecting **Checkout snapshot** or **Follow checkout** immediately forces **Snapshots**; Branch changes is unavailable while either is selected. Missing or multiple merge bases produce an explicit, recoverable selector error rather than silently falling back; choose Snapshots to compare such histories. jj's synthetic root is the empty ancestor of every jj history.
|
||||
|
||||
| Selector input | Effect |
|
||||
| --- | --- |
|
||||
| Tab / Shift+Tab | Next / previous category |
|
||||
| Up / Down, Ctrl+k / Ctrl+j | Previous / next entry |
|
||||
| Backspace / Ctrl+u | Remove a query grapheme / clear query |
|
||||
| Ctrl+b | Toggle Branch changes / Snapshots (Working checkout requires Snapshots) |
|
||||
| Ctrl+b | Toggle Branch changes / Snapshots (checkout choices require Snapshots) |
|
||||
| Enter | Choose the entry |
|
||||
| Esc | Close either selector stage, cancel outstanding work, and restore the source buffer without discarding edits |
|
||||
|
||||
@@ -443,9 +447,9 @@ Comparison discovery builds the changed-path/status catalog first. File text, no
|
||||
|
||||
Conflicted jj revisions also discover files without reading every blob. Ordinary files and symbolic links retain their Git contents; selected conflicted files show jj's rendered conflict projection. Unchanged links and jj's internal merge-tree metadata do not appear as changes. Viewing a conflict does not resolve it or modify the revision.
|
||||
|
||||
**Working checkout After follows forward checkouts automatically**, checked asynchronously once per second, including inactive tabs. A descendant jj change or Git HEAD rebuilds the changed-file catalog and captures current working bytes plus eligible unsaved buffers, while keeping the original Before frozen. jj tracking uses change IDs, so snapshot/description rewrites of the same change do not advance the endpoint or prevent following its later descendants. Same, backward, and unrelated checkouts do not rebuild the catalog; live-buffer editing and external reload still work normally. Historical After never follows. Set `config.diff_follow_working_copy = false` to disable following.
|
||||
**Follow checkout After follows descendant checkouts automatically**, checked asynchronously once per second, including inactive tabs. A descendant jj change or Git HEAD rebuilds the changed-file catalog and captures current working bytes plus eligible unsaved buffers, while keeping the original Before frozen. jj tracking uses change IDs, so snapshot/description rewrites of the same change do not advance the endpoint or prevent following its later descendants. Same, backward, and unrelated checkouts do not rebuild the catalog; live-buffer editing and external reload still work normally. Historical After never follows. Set `config.diff_follow_working_copy = false` to disable following; the picker then calls this choice **Checkout snapshot**.
|
||||
|
||||
**Selected jj bookmarks follow their locally known targets automatically**, checked on the same one-second interval, including inactive tabs and with `config.diff_follow_working_copy = false`. Local bookmarks and known remote-tracking bookmarks retain their names; explicit revision selections remain pinned. A changed commit ID, including an amendment of the same change ID, rebuilds the comparison. Branch changes also recomputes the merge base. Unrelated endpoints stay frozen, except for the existing Working After forward-follow behavior. Deleted or conflicted bookmarks keep the last successful comparison visible with an error; a later successful check clears the error. These checks never fetch, contact remotes, or snapshot jj's working copy; privately loaded remote history and advertised remote selections remain frozen.
|
||||
**Selected jj bookmarks follow their locally known targets automatically**, checked on the same one-second interval, including inactive tabs and with `config.diff_follow_working_copy = false`. Local bookmarks and known remote-tracking bookmarks retain their names; explicit revision selections remain pinned. A changed commit ID, including an amendment of the same change ID, rebuilds the comparison. Branch changes also recomputes the merge base. Unrelated endpoints stay frozen, except for the existing Follow checkout After behavior. Deleted or conflicted bookmarks keep the last successful comparison visible with an error; a later successful check clears the error. These checks never fetch, contact remotes, or snapshot jj's working copy; privately loaded remote history and advertised remote selections remain frozen.
|
||||
|
||||
Deleted or conflicted bookmarks unrelated to the selected endpoints do not block opening or refreshing a comparison.
|
||||
|
||||
@@ -453,7 +457,7 @@ Deleted or conflicted bookmarks unrelated to the selected endpoints do not block
|
||||
|
||||
Refresh retains the selected path when still present, explorer query/view/visibility, logical text-side focus, and split/unified/orientation/wrap choices; moving a Working or bookmark endpoint clears review marks, while pinned checkout-only transitions retain them. Removed selections fall back to the first changed file. Bookmark replacements preserve/clamp cursor and scroll positions as replacement content loads. Failed refreshes keep the previous comparison visible. Superseded file loads and LSP navigation cannot apply to the new comparison; snapshots still displayed in other panes or tabs remain read-only.
|
||||
|
||||
The changed-file explorer is **docked on the right**. In the default split layout, modified files show Before on the left and After on the right. Added files show only After, using the full text workspace; deleted files show only Before. Rename-only files show one empty pane, with the old and new paths in the explorer; renames with text or final-newline changes retain both source sides. Before and unmatched pinned After snapshots are read-only. **Working checkout** or a checkout-matched pinned After binds eligible regular UTF-8 files to normal editor buffers, reusing already-open dirty buffers and their undo history. Editable After supports native edits, completion, undo/redo, and `:w`. Removed files, rename-only files, binary files, symlinks, and submodules remain read-only. Closing the diff keeps its buffers and unsaved edits.
|
||||
The changed-file explorer is **docked on the right**. In the default split layout, modified files show Before on the left and After on the right. Added files show only After, using the full text workspace; deleted files show only Before. Rename-only files show one empty pane, with the old and new paths in the explorer; renames with text or final-newline changes retain both source sides. Before and unmatched pinned After snapshots are read-only. A **Follow checkout / Checkout snapshot After** or a checkout-matched pinned After binds eligible regular UTF-8 files to normal editor buffers, reusing already-open dirty buffers and their undo history. Editable After supports native edits, completion, undo/redo, and `:w`. Removed files, rename-only files, binary files, symlinks, and submodules remain read-only. Closing the diff keeps its buffers and unsaved edits.
|
||||
|
||||
Comparisons start in **split, vertical (left/right)** view by default. In Normal mode, **Space v** cycles split/unified; **Space s** switches a split between vertical (left/right) and horizontal (above/below, Before above After). Canonical commands are `:diff.view.toggle` and `:diff.orientation.toggle`; both are available in the palette and as remappable `config.core.diff.view.toggle` / `config.core.diff.orientation.toggle` actions. Configure new-comparison defaults with `config.diff_view_mode = "split"` or `"unified"` and `config.diff_split_orientation = "vertical"` or `"horizontal"`. Current choices survive file and tab switches; closing and reopening uses the configured defaults. Orientation stays unchanged while unified is active.
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ Vamp.configure do |config|
|
||||
config.leader = "space"
|
||||
config.clipboard_mode = "system" # "separate" keeps ordinary y/d/c/p/P internal
|
||||
config.git_blame = true # false disables current-line inline blame
|
||||
config.cursor = {} # mode colors enabled; block cursor in every mode
|
||||
# config.cursor = { mode_colors: false, insert: :bar, visual: :underline }
|
||||
config.scroll_distance = 0 # nonnegative edge distance, or nil to center
|
||||
config.scroll_step_lines = nil # Ctrl+u/d: half viewport, or a positive screen-row count
|
||||
config.highlight_trailing_whitespace = false # true marks line-end whitespace in red
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
use crate::editor::Mode;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize)]
|
||||
#[serde(default, deny_unknown_fields)]
|
||||
pub(crate) struct CursorConfig {
|
||||
pub(crate) mode_colors: bool,
|
||||
pub(crate) normal: CursorShape,
|
||||
pub(crate) insert: CursorShape,
|
||||
pub(crate) command: CursorShape,
|
||||
pub(crate) search: CursorShape,
|
||||
pub(crate) visual: CursorShape,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub(crate) enum CursorShape {
|
||||
Block,
|
||||
Bar,
|
||||
Underline,
|
||||
}
|
||||
|
||||
impl Default for CursorConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
mode_colors: true,
|
||||
normal: CursorShape::Block,
|
||||
insert: CursorShape::Block,
|
||||
command: CursorShape::Block,
|
||||
search: CursorShape::Block,
|
||||
visual: CursorShape::Block,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CursorConfig {
|
||||
pub(crate) fn shape(self, mode: Mode) -> CursorShape {
|
||||
match mode {
|
||||
Mode::Normal => self.normal,
|
||||
Mode::Insert => self.insert,
|
||||
Mode::Command => self.command,
|
||||
Mode::Search => self.search,
|
||||
Mode::Visual => self.visual,
|
||||
}
|
||||
}
|
||||
}
|
||||
+248
-3
@@ -96,10 +96,22 @@ pub struct Revision {
|
||||
pub description: String,
|
||||
pub category: Category,
|
||||
}
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq)]
|
||||
pub struct RevisionGraph {
|
||||
pub change_id: String,
|
||||
pub description: String,
|
||||
pub parents: Vec<String>,
|
||||
pub author: String,
|
||||
pub timestamp: String,
|
||||
pub bookmarks: String,
|
||||
pub current: bool,
|
||||
pub immutable: bool,
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub struct Catalog {
|
||||
pub kind: RepoKind,
|
||||
pub entries: Vec<Revision>,
|
||||
pub graph: BTreeMap<String, RevisionGraph>,
|
||||
pub notice: Option<String>,
|
||||
}
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||
@@ -761,6 +773,7 @@ pub struct DiffState {
|
||||
pub word_wrap: bool,
|
||||
pub view_mode: ViewMode,
|
||||
pub comparison_mode: ComparisonMode,
|
||||
pub follow_working_copy: bool,
|
||||
pub split_axis: crate::panes::SplitAxis,
|
||||
pub writable_side: Option<Focus>,
|
||||
pub side_labels: [&'static str; 2],
|
||||
@@ -808,6 +821,8 @@ pub struct DiffState {
|
||||
pending: Option<Operation>,
|
||||
request_kind: Option<RequestKind>,
|
||||
visible: Vec<usize>,
|
||||
picker_graph: BTreeMap<String, [String; 2]>,
|
||||
bookmark_graph: BTreeMap<String, BTreeMap<Option<String>, String>>,
|
||||
search_fields: Vec<[String; 3]>,
|
||||
search_matches: Vec<([usize; 7], usize)>,
|
||||
max_before: usize,
|
||||
@@ -831,6 +846,7 @@ impl DiffState {
|
||||
word_wrap: false,
|
||||
view_mode: ViewMode::Split,
|
||||
comparison_mode: ComparisonMode::default(),
|
||||
follow_working_copy: false,
|
||||
split_axis: crate::panes::SplitAxis::Vertical,
|
||||
writable_side: Some(Focus::After),
|
||||
side_labels: ["Before", "After"],
|
||||
@@ -875,6 +891,8 @@ impl DiffState {
|
||||
pending: Some(Operation::Discover),
|
||||
request_kind: Some(RequestKind::Catalog),
|
||||
visible: Vec::new(),
|
||||
picker_graph: BTreeMap::new(),
|
||||
bookmark_graph: BTreeMap::new(),
|
||||
search_fields: Vec::new(),
|
||||
search_matches: Vec::new(),
|
||||
max_before: 0,
|
||||
@@ -1178,6 +1196,7 @@ impl DiffState {
|
||||
kind: page.kind,
|
||||
entries: Vec::new(),
|
||||
notice: Some(format!("Pull requests from {}", page.remote)),
|
||||
graph: BTreeMap::new(),
|
||||
});
|
||||
for (revision, metadata) in page.entries {
|
||||
let RevisionTarget::PullRequest { number, .. } = &revision.target else {
|
||||
@@ -1436,6 +1455,20 @@ impl DiffState {
|
||||
true
|
||||
}
|
||||
fn prepare_search(&mut self) {
|
||||
self.bookmark_graph.clear();
|
||||
if let Some(catalog) = &self.catalog {
|
||||
for entry in &catalog.entries {
|
||||
if let RevisionTarget::Bookmark { name, remote } = &entry.target
|
||||
&& let Some(id) = entry.description.split_whitespace().nth(1)
|
||||
&& catalog.graph.contains_key(id)
|
||||
{
|
||||
self.bookmark_graph
|
||||
.entry(name.clone())
|
||||
.or_default()
|
||||
.insert(remote.clone(), id.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
self.search_fields = self
|
||||
.catalog
|
||||
.as_ref()
|
||||
@@ -1552,6 +1585,186 @@ impl DiffState {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn graph_revision(&self, revision: &Revision) -> Option<(&str, &RevisionGraph)> {
|
||||
let catalog = self.catalog.as_ref()?;
|
||||
let id = match &revision.target {
|
||||
RevisionTarget::Commit(id) => id.as_str(),
|
||||
RevisionTarget::Bookmark { name, remote } => {
|
||||
self.bookmark_graph.get(name)?.get(remote)?
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
catalog
|
||||
.graph
|
||||
.get_key_value(id)
|
||||
.map(|(id, graph)| (id.as_str(), graph))
|
||||
}
|
||||
|
||||
pub fn picker_graph(&self) -> &BTreeMap<String, [String; 2]> {
|
||||
&self.picker_graph
|
||||
}
|
||||
|
||||
fn rebuild_picker_graph(&mut self) {
|
||||
let mut result = BTreeMap::new();
|
||||
let Some(catalog) = &self.catalog else {
|
||||
self.picker_graph = result;
|
||||
return;
|
||||
};
|
||||
let visible: Vec<_> = self
|
||||
.entries()
|
||||
.filter_map(|entry| self.graph_revision(entry))
|
||||
.map(|(id, _)| id)
|
||||
.collect();
|
||||
let selected: BTreeSet<_> = visible.iter().copied().collect();
|
||||
if selected.is_empty() {
|
||||
self.picker_graph = result;
|
||||
return;
|
||||
}
|
||||
let mut nearest: BTreeMap<&str, BTreeMap<&str, bool>> = BTreeMap::new();
|
||||
for entry in catalog
|
||||
.entries
|
||||
.iter()
|
||||
.rev()
|
||||
.filter(|entry| entry.category == Category::Revisions)
|
||||
{
|
||||
let Some((id, graph)) = self.graph_revision(entry) else {
|
||||
continue;
|
||||
};
|
||||
if nearest.contains_key(id) {
|
||||
continue;
|
||||
}
|
||||
let mut ancestors = BTreeMap::new();
|
||||
if selected.contains(id) {
|
||||
ancestors.insert(id, false);
|
||||
} else {
|
||||
for parent in &graph.parents {
|
||||
if let Some(parents) = nearest.get(parent.as_str()) {
|
||||
ancestors.extend(parents.keys().map(|&parent| (parent, true)));
|
||||
}
|
||||
}
|
||||
}
|
||||
nearest.insert(id, ancestors);
|
||||
}
|
||||
let mut lanes: Vec<(&str, bool)> = Vec::new();
|
||||
for id in visible {
|
||||
if result.contains_key(id) {
|
||||
continue;
|
||||
}
|
||||
let graph = &catalog.graph[id];
|
||||
let mut parents = BTreeMap::new();
|
||||
for parent in &graph.parents {
|
||||
if let Some(ancestors) = nearest.get(parent.as_str()) {
|
||||
for (&ancestor, &skipped) in ancestors {
|
||||
parents
|
||||
.entry(ancestor)
|
||||
.and_modify(|old| *old |= skipped)
|
||||
.or_insert(skipped);
|
||||
}
|
||||
}
|
||||
}
|
||||
let column = lanes
|
||||
.iter()
|
||||
.position(|&(lane, _)| lane == id)
|
||||
.unwrap_or_else(|| {
|
||||
lanes.push((id, false));
|
||||
lanes.len() - 1
|
||||
});
|
||||
let mut next = lanes.clone();
|
||||
next.remove(column);
|
||||
for (offset, (&parent, &skipped)) in parents.iter().enumerate() {
|
||||
if let Some(lane) = next.iter_mut().find(|(lane, _)| *lane == parent) {
|
||||
lane.1 |= skipped;
|
||||
} else {
|
||||
next.insert((column + offset).min(next.len()), (parent, skipped));
|
||||
}
|
||||
}
|
||||
let width = lanes.len().max(next.len()) * 2;
|
||||
let mut first = vec![' '; width];
|
||||
for (column, &(_, skipped)) in lanes.iter().enumerate() {
|
||||
first[column * 2] = if skipped { '~' } else { '│' };
|
||||
}
|
||||
first[column * 2] = if graph.current {
|
||||
'@'
|
||||
} else if graph.immutable {
|
||||
'◆'
|
||||
} else {
|
||||
'○'
|
||||
};
|
||||
// Low bits connect up/down/left/right; high bits distinguish joins from crossings.
|
||||
let mut links = vec![0u8; width];
|
||||
for (from, &(lane, _)) in lanes.iter().enumerate() {
|
||||
for (to, &(target, _)) in next.iter().enumerate() {
|
||||
if (lane == id && !parents.contains_key(target))
|
||||
|| (lane != id && lane != target)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let (from, to) = (from * 2, to * 2);
|
||||
if links[from] & 1 != 0 {
|
||||
links[from] |= 16;
|
||||
}
|
||||
if links[to] & 2 != 0 {
|
||||
links[to] |= 32;
|
||||
}
|
||||
if from == to {
|
||||
links[from] |= 3;
|
||||
} else {
|
||||
links[from] |= 1 | if from < to { 8 } else { 4 };
|
||||
links[to] |= 2 | if from < to { 4 } else { 8 };
|
||||
for cell in &mut links[from.min(to) + 1..from.max(to)] {
|
||||
*cell |= 12;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut second: Vec<_> = links
|
||||
.into_iter()
|
||||
.map(|link| match link & 15 {
|
||||
3 => '│',
|
||||
5 => '┘',
|
||||
6 => '┐',
|
||||
7 => '┤',
|
||||
9 => '└',
|
||||
10 => '┌',
|
||||
11 => '├',
|
||||
12 => '─',
|
||||
13 => '┴',
|
||||
14 => '┬',
|
||||
15 => {
|
||||
if link & 48 == 0 {
|
||||
'╪'
|
||||
} else {
|
||||
'┼'
|
||||
}
|
||||
}
|
||||
_ => ' ',
|
||||
})
|
||||
.collect();
|
||||
for (column, &(_, skipped)) in next.iter().enumerate() {
|
||||
if skipped {
|
||||
second[column * 2] = '~';
|
||||
}
|
||||
}
|
||||
if !graph.parents.is_empty() && parents.is_empty() {
|
||||
second[column * 2] = '~';
|
||||
}
|
||||
if !parents.is_empty()
|
||||
&& graph
|
||||
.parents
|
||||
.iter()
|
||||
.any(|parent| nearest.get(parent.as_str()).is_none_or(BTreeMap::is_empty))
|
||||
{
|
||||
second.extend(['~', ' ']);
|
||||
}
|
||||
result.insert(
|
||||
id.to_owned(),
|
||||
[first.into_iter().collect(), second.into_iter().collect()],
|
||||
);
|
||||
lanes = next;
|
||||
}
|
||||
self.picker_graph = result;
|
||||
}
|
||||
|
||||
fn refilter(&mut self) {
|
||||
self.visible.clear();
|
||||
self.search_matches.clear();
|
||||
@@ -1619,7 +1832,7 @@ impl DiffState {
|
||||
self.search_matches.push((score, index));
|
||||
}
|
||||
}
|
||||
if self.pull_request_remote.is_none() {
|
||||
if self.pull_request_remote.is_none() && catalog.kind == RepoKind::Git {
|
||||
self.search_matches
|
||||
.sort_unstable_by_key(|&(score, index)| (score, index));
|
||||
}
|
||||
@@ -1663,8 +1876,34 @@ impl DiffState {
|
||||
b_number.cmp(&a_number)
|
||||
});
|
||||
}
|
||||
if self.pull_request_remote.is_none() {
|
||||
if let Some(before) = &self.before {
|
||||
let same = |entry: &Revision| {
|
||||
entry.target == before.target
|
||||
|| self
|
||||
.graph_revision(entry)
|
||||
.zip(self.graph_revision(before))
|
||||
.is_some_and(|(a, b)| a.0 == b.0)
|
||||
};
|
||||
if !self
|
||||
.visible
|
||||
.iter()
|
||||
.any(|&index| same(&catalog.entries[index]))
|
||||
&& let Some(index) = catalog
|
||||
.entries
|
||||
.iter()
|
||||
.position(|entry| entry.target == before.target)
|
||||
{
|
||||
self.visible.push(index);
|
||||
}
|
||||
}
|
||||
if catalog.kind == RepoKind::Jujutsu {
|
||||
self.visible.sort_unstable();
|
||||
}
|
||||
}
|
||||
}
|
||||
self.selected = 0;
|
||||
self.rebuild_picker_graph();
|
||||
}
|
||||
|
||||
fn select_target(&mut self, target: &RevisionTarget) {
|
||||
@@ -1838,7 +2077,7 @@ impl DiffState {
|
||||
|
||||
fn choose(&mut self) {
|
||||
let revision = self.entries().nth(self.selected).cloned();
|
||||
let Some(revision) = revision else {
|
||||
let Some(mut revision) = revision else {
|
||||
self.retry_pull_requests();
|
||||
// Listing can be retried without closing the modal.
|
||||
if self.catalog.is_none()
|
||||
@@ -1861,6 +2100,12 @@ impl DiffState {
|
||||
}
|
||||
if revision.target == RevisionTarget::Working {
|
||||
self.comparison_mode = ComparisonMode::Snapshots;
|
||||
revision.label = if self.phase == Phase::After && self.follow_working_copy {
|
||||
"Follow checkout"
|
||||
} else {
|
||||
"Checkout snapshot"
|
||||
}
|
||||
.into();
|
||||
}
|
||||
if let RevisionTarget::FetchRemote(remote) = &revision.target {
|
||||
self.queue(Operation::FetchRemote(remote.clone()));
|
||||
@@ -1891,7 +2136,7 @@ impl DiffState {
|
||||
return Err("Select a pull request before changing comparison mode");
|
||||
}
|
||||
if self.working_selected() {
|
||||
return Err("Working checkout requires Snapshots");
|
||||
return Err("Checkout selections require Snapshots");
|
||||
}
|
||||
self.comparison_mode = match self.comparison_mode {
|
||||
ComparisonMode::BranchChanges => ComparisonMode::Snapshots,
|
||||
|
||||
@@ -2228,6 +2228,7 @@ pub struct Editor {
|
||||
bottom_bar: ChromeLine,
|
||||
popup: PopupConfig,
|
||||
labels: BTreeMap<String, String>,
|
||||
pub(crate) cursor_config: crate::cursor::CursorConfig,
|
||||
scroll_distance: Option<usize>,
|
||||
scroll_step_lines: Option<NonZeroUsize>,
|
||||
highlight_trailing_whitespace: bool,
|
||||
@@ -2281,6 +2282,7 @@ pub struct Editor {
|
||||
diff_return_buffer: Option<usize>,
|
||||
diff_context_options: (usize, usize),
|
||||
diff_display_options: (ViewMode, SplitAxis),
|
||||
pub(crate) diff_follow_working_copy: bool,
|
||||
pub(crate) pull_request_review_requested_symbol: String,
|
||||
pub(crate) pull_request_approved_symbol: String,
|
||||
pub(crate) pull_request_preferences: crate::pull_requests::Preferences,
|
||||
@@ -2353,6 +2355,7 @@ impl Editor {
|
||||
bottom_bar: ChromeLine::bottom(),
|
||||
popup: PopupConfig::default(),
|
||||
labels: BTreeMap::new(),
|
||||
cursor_config: crate::cursor::CursorConfig::default(),
|
||||
scroll_distance: Some(0),
|
||||
scroll_step_lines: None,
|
||||
highlight_trailing_whitespace: false,
|
||||
@@ -2427,6 +2430,7 @@ impl Editor {
|
||||
diff_return_buffer: None,
|
||||
diff_context_options: (10, 15),
|
||||
diff_display_options: (ViewMode::Split, SplitAxis::Vertical),
|
||||
diff_follow_working_copy: false,
|
||||
pull_request_review_requested_symbol: "🙏".into(),
|
||||
pull_request_approved_symbol: "👍".into(),
|
||||
pull_request_preferences: Default::default(),
|
||||
@@ -4762,6 +4766,7 @@ impl Editor {
|
||||
diff.word_wrap = self.active.view.word_wrap;
|
||||
diff.view_mode = self.diff_display_options.0;
|
||||
diff.split_axis = self.diff_display_options.1;
|
||||
diff.follow_working_copy = self.diff_follow_working_copy;
|
||||
diff.set_context_options(self.diff_context_options.0, self.diff_context_options.1);
|
||||
self.diff = Some(diff);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ mod battery;
|
||||
mod blame;
|
||||
pub mod chrome;
|
||||
pub mod clipboard;
|
||||
pub(crate) mod cursor;
|
||||
pub mod diff;
|
||||
pub mod editor;
|
||||
pub mod files;
|
||||
|
||||
+2
-2
@@ -85,7 +85,7 @@ Restart: :restart closes clean buffers; unsaved buffers remain open and block re
|
||||
Tabs: :tab.new, :tab.previous, :tab.next, :tab.close, :tab.force_close
|
||||
Tabs retain pane layouts and independent views; close protects exclusively displayed unsaved edits
|
||||
Markdown links: :follow_link (primary caret; local files only)
|
||||
Diff: :diff (Normal); choose Before then After; Working checkout After edits live unsaved buffers
|
||||
Diff: :diff (Normal); floating jj log graph; choose Before then After; selected Before is marked inline
|
||||
Before and historical/remote After stay read-only; Tab/Shift+Tab categories/Normal focus
|
||||
All text panes use native motions, selections and copy; read-only panes reject edits/saves
|
||||
Switching Before/After preserves the aligned cursor row and display column
|
||||
@@ -93,7 +93,7 @@ Diff: :diff (Normal); choose Before then After; Working checkout After edits liv
|
||||
Normal [/] explicitly expands context; Insert brackets remain literal text
|
||||
Normal Space v cycles split/unified; Space s flips left/right vs above/below split
|
||||
Defaults: config.diff_view_mode = \"split\"; config.diff_split_orientation = \"vertical\"
|
||||
Working After follows descendant checkouts; config.diff_follow_working_copy = false disables it
|
||||
Follow checkout After edits live buffers and follows descendants; config.diff_follow_working_copy = false disables following
|
||||
Esc closes Before/After selectors; :diff.close exits an opened comparison explicitly
|
||||
Remote refs/history load into temporary comparison repos without changing active refs/checkout
|
||||
Changed files: normal picker/explorer bindings, Ctrl+w close; A/M/D/R status and rename paths
|
||||
|
||||
+108
-12
@@ -1,7 +1,8 @@
|
||||
//! Read-only active-repository discovery and isolated revision comparison.
|
||||
use crate::diff::{
|
||||
BlameRevision, Catalog, Category, ChangedFile, Comparison, ComparisonMode, FileStatus,
|
||||
PullRequestMetadata, PullRequestPage, RepoKind, Revision, RevisionTarget, line_hunks,
|
||||
PullRequestMetadata, PullRequestPage, RepoKind, Revision, RevisionGraph, RevisionTarget,
|
||||
line_hunks,
|
||||
};
|
||||
use std::{
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
@@ -1180,10 +1181,25 @@ impl Repository {
|
||||
root: &Path,
|
||||
store: &Path,
|
||||
entries: &mut Vec<Revision>,
|
||||
graph: &mut BTreeMap<String, RevisionGraph>,
|
||||
notices: &mut Vec<String>,
|
||||
) -> Result<(), String> {
|
||||
if self.kind == RepoKind::Jujutsu {
|
||||
let template = r#""[" ++ json(commit_id) ++ "," ++ json(change_id) ++ "," ++ json(description) ++ "," ++ json(local_bookmarks.map(|b| b.name())) ++ "," ++ json(remote_bookmarks.map(|b| b.name())) ++ "," ++ json(remote_bookmarks.map(|b| b.remote())) ++ "]\n""#;
|
||||
#[derive(serde::Deserialize)]
|
||||
struct JjRevision(
|
||||
String,
|
||||
String,
|
||||
String,
|
||||
Vec<String>,
|
||||
Vec<String>,
|
||||
Vec<String>,
|
||||
Vec<String>,
|
||||
String,
|
||||
String,
|
||||
bool,
|
||||
bool,
|
||||
);
|
||||
let template = r#""[" ++ json(commit_id) ++ "," ++ json(change_id) ++ "," ++ json(description) ++ "," ++ json(local_bookmarks.map(|b| b.name())) ++ "," ++ json(remote_bookmarks.map(|b| b.name())) ++ "," ++ json(remote_bookmarks.map(|b| b.remote())) ++ "," ++ json(parents.map(|p| p.commit_id())) ++ "," ++ json(author.name()) ++ "," ++ json(author.timestamp().format("%Y-%m-%d %H:%M")) ++ "," ++ json(current_working_copy) ++ "," ++ json(immutable) ++ "]\n""#;
|
||||
let revset = if root == self.root {
|
||||
"all()"
|
||||
} else {
|
||||
@@ -1192,15 +1208,40 @@ impl Repository {
|
||||
let output =
|
||||
text(self.jj(root, &["log", "--no-graph", "-r", revset, "-T", template])?)?;
|
||||
for line in output.lines() {
|
||||
let (id, change, description, bookmarks, remote_names, remotes): (
|
||||
String,
|
||||
String,
|
||||
String,
|
||||
Vec<String>,
|
||||
Vec<String>,
|
||||
Vec<String>,
|
||||
let JjRevision(
|
||||
id,
|
||||
change,
|
||||
description,
|
||||
bookmarks,
|
||||
remote_names,
|
||||
remotes,
|
||||
parents,
|
||||
author,
|
||||
timestamp,
|
||||
current,
|
||||
immutable,
|
||||
) = serde_json::from_str(line)
|
||||
.map_err(|e| format!("Cannot decode Jujutsu revision: {e}"))?;
|
||||
graph.entry(id.clone()).or_insert_with(|| RevisionGraph {
|
||||
change_id: change.clone(),
|
||||
description: description.trim_end_matches('\n').into(),
|
||||
parents,
|
||||
author,
|
||||
timestamp,
|
||||
bookmarks: bookmarks
|
||||
.iter()
|
||||
.cloned()
|
||||
.chain(
|
||||
remote_names
|
||||
.iter()
|
||||
.zip(&remotes)
|
||||
.map(|(name, remote)| format!("{name}@{remote}")),
|
||||
)
|
||||
.collect::<Vec<_>>()
|
||||
.join(" "),
|
||||
current: current && root == self.root,
|
||||
immutable,
|
||||
});
|
||||
let target = RevisionTarget::Commit(id.clone());
|
||||
entries.push(Revision {
|
||||
target: target.clone(),
|
||||
@@ -1370,15 +1411,69 @@ impl Repository {
|
||||
};
|
||||
let mut entries = vec![Revision {
|
||||
target: RevisionTarget::Working,
|
||||
label: "Working checkout".into(),
|
||||
label: "Checkout snapshot".into(),
|
||||
description:
|
||||
"On-disk tracked and eligible untracked files; unsaved buffers are excluded".into(),
|
||||
category,
|
||||
}];
|
||||
let mut notices = vec![];
|
||||
self.revisions(&self.root, &self.store, &mut entries, &mut notices)?;
|
||||
let mut graph = BTreeMap::new();
|
||||
self.revisions(
|
||||
&self.root,
|
||||
&self.store,
|
||||
&mut entries,
|
||||
&mut graph,
|
||||
&mut notices,
|
||||
)?;
|
||||
if let Some((root, store)) = &self.private {
|
||||
self.revisions(root, store, &mut entries, &mut notices)?;
|
||||
self.revisions(root, store, &mut entries, &mut graph, &mut notices)?;
|
||||
}
|
||||
if self.kind == RepoKind::Jujutsu && self.private.is_some() {
|
||||
let order: BTreeMap<_, _> = entries
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(index, entry)| match &entry.target {
|
||||
RevisionTarget::Commit(id) => Some((id.as_str(), index)),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
let mut children: BTreeMap<_, usize> =
|
||||
graph.keys().map(|id| (id.as_str(), 0)).collect();
|
||||
for node in graph.values() {
|
||||
for parent in &node.parents {
|
||||
if let Some(count) = children.get_mut(parent.as_str()) {
|
||||
*count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut ready: BTreeSet<_> = children
|
||||
.iter()
|
||||
.filter(|(_, count)| **count == 0)
|
||||
.map(|(&id, _)| (order[id], id))
|
||||
.collect();
|
||||
let mut ranks = BTreeMap::new();
|
||||
while let Some((_, id)) = ready.pop_first() {
|
||||
ranks.insert(id, ranks.len() + 1);
|
||||
for parent in &graph[id].parents {
|
||||
if let Some(count) = children.get_mut(parent.as_str()) {
|
||||
*count -= 1;
|
||||
if *count == 0 {
|
||||
ready.insert((order[parent.as_str()], parent.as_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
entries.sort_by_key(|entry| match &entry.target {
|
||||
RevisionTarget::Working => 0,
|
||||
RevisionTarget::Commit(id) => ranks.get(id.as_str()).copied().unwrap_or(usize::MAX),
|
||||
RevisionTarget::Bookmark { .. } => entry
|
||||
.description
|
||||
.split_whitespace()
|
||||
.nth(1)
|
||||
.and_then(|id| ranks.get(id).copied())
|
||||
.unwrap_or(usize::MAX),
|
||||
_ => usize::MAX,
|
||||
});
|
||||
}
|
||||
for remote in &self.remotes {
|
||||
for &view in self.kind.categories() {
|
||||
@@ -1439,6 +1534,7 @@ impl Repository {
|
||||
Ok(Catalog {
|
||||
kind: self.kind,
|
||||
entries,
|
||||
graph,
|
||||
notice: if notices.is_empty() {
|
||||
None
|
||||
} else {
|
||||
|
||||
+5
-1
@@ -167,7 +167,11 @@ pub fn run(request: &Request, config: Option<&Path>) -> Result<(), String> {
|
||||
vec![review]
|
||||
} else {
|
||||
match store {
|
||||
Some(store) => store.list(&root)?,
|
||||
Some(store) => store
|
||||
.list(&root)?
|
||||
.into_iter()
|
||||
.filter(|review| !review.comments.is_empty())
|
||||
.collect(),
|
||||
None => Vec::new(),
|
||||
}
|
||||
};
|
||||
|
||||
@@ -43,6 +43,7 @@ pub struct Config {
|
||||
pub clipboard_mode: String,
|
||||
pub git_blame: bool,
|
||||
pub git_gutter: crate::gutter::GutterStyle,
|
||||
pub(crate) cursor: crate::cursor::CursorConfig,
|
||||
pub top_bar: ChromeLine,
|
||||
pub bottom_bar: ChromeLine,
|
||||
pub popup: PopupConfig,
|
||||
@@ -101,6 +102,7 @@ impl Default for Config {
|
||||
clipboard_mode: "system".into(),
|
||||
git_blame: true,
|
||||
git_gutter: crate::gutter::GutterStyle::default(),
|
||||
cursor: crate::cursor::CursorConfig::default(),
|
||||
top_bar: ChromeLine::top(),
|
||||
bottom_bar: ChromeLine::bottom(),
|
||||
popup: PopupConfig::default(),
|
||||
@@ -146,6 +148,7 @@ pub fn load_config(path: &Path) -> Result<Config, String> {
|
||||
clipboard_mode,
|
||||
git_blame,
|
||||
git_gutter,
|
||||
cursor,
|
||||
top_bar,
|
||||
bottom_bar,
|
||||
popup,
|
||||
@@ -192,6 +195,7 @@ pub fn load_config(path: &Path) -> Result<Config, String> {
|
||||
config.clipboard_mode = clipboard_mode;
|
||||
config.git_blame = git_blame;
|
||||
config.git_gutter = git_gutter;
|
||||
config.cursor = cursor;
|
||||
config.top_bar = top_bar;
|
||||
config.bottom_bar = bottom_bar;
|
||||
config.popup = popup;
|
||||
@@ -558,6 +562,8 @@ struct ConfigFrame {
|
||||
clipboard_mode: String,
|
||||
git_blame: bool,
|
||||
git_gutter: crate::gutter::GutterStyle,
|
||||
#[serde(default)]
|
||||
cursor: crate::cursor::CursorConfig,
|
||||
#[serde(deserialize_with = "crate::chrome::top")]
|
||||
top_bar: ChromeLine,
|
||||
#[serde(deserialize_with = "crate::chrome::bottom")]
|
||||
|
||||
@@ -142,6 +142,7 @@ module Vamp
|
||||
@clipboard_mode = "system"
|
||||
@git_blame = true
|
||||
@git_gutter = "bar"
|
||||
@cursor = {}
|
||||
@bar = BarConfig.new
|
||||
@popup = PopupConfig.new
|
||||
@labels = {}
|
||||
@@ -231,6 +232,32 @@ module Vamp
|
||||
@git_gutter = style
|
||||
end
|
||||
|
||||
# @param options [Hash{String, Symbol => Boolean, String, Symbol}] mode_colors defaults to true; mode shapes default to block
|
||||
# @return [Hash{String => Boolean, String}]
|
||||
def cursor=(options)
|
||||
raise TypeError, "cursor options must be a Hash" unless options.is_a?(Hash)
|
||||
|
||||
@cursor = options.each_with_object({}) do |(option, value), result|
|
||||
option = option.to_s if option.is_a?(Symbol)
|
||||
option = Vamp.string!(option, "cursor option")
|
||||
raise ArgumentError, "duplicate cursor option: #{option}" if result.key?(option)
|
||||
|
||||
case option
|
||||
when "mode_colors"
|
||||
raise TypeError, "cursor mode_colors must be true or false" unless [true, false].include?(value)
|
||||
when "normal", "insert", "command", "search", "visual"
|
||||
value = value.to_s if value.is_a?(Symbol)
|
||||
value = Vamp.string!(value, "cursor shape")
|
||||
unless %w[block bar underline].include?(value)
|
||||
raise ArgumentError, "cursor shape must be block, bar, or underline"
|
||||
end
|
||||
else
|
||||
raise ArgumentError, "unknown cursor option: #{option}"
|
||||
end
|
||||
result[option] = value
|
||||
end
|
||||
end
|
||||
|
||||
# @param values [Hash{String, Symbol => String}]
|
||||
# @return [Hash]
|
||||
def labels=(values)
|
||||
@@ -441,6 +468,7 @@ module Vamp
|
||||
"file_explorer_view" => @file_explorer_view, "clipboard_mode" => @clipboard_mode,
|
||||
"git_blame" => @git_blame,
|
||||
"git_gutter" => @git_gutter,
|
||||
"cursor" => @cursor,
|
||||
"scroll_distance" => @scroll_distance,
|
||||
"scroll_step_lines" => @scroll_step_lines,
|
||||
"highlight_trailing_whitespace" => @highlight_trailing_whitespace,
|
||||
|
||||
@@ -516,6 +516,7 @@ impl EditorSession {
|
||||
}),
|
||||
None => Config::default(),
|
||||
};
|
||||
editor.cursor_config = config.cursor;
|
||||
let (pull_request_preferences_store, mut preferences, notice) = match preferences_path {
|
||||
Some(path) => crate::pull_request_preferences::Store::load(path),
|
||||
None => (
|
||||
@@ -579,6 +580,7 @@ impl EditorSession {
|
||||
editor.set_tab_spaces(config.tab_spaces, config.language_tab_spaces);
|
||||
editor.set_diff_context_options(config.diff_context_lines, config.diff_expand_lines);
|
||||
editor.set_diff_display_options(config.diff_view_mode, config.diff_split_orientation);
|
||||
editor.diff_follow_working_copy = config.diff_follow_working_copy;
|
||||
editor.pull_request_review_requested_symbol = config.pull_request_review_requested_symbol;
|
||||
editor.pull_request_approved_symbol = config.pull_request_approved_symbol;
|
||||
editor.resolve_history_layout = config.resolve_history_layout;
|
||||
|
||||
+280
-43
@@ -28,8 +28,9 @@ use crossterm::{
|
||||
};
|
||||
use ratatui::{
|
||||
Frame, Terminal,
|
||||
backend::CrosstermBackend,
|
||||
layout::{Constraint, Layout, Position, Rect},
|
||||
backend::{Backend, ClearType, CrosstermBackend, WindowSize},
|
||||
buffer::Cell,
|
||||
layout::{Constraint, Layout, Position, Rect, Size},
|
||||
style::{Color, Modifier, Style},
|
||||
text::{Line, Span},
|
||||
widgets::{Block, Borders, Clear, Paragraph, Wrap},
|
||||
@@ -837,6 +838,7 @@ impl BufferViewports {
|
||||
.filter_map(|(_, pane)| pane.panels.diff.as_ref()),
|
||||
)
|
||||
.any(|geometry| geometry.viewport.is_some());
|
||||
paint_cursor(frame, editor, self.panels.cursor);
|
||||
}
|
||||
|
||||
fn draw_resolver_history(
|
||||
@@ -1290,29 +1292,149 @@ fn wheel_kind(mouse: &MouseEvent) -> Option<MouseEventKind> {
|
||||
})
|
||||
}
|
||||
|
||||
fn mode_accent(mode: Mode) -> Color {
|
||||
match mode {
|
||||
Mode::Normal => Color::Cyan,
|
||||
Mode::Insert => Color::Green,
|
||||
Mode::Visual => Color::Magenta,
|
||||
Mode::Command => Color::Yellow,
|
||||
Mode::Search => Color::Blue,
|
||||
}
|
||||
}
|
||||
|
||||
fn mode_style(mode: Mode) -> Style {
|
||||
Style::default()
|
||||
.fg(if mode == Mode::Search {
|
||||
Color::White
|
||||
} else {
|
||||
Color::Black
|
||||
})
|
||||
.bg(mode_accent(mode))
|
||||
}
|
||||
|
||||
fn paint_cursor(frame: &mut Frame, editor: &Editor, position: Option<Position>) {
|
||||
use crate::cursor::CursorShape;
|
||||
let Some(position) = position.filter(|&position| frame.area().contains(position)) else {
|
||||
return;
|
||||
};
|
||||
let shape = editor.cursor_config.shape(editor.mode());
|
||||
let colored = editor.cursor_config.mode_colors;
|
||||
let color = if colored {
|
||||
mode_accent(editor.mode())
|
||||
} else {
|
||||
Color::Reset
|
||||
};
|
||||
let visible = Modifier::HIDDEN | Modifier::DIM | Modifier::REVERSED;
|
||||
let style = match shape {
|
||||
CursorShape::Block if colored => mode_style(editor.mode()).remove_modifier(visible),
|
||||
CursorShape::Block => Style::default()
|
||||
.remove_modifier(Modifier::HIDDEN | Modifier::DIM)
|
||||
.add_modifier(Modifier::REVERSED),
|
||||
CursorShape::Underline => Style::default()
|
||||
.fg(color)
|
||||
.underline_color(color)
|
||||
.remove_modifier(visible)
|
||||
.add_modifier(Modifier::UNDERLINED),
|
||||
CursorShape::Bar => Style::default().fg(color).remove_modifier(visible),
|
||||
};
|
||||
let buffer = frame.buffer_mut();
|
||||
let width = buffer[position]
|
||||
.symbol()
|
||||
.width()
|
||||
.max(1)
|
||||
.min(usize::from(buffer.area.right() - position.x));
|
||||
if shape == CursorShape::Bar {
|
||||
// A cell-rendered bar overlays the hovered glyph; source text stays intact.
|
||||
buffer[position].set_symbol("▏");
|
||||
}
|
||||
for offset in 0..width {
|
||||
buffer[(position.x + offset as u16, position.y)].set_style(style);
|
||||
}
|
||||
}
|
||||
|
||||
// Keep Ratatui's logical cursor position (including IME placement), but never
|
||||
// show a hardware cursor on top of the cell-rendered caret.
|
||||
struct SoftwareCursorBackend<B>(B);
|
||||
|
||||
impl<B: Backend> Backend for SoftwareCursorBackend<B> {
|
||||
type Error = B::Error;
|
||||
|
||||
fn draw<'a, I>(&mut self, content: I) -> Result<(), Self::Error>
|
||||
where
|
||||
I: Iterator<Item = (u16, u16, &'a Cell)>,
|
||||
{
|
||||
self.0.draw(content)
|
||||
}
|
||||
|
||||
fn append_lines(&mut self, count: u16) -> Result<(), Self::Error> {
|
||||
self.0.append_lines(count)
|
||||
}
|
||||
|
||||
fn hide_cursor(&mut self) -> Result<(), Self::Error> {
|
||||
self.0.hide_cursor()
|
||||
}
|
||||
|
||||
fn show_cursor(&mut self) -> Result<(), Self::Error> {
|
||||
self.0.hide_cursor()
|
||||
}
|
||||
|
||||
fn get_cursor_position(&mut self) -> Result<Position, Self::Error> {
|
||||
self.0.get_cursor_position()
|
||||
}
|
||||
|
||||
fn set_cursor_position<P: Into<Position>>(&mut self, position: P) -> Result<(), Self::Error> {
|
||||
self.0.set_cursor_position(position)
|
||||
}
|
||||
|
||||
fn clear(&mut self) -> Result<(), Self::Error> {
|
||||
self.0.clear()
|
||||
}
|
||||
|
||||
fn clear_region(&mut self, clear_type: ClearType) -> Result<(), Self::Error> {
|
||||
self.0.clear_region(clear_type)
|
||||
}
|
||||
|
||||
fn size(&self) -> Result<Size, Self::Error> {
|
||||
self.0.size()
|
||||
}
|
||||
|
||||
fn window_size(&mut self) -> Result<WindowSize, Self::Error> {
|
||||
self.0.window_size()
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> Result<(), Self::Error> {
|
||||
self.0.flush()
|
||||
}
|
||||
}
|
||||
|
||||
fn set_cursor(frame: &mut Frame, panels: &mut WheelPanels, position: Position) {
|
||||
panels.cursor = Some(position);
|
||||
frame.set_cursor_position(position);
|
||||
}
|
||||
|
||||
fn draw_frame<W: io::Write>(
|
||||
terminal: &mut Terminal<CrosstermBackend<Vec<u8>>>,
|
||||
terminal: &mut Terminal<SoftwareCursorBackend<CrosstermBackend<Vec<u8>>>>,
|
||||
output: &mut W,
|
||||
clear_screen: bool,
|
||||
render: impl FnOnce(&mut Frame),
|
||||
) -> io::Result<()> {
|
||||
// Do not suspend the terminal's presentation while computing the next frame.
|
||||
terminal.backend_mut().writer_mut().clear();
|
||||
crossterm::queue!(terminal.backend_mut(), BeginSynchronizedUpdate)?;
|
||||
terminal.backend_mut().0.writer_mut().clear();
|
||||
crossterm::queue!(terminal.backend_mut().0, BeginSynchronizedUpdate)?;
|
||||
// Terminals without synchronized updates still hide the painting cursor.
|
||||
let result = terminal.hide_cursor().and_then(|()| {
|
||||
if clear_screen {
|
||||
// Fresh Ratatui buffers are already empty; avoid its blocking cursor query.
|
||||
crossterm::queue!(
|
||||
terminal.backend_mut(),
|
||||
terminal.backend_mut().0,
|
||||
crossterm::terminal::Clear(crossterm::terminal::ClearType::All)
|
||||
)?;
|
||||
}
|
||||
terminal.draw(render).map(|_| ())
|
||||
});
|
||||
let finish = execute!(terminal.backend_mut(), EndSynchronizedUpdate);
|
||||
let finish = execute!(terminal.backend_mut().0, EndSynchronizedUpdate);
|
||||
result.and(finish)?;
|
||||
output.write_all(terminal.backend().writer())?;
|
||||
output.write_all(terminal.backend().0.writer())?;
|
||||
output.flush()
|
||||
}
|
||||
|
||||
@@ -1320,7 +1442,7 @@ fn draw_frame<W: io::Write>(
|
||||
/// inside the first synchronized frame rather than exposing a blank screen.
|
||||
pub fn run(session: &mut EditorSession, mut clear_screen: bool) -> io::Result<()> {
|
||||
let mut output: Stdout = io::stdout();
|
||||
let mut terminal = Terminal::new(CrosstermBackend::new(Vec::new()))?;
|
||||
let mut terminal = Terminal::new(SoftwareCursorBackend(CrosstermBackend::new(Vec::new())))?;
|
||||
let mut viewports = BufferViewports::default();
|
||||
let mut colors = TerminalColors::default();
|
||||
let mut query_theme = true;
|
||||
@@ -1582,6 +1704,7 @@ struct ChromeItem<'a> {
|
||||
config: &'a SegmentConfig,
|
||||
tab: Option<usize>,
|
||||
accent: bool,
|
||||
mode_style: Style,
|
||||
bold: bool,
|
||||
first: bool,
|
||||
mandatory: bool,
|
||||
@@ -1706,6 +1829,7 @@ fn chrome_items<'a>(
|
||||
config,
|
||||
tab: Some(index),
|
||||
accent: active,
|
||||
mode_style: mode_style(editor.mode()),
|
||||
bold: active,
|
||||
first: index == 0,
|
||||
mandatory: active,
|
||||
@@ -1831,6 +1955,7 @@ fn chrome_items<'a>(
|
||||
text,
|
||||
config,
|
||||
tab: None,
|
||||
mode_style: mode_style(editor.mode()),
|
||||
accent: !matches!(
|
||||
name.as_str(),
|
||||
"path"
|
||||
@@ -1949,7 +2074,7 @@ fn draw_chrome(frame: &mut Frame, mut groups: [Vec<ChromeItem<'_>>; 3], area: Re
|
||||
break;
|
||||
}
|
||||
let available = width - x;
|
||||
let highlight = Style::default().fg(Color::Black).bg(Color::Cyan);
|
||||
let highlight = item.mode_style;
|
||||
let highlight = if item.bold {
|
||||
highlight.add_modifier(Modifier::BOLD)
|
||||
} else {
|
||||
@@ -1973,7 +2098,7 @@ fn draw_chrome(frame: &mut Frame, mut groups: [Vec<ChromeItem<'_>>; 3], area: Re
|
||||
let leading_margin = &PADDING[..item.config.margin[0]];
|
||||
let trailing_margin = &PADDING[..item.config.margin[1]];
|
||||
let edges = item.tab.is_none() || item.accent;
|
||||
let edge = Style::default().fg(Color::Cyan);
|
||||
let edge = Style::default().fg(item.mode_style.bg.unwrap_or(Color::Reset));
|
||||
Line::from(vec![
|
||||
Span::styled(leading_margin, Style::reset()),
|
||||
Span::styled(if edges { item.leading_edge() } else { "" }, edge),
|
||||
@@ -2787,7 +2912,7 @@ fn draw_document(
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_floating_input(frame: &mut Frame, editor: &Editor, area: Rect) -> Option<Rect> {
|
||||
fn draw_floating_input(frame: &mut Frame, editor: &Editor, area: Rect) -> Option<(Rect, Position)> {
|
||||
if area.width == 0 || area.height == 0 {
|
||||
return None;
|
||||
}
|
||||
@@ -2848,7 +2973,10 @@ fn draw_floating_input(frame: &mut Frame, editor: &Editor, area: Rect) -> Option
|
||||
content,
|
||||
);
|
||||
frame.set_cursor_position((content.x + (column - offset) as u16, content.y));
|
||||
Some(panel)
|
||||
Some((
|
||||
panel,
|
||||
Position::new(content.x + (column - offset) as u16, content.y),
|
||||
))
|
||||
}
|
||||
|
||||
fn draw_notification(frame: &mut Frame, editor: &Editor, area: Rect) -> Option<Rect> {
|
||||
@@ -2932,7 +3060,10 @@ fn draw_overlays(
|
||||
.is_some_and(|picker| picker.presentation == FilePresentation::Floating);
|
||||
if !covered {
|
||||
if matches!(editor.mode(), Mode::Command | Mode::Search) {
|
||||
panels.input = draw_floating_input(frame, editor, area);
|
||||
if let Some((panel, cursor)) = draw_floating_input(frame, editor, area) {
|
||||
panels.input = Some(panel);
|
||||
panels.cursor = Some(cursor);
|
||||
}
|
||||
} else if editor.diff().is_none_or(|diff| diff.phase == Phase::View)
|
||||
&& !editor.file_picker().is_some_and(|picker| picker.focused)
|
||||
{
|
||||
@@ -2947,7 +3078,7 @@ fn draw_overlays(
|
||||
.notification
|
||||
.is_some_and(|panel| panel.contains(position))
|
||||
{
|
||||
frame.set_cursor_position(position);
|
||||
set_cursor(frame, panels, position);
|
||||
}
|
||||
if let Some(completion) = editor.completion()
|
||||
&& let Some((_, caret)) = caret
|
||||
@@ -2986,10 +3117,11 @@ fn draw_overlays(
|
||||
draw_hover(frame, hover, area, panels);
|
||||
}
|
||||
if let Some(diagnostic) = editor.startup_diagnostic() {
|
||||
draw_startup_diagnostic(frame, diagnostic, area);
|
||||
panels.cursor = draw_diagnostic_panel(frame, diagnostic, area, "Configuration error", None);
|
||||
}
|
||||
if let Some(output) = editor.command_output() {
|
||||
draw_diagnostic_panel(frame, &output.content, area, &output.title, Some(output));
|
||||
panels.cursor =
|
||||
draw_diagnostic_panel(frame, &output.content, area, &output.title, Some(output));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3312,7 +3444,11 @@ fn paint_editor_line(
|
||||
left,
|
||||
column,
|
||||
column.saturating_add(1),
|
||||
Style::default().fg(Color::Black).bg(Color::Magenta),
|
||||
if editor.cursor_config.mode_colors {
|
||||
mode_style(editor.mode())
|
||||
} else {
|
||||
Style::default().fg(Color::Black).bg(Color::Magenta)
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3452,6 +3588,8 @@ fn draw_diff(
|
||||
}
|
||||
} else if pull_requests {
|
||||
" Pull requests ".into()
|
||||
} else if panel.width < 50 {
|
||||
format!(" Choose {stage} ")
|
||||
} else {
|
||||
format!(" Diff · Choose {stage} · {} ", diff.comparison_mode.label())
|
||||
};
|
||||
@@ -3564,10 +3702,6 @@ fn draw_diff(
|
||||
Constraint::Length(u16::from(content.height >= 7)),
|
||||
])
|
||||
.areas(content);
|
||||
let before = diff
|
||||
.before
|
||||
.as_ref()
|
||||
.map_or("not selected", |revision| revision.label.as_str());
|
||||
let stage_text = if pull_requests {
|
||||
let filters = &diff.pull_request_preferences.filters;
|
||||
let review = if filters.len() == 3 {
|
||||
@@ -3599,11 +3733,7 @@ fn draw_diff(
|
||||
},
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"{} · Ctrl+b toggle · Before: {}",
|
||||
diff.comparison_mode.label(),
|
||||
display_text(before)
|
||||
)
|
||||
format!("{} · Ctrl+b toggle", diff.comparison_mode.label())
|
||||
};
|
||||
frame.render_widget(Paragraph::new(stage_text), stage_area);
|
||||
if pull_requests || diff.catalog.is_some() {
|
||||
@@ -3648,7 +3778,11 @@ fn draw_diff(
|
||||
&& query_area.height > 0
|
||||
&& editor.is_none_or(|editor| editor.render_pane_focused())
|
||||
{
|
||||
frame.set_cursor_position((query_area.x + (query_width - offset) as u16, query_area.y));
|
||||
set_cursor(
|
||||
frame,
|
||||
panels,
|
||||
Position::new(query_area.x + (query_width - offset) as u16, query_area.y),
|
||||
);
|
||||
}
|
||||
if let Some(notice) = notice {
|
||||
frame.render_widget(
|
||||
@@ -3663,11 +3797,34 @@ fn draw_diff(
|
||||
);
|
||||
}
|
||||
let mut entries = diff.entries();
|
||||
let before_matches = |revision: &crate::diff::Revision| {
|
||||
diff.before.as_ref().is_some_and(|before| {
|
||||
match (diff.graph_revision(before), diff.graph_revision(revision)) {
|
||||
(Some((before, _)), Some((candidate, _))) => before == candidate,
|
||||
_ => before.target == revision.target,
|
||||
}
|
||||
})
|
||||
};
|
||||
if !pull_requests && let Some(working) = entries.next() {
|
||||
let follow = diff.phase == Phase::After && diff.follow_working_copy;
|
||||
let label = format!(
|
||||
"{} {} · pinned",
|
||||
"{} {}{} · pinned · {}",
|
||||
if diff.selected == 0 { ">" } else { " " },
|
||||
display_text(&working.label)
|
||||
if follow {
|
||||
"Follow checkout"
|
||||
} else {
|
||||
"Checkout snapshot"
|
||||
},
|
||||
if before_matches(working) {
|
||||
" [Before]"
|
||||
} else {
|
||||
""
|
||||
},
|
||||
if follow {
|
||||
"Live files; follows descendant checkouts"
|
||||
} else {
|
||||
"Live files at this checkout"
|
||||
},
|
||||
);
|
||||
frame.render_widget(
|
||||
Paragraph::new(visible_line(&label, 0, usize::from(pinned_area.width))).style(
|
||||
@@ -3723,6 +3880,7 @@ fn draw_diff(
|
||||
0
|
||||
};
|
||||
let decoration_width = symbol_width + usize::from(symbol_width > 0);
|
||||
let graph = diff.picker_graph();
|
||||
for (index, revision) in entries
|
||||
.enumerate()
|
||||
.skip(first)
|
||||
@@ -3736,6 +3894,71 @@ fn draw_diff(
|
||||
} else {
|
||||
Style::default()
|
||||
};
|
||||
let before_badge = if before_matches(revision) {
|
||||
" [Before]"
|
||||
} else {
|
||||
""
|
||||
};
|
||||
if let Some((id, metadata)) = diff.graph_revision(revision)
|
||||
&& let Some(prefix) = graph.get(id)
|
||||
{
|
||||
let width = usize::from(results.width);
|
||||
let change = metadata.change_id.as_str();
|
||||
let change = change.get(..12).unwrap_or(change);
|
||||
let bookmark = if revision.category == crate::diff::Category::Bookmarks {
|
||||
format!("[{}] ", display_text(&revision.label))
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
let label = format!(
|
||||
"{} {}{bookmark}{}{} {} {} {} {}",
|
||||
if index == diff.selected { ">" } else { " " },
|
||||
prefix[0],
|
||||
display_text(change),
|
||||
before_badge,
|
||||
display_text(&metadata.author),
|
||||
display_text(&metadata.timestamp),
|
||||
if metadata.bookmarks.is_empty() || !bookmark.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
format!("[{}]", display_text(&metadata.bookmarks))
|
||||
},
|
||||
&id[..id.len().min(12)],
|
||||
);
|
||||
if row_height == 2 {
|
||||
lines.push(Line::styled(visible_line(&label, 0, width), style));
|
||||
lines.push(Line::styled(
|
||||
visible_line(
|
||||
&format!(" {}{}", prefix[1], display_text(&metadata.description)),
|
||||
0,
|
||||
width,
|
||||
),
|
||||
style.fg(Color::DarkGray),
|
||||
));
|
||||
} else {
|
||||
lines.push(Line::styled(
|
||||
visible_line(
|
||||
&format!(
|
||||
"{} {}{}{}{bookmark}{} · {}",
|
||||
if index == diff.selected { ">" } else { " " },
|
||||
prefix[0],
|
||||
if prefix[1].contains('~') { "~ " } else { "" },
|
||||
if before_badge.is_empty() {
|
||||
""
|
||||
} else {
|
||||
"[Before] "
|
||||
},
|
||||
display_text(change),
|
||||
display_text(&metadata.description),
|
||||
),
|
||||
0,
|
||||
width,
|
||||
),
|
||||
style,
|
||||
));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let symbol = if pull_requests {
|
||||
match diff.pull_request_review_state(revision) {
|
||||
crate::diff::PullRequestReviewState::Requested => requested_symbol,
|
||||
@@ -3746,7 +3969,7 @@ fn draw_diff(
|
||||
""
|
||||
};
|
||||
let label = format!(
|
||||
"{} {symbol}{:padding$}{}",
|
||||
"{} {symbol}{:padding$}{}{before_badge}",
|
||||
if index == diff.selected { ">" } else { " " },
|
||||
"",
|
||||
display_text(&revision.label),
|
||||
@@ -4897,17 +5120,13 @@ fn floating_panel(area: Rect) -> Rect {
|
||||
panel
|
||||
}
|
||||
|
||||
fn draw_startup_diagnostic(frame: &mut Frame, diagnostic: &StartupDiagnostic, area: Rect) {
|
||||
draw_diagnostic_panel(frame, diagnostic, area, "Configuration error", None);
|
||||
}
|
||||
|
||||
fn draw_diagnostic_panel(
|
||||
frame: &mut Frame,
|
||||
diagnostic: &StartupDiagnostic,
|
||||
area: Rect,
|
||||
title: &str,
|
||||
output: Option<&crate::editor::ShellOutput>,
|
||||
) {
|
||||
) -> Option<Position> {
|
||||
let startup = output.is_none();
|
||||
let panel = floating_panel(area);
|
||||
frame.render_widget(Clear, panel);
|
||||
@@ -4988,7 +5207,11 @@ fn draw_diagnostic_panel(
|
||||
help_area,
|
||||
);
|
||||
if startup && text_area.width > 0 && text_area.height > 0 {
|
||||
frame.set_cursor_position((text_area.x, text_area.y));
|
||||
let position = Position::new(text_area.x, text_area.y);
|
||||
frame.set_cursor_position(position);
|
||||
Some(position)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5707,6 +5930,7 @@ impl Default for DiffColors {
|
||||
struct WheelPanels {
|
||||
workspace_managed: bool,
|
||||
caret: Option<(Rect, Position)>,
|
||||
cursor: Option<Position>,
|
||||
input: Option<Rect>,
|
||||
notification: Option<Rect>,
|
||||
completion: Option<Rect>,
|
||||
@@ -5826,6 +6050,7 @@ impl WheelPanels {
|
||||
}
|
||||
self.hover = None;
|
||||
self.caret = None;
|
||||
self.cursor = None;
|
||||
self.input = None;
|
||||
self.notification = None;
|
||||
self.completion = None;
|
||||
@@ -6361,7 +6586,11 @@ fn draw_file_list(
|
||||
&& (!browsing || picker.entries().len() == 0 || results_area.height == 0)
|
||||
{
|
||||
let cursor_x = if browsing { 0 } else { query_width - offset };
|
||||
frame.set_cursor_position((query_area.x + cursor_x as u16, query_area.y));
|
||||
set_cursor(
|
||||
frame,
|
||||
panels,
|
||||
Position::new(query_area.x + cursor_x as u16, query_area.y),
|
||||
);
|
||||
}
|
||||
if let Some(root) = root {
|
||||
frame.render_widget(root, root_area);
|
||||
@@ -6492,10 +6721,14 @@ fn draw_file_list(
|
||||
&& selected_index >= first
|
||||
&& selected_index - first < count
|
||||
{
|
||||
frame.set_cursor_position((
|
||||
results_area.x,
|
||||
results_area.y + (selected_index - first) as u16,
|
||||
));
|
||||
set_cursor(
|
||||
frame,
|
||||
panels,
|
||||
Position::new(
|
||||
results_area.x,
|
||||
results_area.y + (selected_index - first) as u16,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
if !show_help {
|
||||
@@ -6591,7 +6824,11 @@ fn draw_palette(
|
||||
.style(Style::default().fg(Color::Yellow)),
|
||||
query_area,
|
||||
);
|
||||
frame.set_cursor_position((query_area.x + (query_width - offset) as u16, query_area.y));
|
||||
set_cursor(
|
||||
frame,
|
||||
panels,
|
||||
Position::new(query_area.x + (query_width - offset) as u16, query_area.y),
|
||||
);
|
||||
if palette.entries.is_empty() {
|
||||
panels.picker_scroll.palette = None;
|
||||
frame.render_widget(
|
||||
|
||||
@@ -629,10 +629,6 @@ fn branch_changes_default_and_mode_switches_compare_the_selected_divergent_tips(
|
||||
session.editor().diff().unwrap().comparison_mode,
|
||||
ComparisonMode::Snapshots
|
||||
);
|
||||
assert_eq!(
|
||||
session.editor().message(),
|
||||
"Working checkout requires Snapshots"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1367,6 +1367,31 @@ fn jj_private_fetch_discovers_never_fetched_bookmark_and_searchable_remote_chang
|
||||
);
|
||||
assert_eq!(changed(&comparison, Path::new("file")).after, ["local"]);
|
||||
let loaded = repository.fetch_remote("origin").unwrap();
|
||||
assert_eq!(loaded.graph[&tip].parents, [ancestor.clone()]);
|
||||
assert_eq!(
|
||||
loaded.graph[&ancestor].description,
|
||||
"remote historic needle"
|
||||
);
|
||||
assert!(!loaded.graph[&tip].current);
|
||||
let positions: std::collections::BTreeMap<_, _> = loaded
|
||||
.entries
|
||||
.iter()
|
||||
.filter(|entry| entry.category == Category::Revisions)
|
||||
.enumerate()
|
||||
.filter_map(|(index, entry)| match &entry.target {
|
||||
RevisionTarget::Commit(id) => Some((id.as_str(), index)),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
for (id, metadata) in &loaded.graph {
|
||||
for parent in &metadata.parents {
|
||||
if let (Some(child), Some(parent)) =
|
||||
(positions.get(id.as_str()), positions.get(parent.as_str()))
|
||||
{
|
||||
assert!(child < parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
let historic = loaded
|
||||
.entries
|
||||
.iter()
|
||||
|
||||
+41
-8
@@ -115,6 +115,17 @@ fn cli_deletes_only_the_requested_comment_and_preserves_failed_targets() {
|
||||
assert!(empty.comments.is_empty());
|
||||
assert_eq!(empty.storage_revision, loaded.storage_revision + 1);
|
||||
assert_eq!(empty.summary, review.summary);
|
||||
let output = cli("repo", &["list", "--json"]);
|
||||
assert!(output.status.success(), "{:?}", output);
|
||||
let list: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();
|
||||
assert_eq!(list["reviews"], serde_json::json!([]));
|
||||
let output = cli("repo", &["list"]);
|
||||
assert!(output.status.success(), "{:?}", output);
|
||||
assert!(
|
||||
String::from_utf8(output.stdout)
|
||||
.unwrap()
|
||||
.contains("No stored reviews.")
|
||||
);
|
||||
assert_eq!(
|
||||
store
|
||||
.load(&other.root, other.storage_id.unwrap())
|
||||
@@ -178,6 +189,8 @@ fn cli_resolves_only_the_requested_comment_and_preserves_original_feedback() {
|
||||
other.comments = review.comments.clone();
|
||||
store.save(&mut other).unwrap();
|
||||
let mut source = Review::new(review.root.clone());
|
||||
source.summary = "Progress without comments".into();
|
||||
source.verdict = Some(Verdict::LooksGood);
|
||||
store.save(&mut source).unwrap();
|
||||
let mut reversed = Review::new(review.root.clone());
|
||||
reversed.comparison = Some(["working:frozen-tip".into(), "frozen-base".into()]);
|
||||
@@ -272,20 +285,32 @@ fn cli_resolves_only_the_requested_comment_and_preserves_original_feedback() {
|
||||
let output = cli("repo", &["list", "--json"]);
|
||||
assert!(output.status.success(), "{:?}", output);
|
||||
let list: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();
|
||||
assert_eq!(list["reviews"].as_array().unwrap().len(), 3);
|
||||
assert_eq!(
|
||||
list["reviews"][0]["comparison"],
|
||||
serde_json::json!(reversed.comparison)
|
||||
list["reviews"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|review| review["id"].as_i64().unwrap())
|
||||
.collect::<Vec<_>>(),
|
||||
vec![id]
|
||||
);
|
||||
assert!(list["reviews"][1]["comparison"].is_null());
|
||||
assert_eq!(list["reviews"][2]["comparison"], json["comparison"]);
|
||||
assert_eq!(list["reviews"][2]["counts"], json["counts"]);
|
||||
assert_eq!(list["reviews"][0]["comparison"], json["comparison"]);
|
||||
assert_eq!(list["reviews"][0]["counts"], json["counts"]);
|
||||
let output = cli("repo", &["list"]);
|
||||
assert!(output.status.success(), "{:?}", output);
|
||||
let text = String::from_utf8(output.stdout).unwrap();
|
||||
assert!(text.contains("Scope: source"));
|
||||
assert!(!text.contains("Progress without comments"));
|
||||
assert!(text.contains("Scope: comparison frozen-base → working:frozen-tip"));
|
||||
assert!(text.contains("Scope: comparison working:frozen-tip → frozen-base"));
|
||||
assert!(!text.contains("Scope: comparison working:frozen-tip → frozen-base"));
|
||||
assert_eq!(fs::read(&path).unwrap(), before);
|
||||
let output = cli(
|
||||
"repo",
|
||||
&["show", &source.storage_id.unwrap().to_string(), "--json"],
|
||||
);
|
||||
assert!(output.status.success(), "{:?}", output);
|
||||
let shown: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();
|
||||
assert_eq!(shown["summary"], source.summary);
|
||||
assert_eq!(shown["verdict"], "looks_good");
|
||||
let output = cli("repo", &["resolve", &id_text, "2"]);
|
||||
assert!(output.status.success(), "{:?}", output);
|
||||
let text = String::from_utf8(output.stdout).unwrap();
|
||||
@@ -293,6 +318,14 @@ fn cli_resolves_only_the_requested_comment_and_preserves_original_feedback() {
|
||||
let loaded = store.load(&review.root, id).unwrap();
|
||||
assert_eq!(loaded.storage_revision, review.storage_revision + 2);
|
||||
assert!(loaded.comments.iter().all(|comment| comment.resolved));
|
||||
let output = cli("repo", &["list", "--json"]);
|
||||
assert!(output.status.success(), "{:?}", output);
|
||||
let list: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();
|
||||
assert_eq!(list["reviews"][0]["id"], id);
|
||||
assert_eq!(
|
||||
list["reviews"][0]["counts"],
|
||||
serde_json::json!({"total": 3, "resolved": 3, "unresolved": 0})
|
||||
);
|
||||
assert_eq!(
|
||||
store
|
||||
.load(&other.root, other.storage_id.unwrap())
|
||||
|
||||
+176
-4
@@ -394,6 +394,7 @@ fn revision(
|
||||
fn catalog() -> Catalog {
|
||||
Catalog {
|
||||
kind: RepoKind::Git,
|
||||
graph: Default::default(),
|
||||
entries: vec![
|
||||
revision(
|
||||
RevisionTarget::Working,
|
||||
@@ -1573,7 +1574,7 @@ fn revision_matches_rank_later_contiguous_boundaries_and_tight_subsequences() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn jujutsu_fuzzy_selectors_rank_labels_above_descriptions_in_both_stages() {
|
||||
fn jujutsu_fuzzy_selectors_preserve_catalog_order_in_both_stages() {
|
||||
for phase in [Phase::Before, Phase::After] {
|
||||
for (category_index, &category) in RepoKind::Jujutsu.categories().iter().enumerate() {
|
||||
let mut state = DiffState::new();
|
||||
@@ -1581,6 +1582,7 @@ fn jujutsu_fuzzy_selectors_rank_labels_above_descriptions_in_both_stages() {
|
||||
1,
|
||||
Ok(Outcome::Catalog(Catalog {
|
||||
kind: RepoKind::Jujutsu,
|
||||
graph: Default::default(),
|
||||
entries: vec![
|
||||
revision(
|
||||
RevisionTarget::Working,
|
||||
@@ -1621,15 +1623,185 @@ fn jujutsu_fuzzy_selectors_rank_labels_above_descriptions_in_both_stages() {
|
||||
.map(|entry| &entry.target)
|
||||
.collect::<Vec<_>>(),
|
||||
[
|
||||
&RevisionTarget::Commit("immutable-exact-target".into()),
|
||||
&RevisionTarget::Commit("immutable-fuzzy-target".into()),
|
||||
&RevisionTarget::Commit("description-target".into()),
|
||||
&RevisionTarget::Commit("immutable-fuzzy-target".into()),
|
||||
&RevisionTarget::Commit("immutable-exact-target".into()),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn graph_state() -> DiffState {
|
||||
let mut catalog = Catalog {
|
||||
kind: RepoKind::Jujutsu,
|
||||
graph: Default::default(),
|
||||
notice: None,
|
||||
entries: vec![revision(
|
||||
RevisionTarget::Working,
|
||||
"Working",
|
||||
"",
|
||||
Category::Revisions,
|
||||
)],
|
||||
};
|
||||
for (id, parents) in [
|
||||
("merge", vec!["left", "right"]),
|
||||
("left", vec!["hidden"]),
|
||||
("hidden", vec!["root"]),
|
||||
("right", vec!["root"]),
|
||||
("root", vec![]),
|
||||
] {
|
||||
catalog.entries.push(revision(
|
||||
RevisionTarget::Commit(id.into()),
|
||||
id,
|
||||
"needle",
|
||||
Category::Revisions,
|
||||
));
|
||||
catalog.graph.insert(
|
||||
id.into(),
|
||||
RevisionGraph {
|
||||
parents: parents.into_iter().map(String::from).collect(),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
}
|
||||
catalog.entries.push(revision(
|
||||
RevisionTarget::Bookmark {
|
||||
name: "topic".into(),
|
||||
remote: None,
|
||||
},
|
||||
"topic",
|
||||
"change merge needle",
|
||||
Category::Bookmarks,
|
||||
));
|
||||
catalog.entries.push(revision(
|
||||
RevisionTarget::Bookmark {
|
||||
name: "base".into(),
|
||||
remote: None,
|
||||
},
|
||||
"base",
|
||||
"change root needle",
|
||||
Category::Bookmarks,
|
||||
));
|
||||
let mut state = DiffState::new();
|
||||
state.apply_result(1, Ok(Outcome::Catalog(catalog)));
|
||||
state
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn picker_graph_preserves_forks_merges_and_marks_filtered_ancestry() {
|
||||
let mut state = graph_state();
|
||||
let graph = state.picker_graph();
|
||||
assert_eq!(graph.len(), 5);
|
||||
assert_eq!(graph["merge"][1].trim_end(), "├─┐");
|
||||
assert_eq!(graph["right"][1].trim_end(), "├─┘");
|
||||
assert!(!graph.values().flatten().any(|prefix| prefix.contains('~')));
|
||||
state.category = 1;
|
||||
state.refilter();
|
||||
assert_eq!(state.entries().len(), 3);
|
||||
let graph = state.picker_graph();
|
||||
assert_eq!(
|
||||
graph.keys().map(String::as_str).collect::<Vec<_>>(),
|
||||
["merge", "root"]
|
||||
);
|
||||
assert!(graph["merge"][1].contains('~'));
|
||||
assert_eq!(
|
||||
state
|
||||
.graph_revision(state.entries().nth(1).unwrap())
|
||||
.unwrap()
|
||||
.0,
|
||||
"merge"
|
||||
);
|
||||
assert!(matches!(
|
||||
state.entries().nth(1).unwrap().target,
|
||||
RevisionTarget::Bookmark { .. }
|
||||
));
|
||||
state.category = 0;
|
||||
state.query = "left root".into();
|
||||
state.refilter();
|
||||
assert!(state.picker_graph().is_empty());
|
||||
assert_eq!(state.entries().len(), 1);
|
||||
state.before = Some(state.catalog.as_ref().unwrap().entries[1].clone());
|
||||
state.query = "right".into();
|
||||
state.refilter();
|
||||
assert_eq!(state.picker_graph().len(), 2);
|
||||
assert!(state.picker_graph()["merge"][1].contains('~'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn graph_crossings_do_not_join_unrelated_ancestry() {
|
||||
let mut state = DiffState::new();
|
||||
let mut catalog = Catalog {
|
||||
kind: RepoKind::Jujutsu,
|
||||
entries: Vec::new(),
|
||||
graph: Default::default(),
|
||||
notice: None,
|
||||
};
|
||||
for (id, parents) in [
|
||||
("a", vec!["x"]),
|
||||
("b", vec!["y"]),
|
||||
("merge", vec!["x", "z"]),
|
||||
("x", vec![]),
|
||||
("y", vec![]),
|
||||
("z", vec![]),
|
||||
] {
|
||||
catalog.entries.push(revision(
|
||||
RevisionTarget::Commit(id.into()),
|
||||
id,
|
||||
"",
|
||||
Category::Revisions,
|
||||
));
|
||||
catalog.graph.insert(
|
||||
id.into(),
|
||||
RevisionGraph {
|
||||
parents: parents.into_iter().map(String::from).collect(),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
}
|
||||
state.apply_result(1, Ok(Outcome::Catalog(catalog)));
|
||||
assert_eq!(state.picker_graph()["merge"][1].trim_end(), "├─╪─┤");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn before_identity_survives_query_and_category_without_duplicate_graph_nodes() {
|
||||
let mut state = graph_state();
|
||||
state.category = 1;
|
||||
state.refilter();
|
||||
state.selected = 1;
|
||||
state.choose();
|
||||
let before = state.before.clone().unwrap();
|
||||
assert!(matches!(before.target, RevisionTarget::Bookmark { .. }));
|
||||
state.category = 0;
|
||||
state.refilter();
|
||||
assert_eq!(
|
||||
state
|
||||
.entries()
|
||||
.filter(|entry| state
|
||||
.graph_revision(entry)
|
||||
.is_some_and(|(id, _)| id == "merge"))
|
||||
.count(),
|
||||
1
|
||||
);
|
||||
for category in 0..2 {
|
||||
state.category = category;
|
||||
state.query = "unmatched".into();
|
||||
state.refilter();
|
||||
assert_eq!(state.entries().len(), 2);
|
||||
let retained = state
|
||||
.entries()
|
||||
.find(|entry| entry.target == before.target)
|
||||
.unwrap();
|
||||
assert_eq!(retained.target, before.target);
|
||||
assert_eq!(state.before.as_ref(), Some(&before));
|
||||
state.selected = 1;
|
||||
assert_eq!(
|
||||
state.entries().nth(state.selected).unwrap().target,
|
||||
before.target
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn selector_filters_literal_unicode_tokens_and_pins_working_in_each_category() {
|
||||
let mut editor = editor();
|
||||
@@ -1746,7 +1918,7 @@ fn loader_preserves_after_step_query_category_and_selection_then_compares() {
|
||||
state.entries().nth(state.selected).unwrap().target,
|
||||
RevisionTarget::FetchRemote("origin".into())
|
||||
);
|
||||
assert_eq!(state.entries().len(), 3);
|
||||
assert_eq!(state.entries().len(), 4);
|
||||
let remote_position = state
|
||||
.entries()
|
||||
.position(
|
||||
|
||||
@@ -1836,6 +1836,7 @@ fn hidden_tab_diff_results_restore_visible_insert_interaction_and_route_request_
|
||||
let catalog = || {
|
||||
Outcome::Catalog(Catalog {
|
||||
kind: RepoKind::Git,
|
||||
graph: Default::default(),
|
||||
entries: [
|
||||
RevisionTarget::Commit("base".into()),
|
||||
RevisionTarget::Working,
|
||||
@@ -2627,6 +2628,7 @@ fn diff_results_bind_the_owning_pane_without_disturbing_focused_document_or_mode
|
||||
id,
|
||||
Ok(Outcome::Catalog(Catalog {
|
||||
kind: RepoKind::Git,
|
||||
graph: Default::default(),
|
||||
entries: vec![Revision {
|
||||
target: RevisionTarget::Working,
|
||||
label: "Working".into(),
|
||||
@@ -3039,6 +3041,7 @@ fn working_diff_with_revisions(
|
||||
id,
|
||||
Ok(Outcome::Catalog(Catalog {
|
||||
kind: RepoKind::Git,
|
||||
graph: Default::default(),
|
||||
entries: vec![
|
||||
revision(RevisionTarget::Commit("base".into()), "base"),
|
||||
revision(RevisionTarget::Working, "Working"),
|
||||
@@ -3113,6 +3116,7 @@ fn historical_diff_with_revisions(
|
||||
id,
|
||||
Ok(Outcome::Catalog(Catalog {
|
||||
kind: RepoKind::Git,
|
||||
graph: Default::default(),
|
||||
entries: vec![revision("base"), revision("head")],
|
||||
notice: None,
|
||||
})),
|
||||
|
||||
@@ -463,6 +463,80 @@ fn working_jj_conflicted_parent_uses_cli_projection_without_snapshotting() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn jj_catalog_exposes_fixed_metadata_and_merge_parents_without_snapshotting() {
|
||||
let temp = Temporary::new().unwrap();
|
||||
let root = &temp.0;
|
||||
fixture_command(root, "jj", &["git", "init", "--no-colocate", "."]);
|
||||
fixture_command(root, "jj", &["describe", "-m", "Base"]);
|
||||
let id = |root: &Path| {
|
||||
fixture_command(
|
||||
root,
|
||||
"jj",
|
||||
&[
|
||||
"--ignore-working-copy",
|
||||
"log",
|
||||
"--no-graph",
|
||||
"-r",
|
||||
"@",
|
||||
"-T",
|
||||
"commit_id",
|
||||
],
|
||||
)
|
||||
};
|
||||
let base = id(root);
|
||||
fixture_command(root, "jj", &["bookmark", "create", "base"]);
|
||||
fixture_command(root, "jj", &["new", &base, "-m", "Left"]);
|
||||
let left = id(root);
|
||||
fixture_command(root, "jj", &["new", &base, "-m", "Right"]);
|
||||
let right = id(root);
|
||||
fixture_command(root, "jj", &["new", &left, &right, "-m", "Merge"]);
|
||||
let current = id(root);
|
||||
let operation = fixture_command(
|
||||
root,
|
||||
"jj",
|
||||
&[
|
||||
"--ignore-working-copy",
|
||||
"op",
|
||||
"log",
|
||||
"--no-graph",
|
||||
"-n",
|
||||
"1",
|
||||
"-T",
|
||||
"id",
|
||||
],
|
||||
);
|
||||
let mut repository = Repository::open(root, Arc::new(AtomicBool::new(false))).unwrap();
|
||||
let catalog = repository.catalog().unwrap();
|
||||
let merge = &catalog.graph[¤t];
|
||||
assert_eq!(merge.parents, [left, right]);
|
||||
assert_eq!(merge.author, "Picker Author");
|
||||
assert_eq!(merge.timestamp, "2001-01-01 00:00");
|
||||
assert_eq!(merge.description, "Merge");
|
||||
assert!(!merge.change_id.is_empty());
|
||||
assert!(merge.current);
|
||||
assert_eq!(catalog.graph[&base].bookmarks, "base");
|
||||
assert!(!catalog.graph[&base].current);
|
||||
assert!(catalog.graph[&"0".repeat(40)].immutable);
|
||||
assert_eq!(
|
||||
fixture_command(
|
||||
root,
|
||||
"jj",
|
||||
&[
|
||||
"--ignore-working-copy",
|
||||
"op",
|
||||
"log",
|
||||
"--no-graph",
|
||||
"-n",
|
||||
"1",
|
||||
"-T",
|
||||
"id"
|
||||
]
|
||||
),
|
||||
operation
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cancellation_kills_pipe_holding_children_and_drains_both_streams() {
|
||||
let temp = Temporary::new().unwrap();
|
||||
|
||||
@@ -653,6 +653,69 @@ fn git_gutter_config_modes_default_and_rejection() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cursor_config_partial_shapes_and_invalid_options() {
|
||||
use crate::cursor::CursorShape::{Bar, Block, Underline};
|
||||
|
||||
let fixture = Fixture::new();
|
||||
for (options, mode_colors, shapes) in [
|
||||
(
|
||||
r#"{ insert: :bar, "visual" => "underline" }"#,
|
||||
true,
|
||||
[Block, Bar, Block, Block, Underline],
|
||||
),
|
||||
(
|
||||
r#"{ mode_colors: false, normal: "bar", insert: :underline, command: :bar, search: "underline", visual: :block }"#,
|
||||
false,
|
||||
[Bar, Underline, Bar, Underline, Block],
|
||||
),
|
||||
(
|
||||
r#"{ "mode_colors" => true, normal: :underline, insert: "block", command: "underline", search: :bar, visual: "bar" }"#,
|
||||
true,
|
||||
[Underline, Block, Underline, Bar, Bar],
|
||||
),
|
||||
] {
|
||||
let path = fixture.file(
|
||||
"config.rb",
|
||||
&format!("Vamp.configure {{ |config| config.cursor = {options} }}"),
|
||||
);
|
||||
let cursor = load_config(&path).unwrap().cursor;
|
||||
assert_eq!(cursor.mode_colors, mode_colors);
|
||||
assert_eq!(
|
||||
[
|
||||
cursor.normal,
|
||||
cursor.insert,
|
||||
cursor.command,
|
||||
cursor.search,
|
||||
cursor.visual
|
||||
],
|
||||
shapes
|
||||
);
|
||||
}
|
||||
for options in [
|
||||
"nil",
|
||||
"false",
|
||||
"[]",
|
||||
"{ mode_colors: nil }",
|
||||
"{ mode_colors: 1 }",
|
||||
r#"{ mode_colors: "true" }"#,
|
||||
"{ insert: nil }",
|
||||
"{ insert: false }",
|
||||
"{ insert: 1 }",
|
||||
"{ insert: :beam }",
|
||||
r#"{ normal: "" }"#,
|
||||
"{ unknown: :block }",
|
||||
"{ 1 => :block }",
|
||||
r#"{ insert: :bar, "insert" => :block }"#,
|
||||
] {
|
||||
let path = fixture.file(
|
||||
"config.rb",
|
||||
&format!("Vamp.configure {{ |config| config.cursor = {options} }}"),
|
||||
);
|
||||
assert!(load_config(&path).is_err(), "{options}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn git_blame_boolean_config_typed_toggle_palette_and_wire_validation() {
|
||||
let fixture = Fixture::new();
|
||||
|
||||
@@ -556,6 +556,7 @@ fn checkout_diff_polling_uses_injected_interval_independently_of_endpoint_follow
|
||||
id,
|
||||
Ok(DiffOutcome::Catalog(Catalog {
|
||||
kind: RepoKind::Git,
|
||||
graph: Default::default(),
|
||||
notice: None,
|
||||
entries: [
|
||||
RevisionTarget::Working,
|
||||
@@ -3725,6 +3726,7 @@ fn async_responses_edit_only_current_bound_working_after_and_refresh_projection(
|
||||
id,
|
||||
Ok(DiffOutcome::Catalog(Catalog {
|
||||
kind: RepoKind::Git,
|
||||
graph: Default::default(),
|
||||
notice: None,
|
||||
entries: vec![
|
||||
revision(RevisionTarget::Commit("base".into()), "base"),
|
||||
|
||||
+397
-64
@@ -323,7 +323,11 @@ fn historical_buffer_markers_retain_real_final_newlines_and_scope() {
|
||||
for (x, y, symbol) in [(3, 0, "↵"), (0, 1, "·"), (1, 1, "·"), (7, 1, "↵")] {
|
||||
let cell = &buffer[(area.x + x, area.y + y)];
|
||||
assert_eq!(cell.symbol(), symbol);
|
||||
assert!(cell.modifier.contains(Modifier::DIM));
|
||||
assert_eq!(
|
||||
cell.modifier.contains(Modifier::DIM),
|
||||
views.panels.cursor != Some(Position::new(area.x + x, area.y + y)),
|
||||
"only the primary cursor removes marker dim styling",
|
||||
);
|
||||
}
|
||||
assert_eq!(buffer[(area.x + 6, area.y + 1)].symbol(), " ");
|
||||
assert_eq!(buffer[(area.x + 6, area.y + 1)].bg, Color::Red);
|
||||
@@ -847,6 +851,7 @@ fn whitespace_characters_preserve_source_geometry_and_overlay_styles() {
|
||||
session.handle(Input::End);
|
||||
session.handle(Input::Char('v'));
|
||||
session.handle(Input::Left);
|
||||
session.handle(Input::Left);
|
||||
terminal
|
||||
.draw(|frame| views.draw(frame, session.editor_mut()))
|
||||
.unwrap();
|
||||
@@ -905,6 +910,7 @@ fn trailing_whitespace_is_opt_in_and_preserves_wrapping_and_selection() {
|
||||
session.handle(Input::End);
|
||||
session.handle(Input::Char('v'));
|
||||
session.handle(Input::Left);
|
||||
session.handle(Input::Left);
|
||||
terminal
|
||||
.draw(|frame| views.draw(frame, session.editor_mut()))
|
||||
.unwrap();
|
||||
@@ -1290,7 +1296,7 @@ fn resolver_renders_aligned_native_draft_alternative_and_separate_history() {
|
||||
);
|
||||
assert_eq!(buffer[(x, content.y + 1)].symbol(), "v");
|
||||
assert_eq!(
|
||||
buffer[(x, content.y + 1)].bg,
|
||||
buffer[(x + 1, content.y + 1)].bg,
|
||||
views.panels.diff_colors.row[1]
|
||||
);
|
||||
}
|
||||
@@ -1464,7 +1470,7 @@ fn resolver_renders_aligned_native_draft_alternative_and_separate_history() {
|
||||
let searched_caret = render(&mut terminal, &mut views, &mut session);
|
||||
assert!(screen_text(&terminal).contains("context 30"));
|
||||
assert_eq!(
|
||||
terminal.backend().buffer()[(searched_caret.x, searched_caret.y)].bg,
|
||||
terminal.backend().buffer()[(searched_caret.x + 1, searched_caret.y)].bg,
|
||||
Color::Yellow,
|
||||
"source {:?} ({:?}), terminal {searched_caret:?}, caret {:?}, viewport {:?}, focus {:?}",
|
||||
session.editor().cursor(),
|
||||
@@ -1945,6 +1951,7 @@ fn diff_catalog() -> crate::diff::Catalog {
|
||||
Catalog {
|
||||
kind: RepoKind::Git,
|
||||
entries,
|
||||
graph: Default::default(),
|
||||
notice: None,
|
||||
}
|
||||
}
|
||||
@@ -3495,7 +3502,7 @@ fn diff_picker_keeps_working_pinned_while_windowing_searching_and_changing_stage
|
||||
assert!(text.contains("Choose Before"));
|
||||
assert!(text.contains("Tab categories"));
|
||||
assert!(text.contains("Enter select"));
|
||||
assert!(text.contains("Working checkout · pinned"));
|
||||
assert!(text.contains("Checkout snapshot · pinned"));
|
||||
assert!(text.contains("> commit-19"));
|
||||
assert!(!text.contains("commit-00"));
|
||||
for ch in "needle".chars() {
|
||||
@@ -3505,13 +3512,14 @@ fn diff_picker_keeps_working_pinned_while_windowing_searching_and_changing_stage
|
||||
render_diff(&mut terminal, &diff, &mut panels);
|
||||
let text = screen_text(&terminal);
|
||||
assert!(text.contains("> needle"));
|
||||
assert!(text.contains("Working checkout · pinned"));
|
||||
assert!(text.contains("Checkout snapshot · pinned"));
|
||||
assert!(text.contains("> commit-19"));
|
||||
diff.handle(Input::Enter);
|
||||
render_diff(&mut terminal, &diff, &mut panels);
|
||||
let text = screen_text(&terminal);
|
||||
assert!(text.contains("Choose After"));
|
||||
assert!(text.contains("Branch changes · Ctrl+b toggle · Before: commit-19"));
|
||||
assert!(text.contains("Branch changes · Ctrl+b toggle"));
|
||||
assert!(!text.contains("Before:"));
|
||||
assert!(screen_text(&terminal).contains("Tab categories"));
|
||||
assert!(screen_text(&terminal).contains("Enter select"));
|
||||
diff.handle(Input::Ctrl('u'));
|
||||
@@ -3519,8 +3527,8 @@ fn diff_picker_keeps_working_pinned_while_windowing_searching_and_changing_stage
|
||||
render_diff(&mut terminal, &diff, &mut panels);
|
||||
let text = screen_text(&terminal);
|
||||
assert!(text.contains("feature-branch"));
|
||||
assert!(!text.contains("ordinary change"));
|
||||
assert!(text.contains("Working checkout · pinned"));
|
||||
assert!(text.contains("commit-19 [Before]"));
|
||||
assert!(text.contains("Checkout snapshot · pinned"));
|
||||
let buffer = terminal.backend().buffer();
|
||||
assert!(
|
||||
buffer
|
||||
@@ -3530,6 +3538,128 @@ fn diff_picker_keeps_working_pinned_while_windowing_searching_and_changing_stage
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checkout_picker_labels_follow_the_configured_stage() {
|
||||
let mut diff = DiffState::new();
|
||||
diff.follow_working_copy = true;
|
||||
diff.take_request();
|
||||
diff.apply_result(1, Ok(crate::diff::Outcome::Catalog(diff_catalog())));
|
||||
let mut terminal = Terminal::new(ratatui::backend::TestBackend::new(100, 16)).unwrap();
|
||||
let mut panels = WheelPanels::default();
|
||||
render_diff(&mut terminal, &diff, &mut panels);
|
||||
assert!(
|
||||
screen_text(&terminal).contains("Checkout snapshot · pinned · Live files at this checkout")
|
||||
);
|
||||
diff.handle(Input::Enter);
|
||||
render_diff(&mut terminal, &diff, &mut panels);
|
||||
assert!(screen_text(&terminal).contains("Follow checkout [Before] · pinned"));
|
||||
assert!(screen_text(&terminal).contains("follows descendant checkouts"));
|
||||
diff.follow_working_copy = false;
|
||||
render_diff(&mut terminal, &diff, &mut panels);
|
||||
assert!(screen_text(&terminal).contains("Checkout snapshot [Before] · pinned"));
|
||||
assert!(!screen_text(&terminal).contains("Follow checkout"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn jj_picker_renders_graph_before_badge_and_compacts_without_losing_controls() {
|
||||
use crate::diff::{Category, RepoKind, Revision, RevisionGraph, RevisionTarget};
|
||||
let mut catalog = diff_catalog();
|
||||
catalog.kind = RepoKind::Jujutsu;
|
||||
catalog.entries.truncate(1);
|
||||
for (id, change, parent, current, immutable) in [
|
||||
("aaaa1111", "change-a", Some("bbbb2222"), true, false),
|
||||
("bbbb2222", "change-b", None, false, true),
|
||||
] {
|
||||
catalog.entries.push(Revision {
|
||||
target: RevisionTarget::Commit(id.into()),
|
||||
label: change.into(),
|
||||
description: format!("{change} description"),
|
||||
category: Category::Revisions,
|
||||
});
|
||||
catalog.graph.insert(
|
||||
id.into(),
|
||||
RevisionGraph {
|
||||
change_id: change.into(),
|
||||
description: format!("{change} description"),
|
||||
parents: parent.into_iter().map(str::to_owned).collect(),
|
||||
author: "alice".into(),
|
||||
timestamp: "2026-10-23".into(),
|
||||
bookmarks: if current {
|
||||
"main".into()
|
||||
} else {
|
||||
String::new()
|
||||
},
|
||||
current,
|
||||
immutable,
|
||||
},
|
||||
);
|
||||
}
|
||||
for name in ["main", "topic"] {
|
||||
catalog.entries.push(Revision {
|
||||
target: RevisionTarget::Bookmark {
|
||||
name: name.into(),
|
||||
remote: None,
|
||||
},
|
||||
label: name.into(),
|
||||
description: "change-a aaaa1111 change-a description".into(),
|
||||
category: Category::Bookmarks,
|
||||
});
|
||||
}
|
||||
let mut diff = DiffState::new();
|
||||
diff.take_request();
|
||||
diff.apply_result(1, Ok(crate::diff::Outcome::Catalog(catalog)));
|
||||
diff.handle(Input::Down);
|
||||
diff.handle(Input::Enter);
|
||||
diff.handle(Input::Down);
|
||||
diff.handle(Input::Down);
|
||||
let mut panels = WheelPanels::default();
|
||||
let mut terminal = Terminal::new(ratatui::backend::TestBackend::new(100, 24)).unwrap();
|
||||
render_diff(&mut terminal, &diff, &mut panels);
|
||||
let text = screen_text(&terminal);
|
||||
assert!(text.contains("Choose After"));
|
||||
assert!(text.contains("@"));
|
||||
assert!(text.contains("change-a [Before] alice 2026-10-23 [main] aaaa1111"));
|
||||
assert!(text.contains("change-a description"));
|
||||
assert!(!text.contains("Before:"));
|
||||
let buffer = terminal.backend().buffer();
|
||||
let selected_rows: Vec<_> = (0..buffer.area.height)
|
||||
.filter(|&y| (0..buffer.area.width).any(|x| buffer[(x, y)].bg == Color::Blue))
|
||||
.collect();
|
||||
assert_eq!(selected_rows.len(), 2);
|
||||
assert_eq!(selected_rows[1], selected_rows[0] + 1);
|
||||
let before_row = (0..buffer.area.height)
|
||||
.find(|&y| {
|
||||
(0..buffer.area.width)
|
||||
.map(|x| buffer[(x, y)].symbol())
|
||||
.collect::<String>()
|
||||
.contains("[Before]")
|
||||
})
|
||||
.unwrap();
|
||||
assert!((0..buffer.area.width).all(|x| buffer[(x, before_row)].bg != Color::Blue));
|
||||
for (width, height) in [(44, 12), (20, 8)] {
|
||||
let mut terminal =
|
||||
Terminal::new(ratatui::backend::TestBackend::new(width, height)).unwrap();
|
||||
render_diff(&mut terminal, &diff, &mut panels);
|
||||
let text = screen_text(&terminal);
|
||||
assert!(text.contains("Choose After"));
|
||||
assert!(text.contains("[Before]"));
|
||||
assert!(text.contains("> "));
|
||||
let buffer = terminal.backend().buffer();
|
||||
assert_eq!(
|
||||
(0..height)
|
||||
.filter(|&y| { (0..width).any(|x| buffer[(x, y)].bg == Color::Blue) })
|
||||
.count(),
|
||||
1
|
||||
);
|
||||
}
|
||||
diff.handle(Input::Char('\t'));
|
||||
render_diff(&mut terminal, &diff, &mut panels);
|
||||
let text = screen_text(&terminal);
|
||||
assert!(text.contains("[main] change-a"));
|
||||
assert!(text.contains("[topic] change-a"));
|
||||
assert_eq!(text.matches("change-a description").count(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pull_request_picker_renders_all_rows_without_a_pinned_offset() {
|
||||
use crate::diff::{Category, PullRequestPage, RepoKind, Revision, RevisionTarget};
|
||||
@@ -5383,9 +5513,10 @@ fn floating_fields_use_border_titles_and_inner_horizontal_padding() {
|
||||
let mut terminal = Terminal::new(ratatui::backend::TestBackend::new(80, 12)).unwrap();
|
||||
let workspace = Rect::new(3, 2, 74, 8);
|
||||
let mut panel = Rect::default();
|
||||
let mut cursor = Position::default();
|
||||
terminal
|
||||
.draw(|frame| {
|
||||
panel = draw_floating_input(frame, &editor, workspace).unwrap();
|
||||
(panel, cursor) = draw_floating_input(frame, &editor, workspace).unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(panel.x, workspace.x);
|
||||
@@ -5397,10 +5528,7 @@ fn floating_fields_use_border_titles_and_inner_horizontal_padding() {
|
||||
assert_eq!(buffer[(panel.x + 1, panel.y + 1)].symbol(), " ");
|
||||
assert_eq!(buffer[(panel.x + 2, panel.y + 1)].symbol(), "n");
|
||||
assert_eq!(buffer[(panel.right() - 2, panel.y + 1)].symbol(), " ");
|
||||
assert_eq!(
|
||||
terminal.get_cursor_position().unwrap(),
|
||||
Position::new(panel.x + 8, panel.y + 1)
|
||||
);
|
||||
assert_eq!(cursor, Position::new(panel.x + 8, panel.y + 1));
|
||||
assert_eq!(
|
||||
pane_screen(
|
||||
&terminal,
|
||||
@@ -8558,7 +8686,7 @@ fn native_visual_selection_overrides_selected_review_range_background() {
|
||||
let mut views = BufferViewports::default();
|
||||
let source = render_native_diff(&mut terminal, &mut views, &mut editor);
|
||||
assert_eq!(
|
||||
terminal.backend().buffer()[(source.x, source.y)].bg,
|
||||
terminal.backend().buffer()[(source.x + 1, source.y)].bg,
|
||||
Color::Magenta
|
||||
);
|
||||
editor.handle(Input::Char('v'));
|
||||
@@ -9064,10 +9192,6 @@ fn wrapped_diff_aligns_continuations_and_preserves_native_selection_and_caret()
|
||||
terminal.backend().buffer()[(caret.x, caret.y)].symbol(),
|
||||
"D"
|
||||
);
|
||||
assert_eq!(
|
||||
terminal.backend().buffer()[(caret.x, caret.y)].fg,
|
||||
Color::DarkGray
|
||||
);
|
||||
editor.handle(Input::Char('v'));
|
||||
editor.handle(Input::Home);
|
||||
render_native_diff(&mut terminal, &mut views, &mut editor);
|
||||
@@ -9123,10 +9247,6 @@ fn readonly_diff_panes_render_native_caret_visual_search_and_paired_focus() {
|
||||
terminal.backend().buffer()[(caret.x, caret.y)].symbol(),
|
||||
"f"
|
||||
);
|
||||
assert_eq!(
|
||||
terminal.backend().buffer()[(caret.x, caret.y)].fg,
|
||||
Color::Magenta
|
||||
);
|
||||
editor.handle(Input::Char('v'));
|
||||
editor.handle(Input::Right);
|
||||
render_native_diff(&mut terminal, &mut views, &mut editor);
|
||||
@@ -9140,7 +9260,7 @@ fn readonly_diff_panes_render_native_caret_visual_search_and_paired_focus() {
|
||||
editor.handle(Input::Char('V'));
|
||||
render_native_diff(&mut terminal, &mut views, &mut editor);
|
||||
assert_eq!(
|
||||
terminal.backend().buffer()[(caret.x, caret.y + 1)].bg,
|
||||
terminal.backend().buffer()[(caret.x + 1, caret.y + 1)].bg,
|
||||
Color::Blue
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -9157,11 +9277,11 @@ fn readonly_diff_panes_render_native_caret_visual_search_and_paired_focus() {
|
||||
let searched = render_native_diff(&mut terminal, &mut views, &mut editor);
|
||||
assert!(before.contains(searched));
|
||||
assert_eq!(
|
||||
terminal.backend().buffer()[(searched.x, searched.y)].bg,
|
||||
terminal.backend().buffer()[(searched.x + 1, searched.y)].bg,
|
||||
Color::Yellow
|
||||
);
|
||||
assert_eq!(
|
||||
terminal.backend().buffer()[(searched.x, searched.y)].fg,
|
||||
terminal.backend().buffer()[(searched.x + 1, searched.y)].fg,
|
||||
Color::Black
|
||||
);
|
||||
let before_row = editor
|
||||
@@ -9926,7 +10046,7 @@ fn snippet_highlight_tracks_argument_graphemes_without_filling_the_row() {
|
||||
.unwrap();
|
||||
let buffer = terminal.backend().buffer();
|
||||
// A wide glyph's leading cell owns its terminal style.
|
||||
for x in (0..28).filter(|x| *x != 8) {
|
||||
for x in (0..28).filter(|x| *x != 8 && *x != caret.x) {
|
||||
assert_eq!(
|
||||
buffer[(x, 0)].bg == Color::Blue,
|
||||
selected.contains(&x),
|
||||
@@ -9935,6 +10055,11 @@ fn snippet_highlight_tracks_argument_graphemes_without_filling_the_row() {
|
||||
screen_text(&terminal),
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
buffer[caret].bg,
|
||||
Color::Green,
|
||||
"cursor overrides the snippet selection"
|
||||
);
|
||||
assert_eq!(terminal.get_cursor_position().unwrap(), caret);
|
||||
}
|
||||
editor.handle(Input::Escape);
|
||||
@@ -10504,7 +10629,7 @@ end
|
||||
"T"
|
||||
);
|
||||
assert_eq!(
|
||||
terminal.backend().buffer()[(cursor.x, cursor.y)].fg,
|
||||
terminal.backend().buffer()[(cursor.x - 1, cursor.y)].fg,
|
||||
Color::DarkGray
|
||||
);
|
||||
assert_eq!(fs::read_to_string(target).unwrap(), target_text);
|
||||
@@ -10522,7 +10647,7 @@ fn syntax_tokens_refresh_after_native_edits_and_undo_without_changing_text_on_dr
|
||||
terminal
|
||||
.draw(|frame| viewports.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
assert_eq!(terminal.backend().buffer()[(2, 0)].fg, Color::Yellow);
|
||||
assert_eq!(terminal.backend().buffer()[(3, 0)].fg, Color::Yellow);
|
||||
let revision = editor.text_revision();
|
||||
editor.handle(Input::Right);
|
||||
terminal
|
||||
@@ -10571,7 +10696,7 @@ fn syntax_tokens_refresh_after_native_edits_and_undo_without_changing_text_on_dr
|
||||
("42", Color::Yellow),
|
||||
("\"ok\"", Color::Green),
|
||||
] {
|
||||
let x = 2 + source.find(token).unwrap() as u16;
|
||||
let x = 2 + (source.find(token).unwrap() + token.len() - 1) as u16;
|
||||
assert_eq!(buffer[(x, 0)].fg, color, "{token}");
|
||||
assert_eq!(buffer[(x, 0)].bg, Color::Reset);
|
||||
}
|
||||
@@ -10611,7 +10736,7 @@ fn syntax_continuations_above_viewport_refresh_when_the_opening_line_changes() {
|
||||
"v"
|
||||
);
|
||||
assert_eq!(
|
||||
terminal.backend().buffer()[(caret.x, caret.y)].fg,
|
||||
terminal.backend().buffer()[(caret.x + 1, caret.y)].fg,
|
||||
color,
|
||||
"{name}"
|
||||
);
|
||||
@@ -10626,7 +10751,7 @@ fn syntax_continuations_above_viewport_refresh_when_the_opening_line_changes() {
|
||||
"v"
|
||||
);
|
||||
assert_eq!(
|
||||
terminal.backend().buffer()[(caret.x, caret.y)].fg,
|
||||
terminal.backend().buffer()[(caret.x + 1, caret.y)].fg,
|
||||
Color::Reset,
|
||||
"{name}"
|
||||
);
|
||||
@@ -10635,7 +10760,7 @@ fn syntax_continuations_above_viewport_refresh_when_the_opening_line_changes() {
|
||||
.draw(|frame| viewports.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
terminal.backend().buffer()[(caret.x, caret.y)].fg,
|
||||
terminal.backend().buffer()[(caret.x + 1, caret.y)].fg,
|
||||
color,
|
||||
"{name}"
|
||||
);
|
||||
@@ -10895,7 +11020,7 @@ fn search_visual_selection_and_secondary_carets_override_semantic_foreground() {
|
||||
.unwrap();
|
||||
let found = editor.search_match().unwrap();
|
||||
let y = found.start.row as u16;
|
||||
for x in 4..8 {
|
||||
for x in 5..8 {
|
||||
assert_eq!(terminal.backend().buffer()[(x, y)].fg, Color::Black);
|
||||
assert_eq!(terminal.backend().buffer()[(x, y)].bg, Color::Yellow);
|
||||
assert!(
|
||||
@@ -10908,6 +11033,7 @@ fn search_visual_selection_and_secondary_carets_override_semantic_foreground() {
|
||||
editor.handle(Input::Char('e'));
|
||||
editor.handle(Input::Ctrl('a'));
|
||||
assert_eq!(editor.selection_count(), 3);
|
||||
editor.cursor_config.mode_colors = false;
|
||||
terminal
|
||||
.draw(|frame| viewports.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
@@ -10955,7 +11081,7 @@ fn syntax_redetects_saved_paths_without_text_changes_and_plain_text_keeps_defaul
|
||||
terminal
|
||||
.draw(|frame| viewports.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
assert_eq!(terminal.backend().buffer()[(2, 0)].fg, Color::Magenta);
|
||||
assert_eq!(terminal.backend().buffer()[(3, 0)].fg, Color::Magenta);
|
||||
let revision = editor.text_revision();
|
||||
for name in ["source.vampunknown", "source.txt", "again.rs"] {
|
||||
editor.execute(&format!("w {}", directory.0.join(name).display()));
|
||||
@@ -10964,13 +11090,13 @@ fn syntax_redetects_saved_paths_without_text_changes_and_plain_text_keeps_defaul
|
||||
.draw(|frame| viewports.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
if name.ends_with(".rs") {
|
||||
assert_eq!(terminal.backend().buffer()[(2, 0)].fg, Color::Magenta);
|
||||
assert_eq!(terminal.backend().buffer()[(3, 0)].fg, Color::Magenta);
|
||||
assert_eq!(
|
||||
viewports.syntax[&editor.buffer_id()].language(),
|
||||
Some("Rust")
|
||||
);
|
||||
} else {
|
||||
assert_eq!(terminal.backend().buffer()[(2, 0)].fg, Color::Reset);
|
||||
assert_eq!(terminal.backend().buffer()[(3, 0)].fg, Color::Reset);
|
||||
assert!(viewports.syntax[&editor.buffer_id()].line(0).is_empty());
|
||||
assert!(viewports.syntax[&editor.buffer_id()].language().is_none());
|
||||
}
|
||||
@@ -10989,7 +11115,7 @@ fn syntax_caches_stay_independent_across_buffer_edits_and_retire_closed_ids() {
|
||||
terminal
|
||||
.draw(|frame| viewports.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
assert_eq!(terminal.backend().buffer()[(2, 0)].fg, Color::Yellow);
|
||||
assert_eq!(terminal.backend().buffer()[(3, 0)].fg, Color::Yellow);
|
||||
editor.execute(&format!(
|
||||
"edit {}",
|
||||
directory.file("b.py", "# note").display()
|
||||
@@ -10998,19 +11124,19 @@ fn syntax_caches_stay_independent_across_buffer_edits_and_retire_closed_ids() {
|
||||
terminal
|
||||
.draw(|frame| viewports.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
assert_eq!(terminal.backend().buffer()[(2, 0)].fg, Color::DarkGray);
|
||||
assert_eq!(terminal.backend().buffer()[(3, 0)].fg, Color::DarkGray);
|
||||
editor
|
||||
.apply(vec![crate::editor::Effect::Replace("\"ok\"".into())])
|
||||
.unwrap();
|
||||
terminal
|
||||
.draw(|frame| viewports.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
assert_eq!(terminal.backend().buffer()[(2, 0)].fg, Color::Green);
|
||||
assert_eq!(terminal.backend().buffer()[(3, 0)].fg, Color::Green);
|
||||
editor.execute(&format!("buffer {a_id}"));
|
||||
terminal
|
||||
.draw(|frame| viewports.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
assert_eq!(terminal.backend().buffer()[(2, 0)].fg, Color::Yellow);
|
||||
assert_eq!(terminal.backend().buffer()[(3, 0)].fg, Color::Yellow);
|
||||
assert_eq!(viewports.syntax[&a_id].language(), Some("Rust"));
|
||||
assert_eq!(viewports.syntax[&b_id].language(), Some("Python"));
|
||||
editor.execute(&format!("buffer {b_id}"));
|
||||
@@ -11018,7 +11144,7 @@ fn syntax_caches_stay_independent_across_buffer_edits_and_retire_closed_ids() {
|
||||
terminal
|
||||
.draw(|frame| viewports.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
assert_eq!(terminal.backend().buffer()[(2, 0)].fg, Color::Green);
|
||||
assert_eq!(terminal.backend().buffer()[(3, 0)].fg, Color::Green);
|
||||
assert!(!viewports.syntax.contains_key(&a_id));
|
||||
assert!(!viewports.offsets.contains_key(&a_id));
|
||||
assert_eq!(viewports.syntax.len(), 1);
|
||||
@@ -14348,6 +14474,7 @@ fn status_identifies_active_buffer_and_restored_visual_selection_count() {
|
||||
let b = directory.file("b", "other");
|
||||
let mut editor = Editor::open(Some(a), vec![]).unwrap();
|
||||
editor.set_gutter_style(crate::gutter::GutterStyle::None);
|
||||
editor.cursor_config.mode_colors = false;
|
||||
let a_id = editor.buffer_id();
|
||||
let mut terminal = Terminal::new(ratatui::backend::TestBackend::new(240, 6)).unwrap();
|
||||
let mut viewports = BufferViewports::default();
|
||||
@@ -15160,6 +15287,7 @@ fn tabs_and_wide_graphemes_scroll_in_terminal_cells() {
|
||||
fn selection_set_renders_all_ranges_and_counts_offscreen_targets() {
|
||||
let mut editor = Editor::open(None, vec![]).unwrap();
|
||||
editor.set_gutter_style(crate::gutter::GutterStyle::None);
|
||||
editor.cursor_config.mode_colors = false;
|
||||
editor
|
||||
.apply(vec![crate::editor::Effect::Replace(
|
||||
"界\n界\n界\n界\n界".into(),
|
||||
@@ -15214,25 +15342,28 @@ fn secondary_carets_render_on_empty_lines_and_at_line_end() {
|
||||
let mut terminal = Terminal::new(ratatui::backend::TestBackend::new(48, 5)).unwrap();
|
||||
let (mut top, mut left) = (0, 0);
|
||||
let mut syntax = SyntaxCache::new();
|
||||
terminal
|
||||
.draw(|frame| {
|
||||
draw(
|
||||
frame,
|
||||
&editor,
|
||||
&mut top,
|
||||
&mut left,
|
||||
&mut syntax,
|
||||
&mut DocumentViewport::default(),
|
||||
&mut WheelPanels::default(),
|
||||
)
|
||||
})
|
||||
.unwrap();
|
||||
let buffer = terminal.backend().buffer();
|
||||
for caret in editor.carets() {
|
||||
let x = 2 + display_column(&editor.lines()[caret.row], caret.column) as u16;
|
||||
assert_eq!(buffer[(x, caret.row as u16)].symbol(), " ");
|
||||
if caret != editor.cursor() {
|
||||
assert_eq!(buffer[(x, caret.row as u16)].bg, Color::Magenta);
|
||||
for (enabled, expected) in [(true, Color::Green), (false, Color::Magenta)] {
|
||||
editor.cursor_config.mode_colors = enabled;
|
||||
terminal
|
||||
.draw(|frame| {
|
||||
draw(
|
||||
frame,
|
||||
&editor,
|
||||
&mut top,
|
||||
&mut left,
|
||||
&mut syntax,
|
||||
&mut DocumentViewport::default(),
|
||||
&mut WheelPanels::default(),
|
||||
)
|
||||
})
|
||||
.unwrap();
|
||||
let buffer = terminal.backend().buffer();
|
||||
for caret in editor.carets() {
|
||||
let x = 2 + display_column(&editor.lines()[caret.row], caret.column) as u16;
|
||||
assert_eq!(buffer[(x, caret.row as u16)].symbol(), " ");
|
||||
if caret != editor.cursor() {
|
||||
assert_eq!(buffer[(x, caret.row as u16)].bg, expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
assert_eq!(
|
||||
@@ -15590,6 +15721,121 @@ fn active_search_highlight_uses_display_cells_and_clips_with_horizontal_scroll()
|
||||
assert!(content.contains(terminal.get_cursor_position().unwrap()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn software_cursor_tracks_mode_palette_and_preserves_document_text() {
|
||||
let mut editor = Editor::open(None, vec![]).unwrap();
|
||||
editor
|
||||
.apply(vec![crate::editor::Effect::Replace("hello\n".into())])
|
||||
.unwrap();
|
||||
let mut terminal = Terminal::new(SoftwareCursorBackend(ratatui::backend::TestBackend::new(
|
||||
60, 12,
|
||||
)))
|
||||
.unwrap();
|
||||
let mut views = BufferViewports::default();
|
||||
for (inputs, mode, expected) in [
|
||||
(vec![], Mode::Normal, Color::Cyan),
|
||||
(vec![Input::Char('i')], Mode::Insert, Color::Green),
|
||||
(
|
||||
vec![Input::Escape, Input::Char('v')],
|
||||
Mode::Visual,
|
||||
Color::Magenta,
|
||||
),
|
||||
(
|
||||
vec![Input::Escape, Input::Char(':')],
|
||||
Mode::Command,
|
||||
Color::Yellow,
|
||||
),
|
||||
(
|
||||
vec![Input::Escape, Input::Char('/')],
|
||||
Mode::Search,
|
||||
Color::Blue,
|
||||
),
|
||||
(vec![Input::Escape], Mode::Normal, Color::Cyan),
|
||||
] {
|
||||
for input in inputs {
|
||||
editor.handle(input);
|
||||
}
|
||||
assert_eq!(editor.mode(), mode);
|
||||
terminal
|
||||
.draw(|frame| views.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
let position = if matches!(mode, Mode::Command | Mode::Search) {
|
||||
let panel = views.panels.input.unwrap();
|
||||
Position::new(panel.x + 2, panel.y + 1)
|
||||
} else {
|
||||
views.panels.caret.unwrap().1
|
||||
};
|
||||
assert_eq!(
|
||||
terminal.backend().0.buffer()[position].bg,
|
||||
expected,
|
||||
"{mode}"
|
||||
);
|
||||
assert!(
|
||||
!terminal.backend().0.cursor_visible(),
|
||||
"hardware cursor must stay hidden"
|
||||
);
|
||||
assert_eq!(editor.lines(), &["hello", ""]);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn software_cursor_shapes_preserve_wide_text_and_restore_cells_after_motion() {
|
||||
use crate::cursor::CursorShape;
|
||||
let mut editor = Editor::open(None, vec![]).unwrap();
|
||||
editor
|
||||
.apply(vec![crate::editor::Effect::Replace("界e\u{301}\n".into())])
|
||||
.unwrap();
|
||||
let mut terminal = Terminal::new(SoftwareCursorBackend(ratatui::backend::TestBackend::new(
|
||||
40, 8,
|
||||
)))
|
||||
.unwrap();
|
||||
let mut views = BufferViewports::default();
|
||||
terminal
|
||||
.draw(|frame| views.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
let position = views.panels.cursor.unwrap();
|
||||
let buffer = terminal.backend().0.buffer();
|
||||
assert_eq!(buffer[position].symbol(), "界");
|
||||
assert_eq!(buffer[position].bg, Color::Cyan);
|
||||
|
||||
editor.cursor_config.normal = CursorShape::Bar;
|
||||
terminal
|
||||
.draw(|frame| views.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
assert_eq!(terminal.backend().0.buffer()[position].symbol(), "▏");
|
||||
assert_eq!(terminal.backend().0.buffer()[position].fg, Color::Cyan);
|
||||
editor.handle(Input::Right);
|
||||
terminal
|
||||
.draw(|frame| views.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
assert_eq!(terminal.backend().0.buffer()[position].symbol(), "界");
|
||||
let next = views.panels.cursor.unwrap();
|
||||
assert_eq!(next.x, position.x + 2);
|
||||
assert_eq!(terminal.backend().0.buffer()[next].symbol(), "▏");
|
||||
|
||||
editor.cursor_config.normal = CursorShape::Underline;
|
||||
terminal
|
||||
.draw(|frame| views.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
let buffer = terminal.backend().0.buffer();
|
||||
assert_eq!(buffer[next].symbol(), "e\u{301}");
|
||||
assert!(buffer[next].modifier.contains(Modifier::UNDERLINED));
|
||||
assert_eq!(buffer[next].underline_color, Color::Cyan);
|
||||
assert_eq!(buffer[next].fg, Color::Cyan);
|
||||
|
||||
editor.cursor_config.normal = CursorShape::Block;
|
||||
editor.cursor_config.mode_colors = false;
|
||||
terminal
|
||||
.draw(|frame| views.draw(frame, &mut editor))
|
||||
.unwrap();
|
||||
let buffer = terminal.backend().0.buffer();
|
||||
assert_eq!(buffer[next].symbol(), "e\u{301}");
|
||||
assert!(buffer[next].modifier.contains(Modifier::REVERSED));
|
||||
assert_eq!(buffer[next].bg, Color::Reset);
|
||||
assert_eq!(editor.lines(), &["界e\u{301}", ""]);
|
||||
assert!(!terminal.backend().0.cursor_visible());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn terminal_can_present_previous_frame_while_next_frame_is_computed() {
|
||||
use std::{cell::Cell, rc::Rc};
|
||||
@@ -15621,7 +15867,7 @@ fn terminal_can_present_previous_frame_while_next_frame_is_computed() {
|
||||
synchronized: Rc::clone(&synchronized),
|
||||
};
|
||||
let mut terminal = Terminal::with_options(
|
||||
CrosstermBackend::new(Vec::new()),
|
||||
SoftwareCursorBackend(CrosstermBackend::new(Vec::new())),
|
||||
ratatui::TerminalOptions {
|
||||
viewport: ratatui::Viewport::Fixed(Rect::new(0, 0, 20, 5)),
|
||||
},
|
||||
@@ -15650,7 +15896,7 @@ fn scrolling_never_paints_with_an_exposed_cursor_even_without_synchronized_updat
|
||||
.unwrap();
|
||||
let mut output = Vec::new();
|
||||
let mut terminal = Terminal::with_options(
|
||||
CrosstermBackend::new(Vec::new()),
|
||||
SoftwareCursorBackend(CrosstermBackend::new(Vec::new())),
|
||||
ratatui::TerminalOptions {
|
||||
viewport: ratatui::Viewport::Fixed(Rect::new(0, 0, 20, 5)),
|
||||
},
|
||||
@@ -15701,7 +15947,10 @@ fn scrolling_never_paints_with_an_exposed_cursor_even_without_synchronized_updat
|
||||
x += 1;
|
||||
}
|
||||
}
|
||||
assert!(visible);
|
||||
assert!(
|
||||
!visible,
|
||||
"hardware cursor must stay hidden behind the software cursor"
|
||||
);
|
||||
assert!(!synchronized);
|
||||
for (row, expected) in [(0, "row 0"), (1, "row 1"), (2, "row 2")] {
|
||||
let line = std::str::from_utf8(&screen[row]).unwrap().trim_end();
|
||||
@@ -15734,7 +15983,7 @@ fn terminal_session_scopes_the_callers_panic_hook() {
|
||||
"error" => Err(io::Error::from(io::ErrorKind::BrokenPipe)),
|
||||
"panic" => {
|
||||
let mut terminal = Terminal::with_options(
|
||||
CrosstermBackend::new(Vec::new()),
|
||||
SoftwareCursorBackend(CrosstermBackend::new(Vec::new())),
|
||||
ratatui::TerminalOptions {
|
||||
viewport: ratatui::Viewport::Fixed(Rect::new(0, 0, 20, 5)),
|
||||
},
|
||||
@@ -15952,6 +16201,8 @@ end
|
||||
}
|
||||
}
|
||||
|
||||
// Document-layer checks exclude the final primary-cursor overlay. Complete-frame
|
||||
// cursor and banner checks render through BufferViewports instead.
|
||||
#[cfg(test)]
|
||||
fn draw(
|
||||
frame: &mut Frame,
|
||||
@@ -16163,3 +16414,85 @@ fn shared_shell_status_is_a_separate_segment_left_of_the_battery() {
|
||||
assert!(!top.contains("sle..."));
|
||||
assert!(top.trim_end().ends_with("bat 27%"), "{top}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn both_banners_follow_mode_with_neutral_gaps_even_when_cursor_colors_are_disabled() {
|
||||
let mut editor = Editor::open(None, vec![]).unwrap();
|
||||
editor.execute("tab.new");
|
||||
editor.cursor_config.mode_colors = false;
|
||||
configure_chrome(&mut editor, |top, bottom| {
|
||||
top.left = vec!["tabs".into()];
|
||||
top.center = vec!["path".into()];
|
||||
top.right = vec!["badge".into()];
|
||||
for name in ["tabs", "badge", "path"] {
|
||||
top.segments.insert(
|
||||
name.into(),
|
||||
SegmentConfig {
|
||||
title: match name {
|
||||
"tabs" => "{index}".into(),
|
||||
"path" => "N".into(),
|
||||
_ => String::new(),
|
||||
},
|
||||
padding: usize::from(name != "path"),
|
||||
margin: [1; 2],
|
||||
leading_edge: if name == "path" { "" } else { "<" }.into(),
|
||||
trailing_edge: if name == "path" { "" } else { ">" }.into(),
|
||||
first_leading_edge: None,
|
||||
},
|
||||
);
|
||||
}
|
||||
*bottom = top.clone();
|
||||
});
|
||||
editor.set_label("badge".into(), "B".into()).unwrap();
|
||||
let mut terminal = Terminal::new(ratatui::backend::TestBackend::new(60, 6)).unwrap();
|
||||
let mut syntax = SyntaxCache::new();
|
||||
for (input, mode, accent, foreground) in [
|
||||
(None, Mode::Normal, Color::Cyan, Color::Black),
|
||||
(Some('i'), Mode::Insert, Color::Green, Color::Black),
|
||||
(Some('v'), Mode::Visual, Color::Magenta, Color::Black),
|
||||
(Some(':'), Mode::Command, Color::Yellow, Color::Black),
|
||||
(Some('/'), Mode::Search, Color::Blue, Color::White),
|
||||
(None, Mode::Normal, Color::Cyan, Color::Black),
|
||||
] {
|
||||
editor.handle(Input::Escape);
|
||||
if let Some(ch) = input {
|
||||
editor.handle(Input::Char(ch));
|
||||
}
|
||||
assert_eq!(editor.mode(), mode);
|
||||
terminal
|
||||
.draw(|frame| {
|
||||
let area = frame.area();
|
||||
assert_eq!(
|
||||
draw_bars(frame, &editor, area, &mut syntax),
|
||||
Rect::new(0, 1, 60, 4)
|
||||
);
|
||||
})
|
||||
.unwrap();
|
||||
let buffer = terminal.backend().buffer();
|
||||
for y in [0, 5] {
|
||||
for (x, symbol) in [(9, "2"), (56, "B")] {
|
||||
assert_eq!(buffer[(x, y)].symbol(), symbol, "{mode:?}");
|
||||
}
|
||||
for x in [8, 9, 10, 55, 56, 57] {
|
||||
assert_eq!(buffer[(x, y)].bg, accent, "{mode:?} at {x},{y}");
|
||||
assert_eq!(buffer[(x, y)].fg, foreground, "{mode:?} at {x},{y}");
|
||||
}
|
||||
for (x, symbol) in [(7, "<"), (11, ">"), (54, "<"), (58, ">")] {
|
||||
assert_eq!(buffer[(x, y)].symbol(), symbol);
|
||||
assert_eq!(buffer[(x, y)].fg, accent, "{mode:?} at {x},{y}");
|
||||
assert_eq!(buffer[(x, y)].bg, Color::Reset);
|
||||
}
|
||||
assert_eq!(buffer[(2, y)].symbol(), "1");
|
||||
assert_eq!(buffer[(2, y)].fg, Color::Gray);
|
||||
assert_eq!(buffer[(2, y)].bg, Color::Reset);
|
||||
assert_eq!(buffer[(29, y)].symbol(), "N");
|
||||
assert_eq!(buffer[(29, y)].fg, Color::Reset);
|
||||
assert_eq!(buffer[(29, y)].bg, Color::Reset);
|
||||
for x in [0, 4, 5, 6, 12, 13, 28, 30, 52, 53, 59] {
|
||||
assert_eq!(buffer[(x, y)].symbol(), " ");
|
||||
assert_eq!(buffer[(x, y)].fg, Color::Reset, "{mode:?} at {x},{y}");
|
||||
assert_eq!(buffer[(x, y)].bg, Color::Reset, "{mode:?} at {x},{y}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user