Skip to content

Add the ability to move selected lines up and down #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 2, 2025

Conversation

Bogdan-Belogurov
Copy link
Contributor

Description

This PR introduces two new methods to TextViewController:
moveLinesUp()
moveLinesDown()

These methods allow users to move selected lines of text up or down within the text view.

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

I tested a 50k line file to compare performance in Xcode and CodeEdit.

Xcode CodeEdit
xcode.50k.lines.mov
code.edit.50k.lines.mov

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds the ability to move selected lines of text up or down within the editor via new controller methods, key bindings, and unit tests.

  • Introduces moveLinesUp() and moveLinesDown() in TextViewController with undo grouping and selection updates.
  • Binds Option+Command+[ and Option+Command+] to trigger the new line‐moving actions.
  • Adds unit tests covering single‐line and multi‐line move operations.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
Tests/CodeEditSourceEditorTests/Controller/TextViewController+MoveLinesTests.swift New tests for moving lines up and down in single and multi‐line selections.
Sources/CodeEditSourceEditor/Controller/TextViewController+MoveLines.swift Implements moveLinesUp() and moveLinesDown() with undo grouping.
Sources/CodeEditSourceEditor/Controller/TextViewController+LoadView.swift Adds key bindings for Option+Command+[ and Option+Command+].
Comments suppressed due to low confidence (1)

Tests/CodeEditSourceEditorTests/Controller/TextViewController+MoveLinesTests.swift:1

  • Missing boundary‐condition tests: there are no tests verifying that moving the very first line up or the very last line down is a no-op.
// TextViewController+MoveLinesTests.swift

@thecoolwinter
Copy link
Collaborator

Awesome work, thank you!!

@thecoolwinter thecoolwinter merged commit 162f3d8 into CodeEditApp:main Jun 2, 2025
2 checks passed
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