fix(display): honor pixel-size row offsets - #274
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
It changes redisplay-critical window-text-pixel-size compatibility behavior, including a conditional public return-shape change whose exact GNU Emacs fidelity I could not fully verify, warranting final human review.
Pull request overview
This PR extends the evaluator-backed window-text-pixel-size implementation to honor GNU Emacs's (POSITION . Y-OFFSET) form for the FROM argument. Previously, only the buffer position was consumed and the cdr was merely validated, so callers like Ghostel that pass a pixel offset and expect a (WIDTH HEIGHT START-POSITION) list would hit redisplay errors such as (wrong-type-argument listp (0 . 0)). The change converts a non-zero pixel offset into displayed-screen-row movement (including wrapped rows), reports the adjusted start position, and preserves the legacy (WIDTH . HEIGHT) pair shape for the zero-offset case.
Changes:
window_text_pixel_size_from_posnow returns(EmacsBytePos, Option<i64>), extracting a validated non-zero pixel offset from(POSITION . Y-OFFSET).builtin_window_text_pixel_size_ctxconverts the pixel offset into signed screen-row movement (capped by accessible size), computes the adjusted start via a new helper, and returns a 3-element list when offset reporting is requested.- Adds
screen_line_offset_targetinsymbols.rs, reusing existing forward/backward screen-line motion helpers, plus regression tests for negative, zero, positive, and wrapped-row offsets.
File summaries
| File | Description |
|---|---|
neovm-core/src/emacs_core/xdisp.rs |
Parses (POSITION . Y-OFFSET), maps pixel offset to screen rows, and returns the GNU-compatible (WIDTH HEIGHT START) list. |
neovm-core/src/emacs_core/builtins/symbols.rs |
Adds screen_line_offset_target to move a signed number of displayed screen lines from a position. |
neovm-core/src/emacs_core/xdisp_test.rs |
Adds four regression tests covering offset shapes and wrapped-row counting. |
I verified the row-conversion math (guaranteeing lines is never zero for a non-zero offset), confirmed expect_fixnum_arg prevents the .as_fixnum().expect(...) from panicking, checked that screen_line_offset_target mirrors the existing screen_line_motion_target patterns, confirmed the sole caller of the changed window_text_pixel_size_from_pos signature is updated, and traced the tests against the implementation. I found no concrete objective defects to flag (the only nit, a redundant wid.0 as u64 cast, is non-blocking since neovm-core is not clippy-gated with -D warnings).
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Merged—thank you. I am following up directly on main with GNU-oracle regressions and fixes for partial positive pixel offsets, final unterminated-row motion, TO clipping order, and the shared display-motion seam. I will keep the follow-up scoped to those compatibility and performance issues. |
Issue
window-text-pixel-sizedoes not support GNU Emacs's(POSITION . Y-OFFSET)input and result shape. Ghostel expects this form and otherwise hits redisplay errors such as(wrong-type-argument listp (0 . 0)); the failure is reproducible on Linux as well as Windows.Solution
(POSITION . Y-OFFSET)and preserve the existing pair result for a zero offset.(WIDTH HEIGHT START-POSITION)when offset reporting is requested.Verification
cargo test -p neovm-core --lib window_text_pixel_size_ -- --nocapturepasses (21 tests).cargo fmt --all -- --checkpasses.cargo build -p neomacspasses on Windows.Split from #273 at the maintainer's request.