feat: freeze per-window rendering during minibuffer sessions#8
Merged
Conversation
Completion sessions preview candidate buffers by swapping them into a window (consult, embark). Each swap perturbs a per-window bar -- most visibly a wrap tab-line, which gains the preview buffer as a tab and can re-flow onto a different number of rows, popping taller/shorter as the user moves through candidates. While a minibuffer is active, targets in svg-line-freeze-in-minibuffer (default: tab-line) return the display string last rendered for that window outside a minibuffer, from a window-weak cache; normal rendering resumes the moment the minibuffer closes. A window with no cached render falls through to a live render without poisoning the cache.
There was a problem hiding this comment.
Pull request overview
This PR adds a minibuffer-aware “freeze” mode so selected svg-line targets (default tab-line) can reuse their last pre-minibuffer render per window, preventing UI height reflow during completion preview sessions that temporarily swap buffers into windows.
Changes:
- Introduces
svg-line-freeze-in-minibufferand a weak-key cache (svg-line--freeze-cache) to store the last unfrozen render. - Updates
svg-line--renderto return cached output while a minibuffer is active for configured targets, and to refresh the cache outside minibuffer sessions. - Adds ERT tests covering cached returns, disabled freezing, and uncached-window fallback behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| svg-line.el | Adds minibuffer-freeze customization + cache and wires freeze behavior into svg-line--render. |
| test/svg-line-test.el | Adds tests validating freeze caching behavior and cache miss handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+744
to
+761
| (defcustom svg-line-freeze-in-minibuffer '(tab-line) | ||
| "Targets whose windows keep their last render while a minibuffer is active. | ||
| Completion sessions preview candidate buffers by swapping them into a | ||
| window (consult, embark, ...). Each swap perturbs a per-window bar -- | ||
| most visibly a `wrap' tab-line, which gains the preview buffer as a tab | ||
| and can re-flow onto a different number of rows, so the bar pops taller | ||
| and shorter as the user moves through candidates. While a minibuffer is | ||
| active, a target listed here keeps showing the display string it last | ||
| rendered for that window OUTSIDE the minibuffer; normal rendering | ||
| resumes the moment the minibuffer closes. Set to nil to disable." | ||
| :type '(repeat (choice (const tab-line) (const header-line) | ||
| (const mode-line) (const tab-bar)))) | ||
|
|
||
| (defvar svg-line--freeze-cache (make-hash-table :test 'eq :weakness 'key) | ||
| "WINDOW -> alist of (NAME . DISPLAY-STRING) from the last unfrozen render. | ||
| Weak on the window, so entries die with their windows. Read (instead of | ||
| rendering) while a minibuffer is active for targets in | ||
| `svg-line-freeze-in-minibuffer'; written on every render outside one.") |
Comment on lines
+1394
to
+1413
| (let* ((spec (svg-line--spec name)) | ||
| (freezable (memq (plist-get spec :target) | ||
| svg-line-freeze-in-minibuffer)) | ||
| (win (and freezable (selected-window))) | ||
| (in-mini (and freezable (active-minibuffer-window)))) | ||
| (or (and in-mini win | ||
| (cdr (assq name (gethash win svg-line--freeze-cache)))) | ||
| (let ((str | ||
| (if (eq (or (plist-get spec :layout) 'lines) 'wrap) | ||
| (let ((s (svg-line-display (car (svg-line--build-wrap spec))))) | ||
| (svg-line--store-placements name svg-line--wrap-lh svg-line--wrap-placements) | ||
| ;; the whole wrap line is tabs, so a hand pointer everywhere fits | ||
| (svg-line--interactive s name (and svg-line--wrap-placements t) 'hand)) | ||
| (let ((svg (svg-line--build-lines spec))) | ||
| (svg-line--store-placements name svg-line--lines-lh svg-line--lines-placements) | ||
| ;; a lines bar has large non-interactive gaps, so no global pointer | ||
| (svg-line--interactive (svg-line-display svg) name | ||
| (and svg-line--lines-placements t)))))) | ||
| (when (and win (not in-mini) (window-live-p win)) | ||
| (setf (alist-get name (gethash win svg-line--freeze-cache)) str)) |
Completion previews flip the selected window's buffer on every candidate (original <-> previewed buffer), and a frame-level bar whose segments read the current buffer (buffer name, file icon, modal state) re-rendered with different content on each flip -- alternating images repainting the bar, a visible flash -- while time-driven segments like keycast should stay live. :context-buffer takes a function returning the buffer to make current while evaluating :content (nil or a dead buffer falls through to the render-time buffer). Configs can pin a tab-bar to the buffer the user came from during minibuffer sessions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completion sessions preview candidate buffers by swapping them into a window (consult, embark, …). Each swap perturbs a per-window bar — most visibly a
wraptab-line, which gains the preview buffer as a tab and can re-flow onto a different number of rows, so the bar pops taller and shorter as the user moves through candidates.While a minibuffer is active, targets listed in
svg-line-freeze-in-minibuffer(default:'(tab-line)) return the display string they last rendered for that window outside a minibuffer, from a window-weak cache (svg-line--freeze-cache). Normal rendering resumes the moment the minibuffer closes. A window with no cached render (created mid-session) falls through to a live render without poisoning the cache.Redisplay evaluates a window's format with that window selected, so
selected-windowidentifies the cache slot.Tests
freeze-returns-cached-during-minibuffer: cached string returned eq, content fn not re-called; fresh render + cache refresh afterfreeze-disabled-target-renders-livefreeze-uncached-window-renders-fresh: falls through, does not poison the cacheVerified live
Driving a real consult session with buffer preview: mid-preview the window's tab-line render is
eqto the pre-minibuffer string (no re-flow possible), and post-exit rendering is fresh.Addition:
:context-buffer(second commit)The freeze fixes per-window bars; frame-level bars have the complementary problem: their buffer-dependent segments (buffer name, file icon, modal state, …) read the current buffer, and completion previews flip the selected window's buffer per candidate — so the bar re-rendered with alternating content, repainting as a visible flash (geometry verified constant: 57px throughout reproduction).
:context-buffertakes a function returning the buffer to make current while evaluating:content(nil/dead falls through). A config can pin its tab-bar to the buffer the user came from during minibuffer sessions while time-driven segments (keycast) stay live.Verified live: 24/24 in-session tab-bar content evaluations ran in the pinned buffer, zero flips (previously alternating Minibuf/original/preview contexts).