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

Duplicate line duplicates 2 lines when used at end of line #643

Open
PQCraft opened this issue Jun 6, 2024 · 0 comments
Open

Duplicate line duplicates 2 lines when used at end of line #643

PQCraft opened this issue Jun 6, 2024 · 0 comments

Comments

@PQCraft
Copy link

PQCraft commented Jun 6, 2024

 * Xed version - 3.6.0
 * Distribution - Arch

Issue
Pressing Ctrl+Shift+D to duplicate a line works as intended when the cursor is before a char in the line but duplicates the next line too if used at the end.

Steps to reproduce
Cursor before char in line:

 L i n|e   1
 L i n e   2

after ctrl+shift+d

 L i n|e   1
 L i n e   1
 L i n e   2

------
Cursor at end of line:

 L i n e   1|
 L i n e   2

ctrl+shift+d

 L i n e   1|
 L i n e   2
 L i n e   1
 L i n e   2

Expected behaviour
Only the current line should be duplicated.

 L i n e   1|
 L i n e   2

ctrl+shift+d

 L i n e   1|
 L i n e   1
 L i n e   2

Other information
Minor gripe but I think it should also be a single undo to get rid of the duplicated line. Currently, you have to press ctrl+z twice:

 L i n|e   1
 L i n e   2

ctrl+shift+d

 L i n|e   1
 L i n e   1
 L i n e   2

ctrl+z

 L i n e   1
|
 L i n e   2

ctrl+z

 L i n e   1|
 L i n e   2
Toni-Ordning added a commit to Toni-Ordning/xed that referenced this issue Jul 28, 2024
This fixes issue linuxmint#643. When cursor is at the end of the line, old
version would duplicate two lines: The line where the cursor is, and the
line following it. This happened because the buffer that is being copied
would include both lines and the newline separating them. This fix
checks if there are multiple lines in the current buffer, and if so,
moves buffers end iterator to the newline character, so that only the
line where cursor is located is duplicated.
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

No branches or pull requests

1 participant