Skip to content

[diffs/editor] Support moveLineUp and moveLineDown commands#936

Merged
ije merged 3 commits into
beta-1.3from
editor/move-line
Jul 3, 2026
Merged

[diffs/editor] Support moveLineUp and moveLineDown commands#936
ije merged 3 commits into
beta-1.3from
editor/move-line

Conversation

@ije

@ije ije commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator
  • Add moveLineUp and moveLineDown editor commands
  • Shortcuts:
    • Alt + ↑ / Alt +↓
    • Alt + Ctrl + P / Alt + Ctrl + N on macOS and Linux

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pierre-docs-diffs Ready Ready Preview Jul 2, 2026 8:56am
pierre-docs-diffshub Ready Ready Preview Jul 2, 2026 8:56am
pierre-docs-trees Ready Ready Preview Jul 2, 2026 8:56am
pierrejs-diff-demo Ready Ready Preview Jul 2, 2026 8:56am

Request Review

@ije
ije requested review from amadeus and necolas July 2, 2026 08:14
@ije

ije commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 16ea0af81d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/diffs/src/editor/selection.ts Outdated
Comment on lines +1377 to +1379
end: {
line: selection.end.line + direction,
character: selection.end.character,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clamp moved selections at EOF

When a non-empty selection ends at column 0 of the following line, getSelectedLineBlocks deliberately treats that following line as excluded, so moving the block down can be allowed even when the raw selection.end.line is already the last line index. In a file without a trailing newline, selecting line N as {start: N, end: N+1 character 0} and pressing Alt+Down moves the text to the final line but this code sets end.line to lineCount, leaving #selections out of bounds; subsequent rendering/scrolling can't place the caret and later edits normalize the invalid end back onto the last line, collapsing or corrupting the selection.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 1b2a5dd

@ije
ije merged commit 3c77cfa into beta-1.3 Jul 3, 2026
8 checks passed
@ije
ije deleted the editor/move-line branch July 3, 2026 07:45
amadeus pushed a commit that referenced this pull request Jul 21, 2026
* [diffs/editor] Support `moveLineUp` and `moveLineDown` commands

* fix "Clamp moved selections at EOF"

* fix performance: 60ms -> 0.3ms (m4 pro)
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