Skip to content

Commit

Permalink
Duplicate only current line when cursor is at the end of the line (#649)
Browse files Browse the repository at this point in the history
This fixes issue #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.
  • Loading branch information
Toni Ordning authored Nov 25, 2024
1 parent cf5b735 commit fe08c2c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions xed/xed-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,16 @@ xed_view_duplicate (XedView *view)
{
gtk_text_iter_set_line_index (&start, 0);
gtk_text_iter_forward_to_line_end (&end);

if (gtk_text_buffer_get_line_count (buffer) > 1)
{
gtk_text_iter_assign (&end, &start);
while (gtk_text_iter_get_char (&end) != '\n' &&
!gtk_text_iter_is_end (&end))
{
gtk_text_iter_forward_char (&end);
}
}
}

gtk_text_iter_order (&start, &end);
Expand Down

0 comments on commit fe08c2c

Please sign in to comment.