feat: commit info overlay with m key#103
Conversation
|
@dlvhdr I was wondering if this makes more sense to added in the Header instead of the Footer? The message is also shown when we are at Btw, the scrollbar is visible in this overlay, maybe we can do something similar in the right panel to see where we are or if there are more data below. |
|
In the Header I was thinking to put something like a navigation between commits: Maybe also something to indicate in which worktree you are, but not sure if all this makes sense for diffnav, it will start to get close to |
Add a floating overlay (toggled with m key) that shows the commit preamble (hash, author, date, message) and file list with status indicators (A/D/R/C/M) when diffnav is used as a pager for git show or tig. The commit subject also appears in the footer bar and is clickable to open the overlay. Does nothing for plain diffs without commit metadata.
Use a viewport for the message overlay so long content (many files or lengthy commit messages) can be scrolled with mouse wheel, j/k, up/down, and ctrl+d/ctrl+u. The overlay height is capped at half the terminal and resizes with the window.
Clicking outside the help or message overlay now closes it. Clicks inside the overlay are consumed, and mouse scroll still works for the message overlay.
Clicking a file name in the message overlay navigates to that file in the file tree, shows its diff, and closes the overlay.
Clicking anywhere on the footer bar (except the F1/? help label) now opens the commit info overlay when a preamble is available.
Show a scrollbar on the right side of the message overlay when the content overflows. The thumb size and position reflect the visible portion and scroll offset.
Fix overlayBounds to use rendered (styled) dimensions instead of content dimensions, matching View()'s centering logic. This fixes click-outside detection being misaligned by border+padding offsets, and also accounts for the scrollbar width when visible. Also use scrollLines constant instead of hardcoded 3 for mouse wheel scroll in the message overlay.
Display commit hash, abbreviated author, and subject in the header bar (DIFFNAV • hash author • subject). Clicking the header opens the commit info overlay. Remove file listing from overlay and footer clickability.
Use gruvbox colors from tig for commit hash (132), date (172), author (109), and branch ref (072). Detect branch at startup via git rev-parse. Fix zone constant alignment.
- Use utils.TruncateString for UTF-8 safe subject truncation - Fix overlay centering to use rendered (post-border) width - Block non-left-click mouse events while overlay is open - Prefer preamble branch decoration over git rev-parse fallback - Use rune-safe author initial extraction
…name" This reverts commit 2312493.
- Move resolveBranch to standalone function called in fetchFileTree (async tea.Cmd) instead of synchronously in Update - Deduplicate overlay rendering: extract overlayStyle(), renderOverlay(), and messageViewContent() shared by View() and handleMouse() - Cache parseCommitMeta result on model instead of re-parsing every render frame - Strip +/* prefixes from git branch --points-at output - Remove branch field from commitMeta (now resolved separately)
- Split overlay scroll cases: arrows scroll 1 line, ctrl+d/u scroll half a page to match vim convention - Pass full commit hash to git branch --points-at instead of truncating to 7 chars - Update stale comment about ctrl+d/u routing
…idth for truncation - Clamp overlay row/col to zero to prevent negative coordinates on small terminals - Move GotoTop() out of updateMessageVp() into the two open-overlay call sites so resize doesn't reset scroll position - Use runewidth.StringWidth instead of len() in TruncateString guard to correctly handle non-ASCII characters
|
@dlvhdr PTAL |
m key
Yeah definitely up for chatting about it. Also recommend joining the discord server, there are other folks there that can chime in. I love tig btw. Maybe we should turn diffnav into a modern tig :) |
- Extract viewHeader() from View() for readability - Return overlayResult struct from renderOverlay() instead of 5 values - Wrap long lines in overlay viewport instead of truncating - Use GetVerticalFrameSize() instead of hardcoded border/padding math - Add nerdfont branch icon with ASCII/Unicode fallback - Fix scrollbar thumb staying at top after small scroll
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [dlvhdr/diffnav](https://github.com/dlvhdr/diffnav) | minor | `v0.10.0` → `v0.11.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>dlvhdr/diffnav (dlvhdr/diffnav)</summary> ### [`v0.11.0`](https://github.com/dlvhdr/diffnav/releases/tag/v0.11.0) [Compare Source](dlvhdr/diffnav@v0.10.0...v0.11.0) ### v0.11.0 #### Notable Features - Search (accessed via <kbd>t</kbd>) now shows the filename first and has icons - <kbd>n/p/N</kbd> is used to navigate to next/previous file - If used with `git show`, and there's a commit preamble present, pressing <kbd>m</kbd> will show the commit info. It's also shown in the header - There's finally a scrollbar in the diffview - Thanks to new contributor [@​vertti](https://github.com/vertti) `diffnav` now supports a `watch` flag which will run `git diff` by default (but can be controlled). It will run the command while maintaining the UI state Once again, thanks to [@​pablospe](https://github.com/pablospe) for his awesome contributions! #### Changelog - [`0957bb1`](dlvhdr/diffnav@0957bb1) chore: upgrade deps ([#​114](dlvhdr/diffnav#114)) - [`4a31deb`](dlvhdr/diffnav@4a31deb) ci: add basic CI workflow ([#​113](dlvhdr/diffnav#113)) - [`dc735a5`](dlvhdr/diffnav@dc735a5) feat(search): show filename first + icons ([#​105](dlvhdr/diffnav#105)) - [`822adc6`](dlvhdr/diffnav@822adc6) feat: Add shift+tab as alias for tab to switch panels ([#​109](dlvhdr/diffnav#109)) - [`41f1c16`](dlvhdr/diffnav@41f1c16) feat: add F1 key to toggle help overlay ([#​101](dlvhdr/diffnav#101)) - [`c899b9e`](dlvhdr/diffnav@c899b9e) feat: add n (next file) and p/N (previous file) shortcuts to jump between files ([#​98](dlvhdr/diffnav#98)) - [`e651360`](dlvhdr/diffnav@e651360) feat: add scrollbar to diff viewer ([#​112](dlvhdr/diffnav#112)) - [`e616b2a`](dlvhdr/diffnav@e616b2a) feat: add watch mode for auto-refreshing diffs ([#​96](dlvhdr/diffnav#96)) - [`19503d8`](dlvhdr/diffnav@19503d8) feat: commit info overlay with `m` key ([#​103](dlvhdr/diffnav#103)) - [`e215560`](dlvhdr/diffnav@e215560) feat: show commit info when used as a pager for git show ([#​97](dlvhdr/diffnav#97)) - [`2898ff7`](dlvhdr/diffnav@2898ff7) fix: sidebar search crashes ([#​95](dlvhdr/diffnav#95)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My44OS42IiwidXBkYXRlZEluVmVyIjoiNDMuODkuNiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6Om1pbm9yIl19-->
Summary
mkey to open a floating overlay showing the full commit preamble (hash, author, date, message body)DIFFNAV • hash date author • [branch] subjectgit branch --points-atfor any commit