[GH-ISSUE #6500] [Bug] New Line character "\n" is considered in selection #2862

Closed
opened 2026-03-23 21:25:47 +00:00 by mirror · 1 comment
Owner

Originally created by @Ahad-patel on GitHub (Oct 7, 2024).
Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/6500

Bug Description

When the cursor is on the first character of any line, pressing Shift + ← three times will select up to the last character of the previous line. Similarly, when the cursor is on the last character of a line, pressing Shift + → selects from the current line to the first character of the next line. This behavior indicates that newline characters are being included in the selection.

This selection issue affects functionality that uses the editorState.getNodesInSelection function.

How to Reproduce

  1. Add few lines of content
  2. Put curson on any place in between the line, make sure there is one line before or after the current line
  3. Keep on selecting the line using shift + <- or shift + ->
  4. so when you reach the start or end of currrent line press shift + <- or shift + -> accordingly
  5. You will need it to press twice to select the previous line
  6. new line is also considered in the selection

Expected Behavior

New line should not be considered when selecting the line

Operating System

macos

AppFlowy Version(s)

1.7.0

Screenshots

https://github.com/user-attachments/assets/ceecb126-1457-4183-bd99-b355eaeec7be

Additional Context

No response

Originally created by @Ahad-patel on GitHub (Oct 7, 2024). Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/6500 ### Bug Description When the cursor is on the first character of any line, pressing `Shift + ←` three times will select up to the last character of the previous line. Similarly, when the cursor is on the last character of a line, pressing `Shift + →` selects from the current line to the first character of the next line. This behavior indicates that newline characters are being included in the selection. This selection issue affects functionality that uses the `editorState.getNodesInSelection` function. ### How to Reproduce 1. Add few lines of content 2. Put curson on any place in between the line, make sure there is one line before or after the current line 3. Keep on selecting the line using `shift + <-` or `shift + ->` 4. so when you reach the start or end of currrent line press `shift + <-` or `shift + ->` accordingly 5. You will need it to press twice to select the previous line 6. new line is also considered in the selection ### Expected Behavior New line should not be considered when selecting the line ### Operating System macos ### AppFlowy Version(s) 1.7.0 ### Screenshots https://github.com/user-attachments/assets/ceecb126-1457-4183-bd99-b355eaeec7be ### Additional Context _No response_
mirror 2026-03-23 21:25:47 +00:00
  • closed this issue
  • added the
    editor
    label
Author
Owner

@asjqkkkk commented on GitHub (Feb 26, 2025):

Hi @Ahad-patel ,I think it's more appropriate to add a default selection area for empty strings than to skip selecting them. If there are multiple empty lines, skipping the selection of empty strings could cause many unexpected behaviors.

The video below shows the default selection area for empty strings:

https://github.com/user-attachments/assets/7b9886e8-928b-4e93-a0ac-4c3826b8ff00

<!-- gh-comment-id:2683944907 --> @asjqkkkk commented on GitHub (Feb 26, 2025): Hi @Ahad-patel ,I think it's more appropriate to add a default selection area for empty strings than to skip selecting them. If there are multiple empty lines, skipping the selection of empty strings could cause many unexpected behaviors. The video below shows the default selection area for empty strings: https://github.com/user-attachments/assets/7b9886e8-928b-4e93-a0ac-4c3826b8ff00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AppFlowy-IO/AppFlowy#2862
No description provided.