Skip to content

fix(editor): preserve viewport during non-wrapped screen-line motion - #415

Merged
fcoury merged 2 commits into
mainfrom
fcoury/nowrap-screen-line-scroll
Oct 21, 2026
Merged

fcoury merged 2 commits into
mainfrom
fcoury/nowrap-screen-line-scroll

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

When j/k are mapped to MoveScreenLineDown/MoveScreenLineUp, disabling wrapping makes each movement scroll the document while keeping the cursor on the same screen row. With scrolloff = 3, moving from line 30 to 31 scrolls the first visible line from 27 to 28. The old implementation also restricts destinations to rows already in the viewport.

Resolve non-wrapped destinations from buffer lines and use the existing cursor-reveal policy, so movement preserves the viewport until the cursor reaches its scroll margin and can continue past either viewport edge. Wrapped movement keeps its existing implementation.

Add a regression in tests/movement.rs comparing screen-line and ordinary vertical movement through a long document in both directions, including file boundaries and scrolloff values of 0 and 3.

How to Test

  1. Open a document longer than the viewport with wrap = false, scrolloff = 3, and normal-mode j/k mapped to MoveScreenLineDown/MoveScreenLineUp. Press j repeatedly: the cursor should move down the screen, with scrolling starting only at the bottom margin. Reverse with k and expect the same behavior at the top margin.
  2. Repeat with scrolloff = 0. Movement should cross both viewport edges and reach the beginning/end of the file without getting stuck. Enable wrapping and verify gj/gk still move through wrapped segments.
  3. Run cargo test --test movement and cargo clippy --all-targets --all-features -- -D warnings.

Validation: reproduced the original issue interactively on installed Red 0.9.1 and confirmed ordinary MoveDown does not exhibit it. git diff --check passes. The new regression and Clippy are blocked before compilation because the configured dependency registry does not provide the existing locked zip 9.0.4 dependency (it offers versions through 9.0.3). The fix has not yet been built or smoke-tested.

@fcoury

fcoury commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T02:56:52.367565Z 574b981 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 574b98193d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fcoury
fcoury merged commit 9f88d50 into main Oct 21, 2026
12 checks passed
@fcoury
fcoury deleted the fcoury/nowrap-screen-line-scroll branch October 21, 2026 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants