Skip to content
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

when execute editor::CutToEndOfLine action in the end of line, zed delete the entire line. #19816

Open
opsnull opened this issue Oct 28, 2024 · 1 comment
Labels
editor Feedback for code editing, formatting, editor iterations, etc reproducible Verified steps to reproduce included

Comments

@opsnull
Copy link

opsnull commented Oct 28, 2024

Summary

When execute the editor::CutToEndOfLine action at the end of line, it deletes the line you are on (to the left of the cursor) instead of the newline (to the right of cursor).

"editor::CutToEndOfLine" is a cut operation command. It should only cut content from the cursor position to the end of the line. Not delete the entire line.

This also impacts editor: kill ring cut

Oct-28-2024 12-38-31

suggest:

  1. Only cut text from cursor position to the end of line
  2. Preserve text before the cursor
  3. Maintain the line's existence (don't delete the line break)

Environment

Zed: v0.160.0 (Zed Dev ffe36c9)
OS: macOS 15.0.1
Memory: 18 GiB
Architecture: aarch64

@opsnull opsnull added admin read bug [core label] labels Oct 28, 2024
@opsnull opsnull changed the title When execute editor::CutToEndOfLine action in the end of line, it delete the entire line. when execute editor::CutToEndOfLine action in the end of line, zed delete the entire line. Oct 28, 2024
@JosephTLyons JosephTLyons added editor Feedback for code editing, formatting, editor iterations, etc and removed triage labels Nov 1, 2024
@jinschoi
Copy link

jinschoi commented Jan 12, 2025

Editor::cut_to_end_of_line looks just like delete_to_end_of_line which immediately precedes it, which works as expected. cut_to_end_of_line ends up calling cut_common(), which cuts the entire line if the selection is empty, which it is when the cursor is already at the end of the line. delete_to_end_of_line ends up calling delete(), which has some code to deal with the cursor being at the end of the line: it adjusts the selection to advance the end of the selection by one. Perhaps adding a similar test to either cut_to_end_of_line() or cut_common() will fix this issue, depending on whether a cut with an empty selection is intended behavior or not?

@jinschoi jinschoi mentioned this issue Jan 14, 2025
1 task
@devzeth devzeth added the reproducible Verified steps to reproduce included label Feb 20, 2025
@devzeth devzeth marked this as a duplicate of #5210 Feb 20, 2025
@notpeter notpeter removed the bug [core label] label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor Feedback for code editing, formatting, editor iterations, etc reproducible Verified steps to reproduce included
Projects
None yet
Development

No branches or pull requests

5 participants