Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data/io.elementary.code.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<li>It is now possible to change Git branch with untracked files present in a project</li>
<li>Crashes are prevented while searching in large projects</li>
<li>The correct document is now focused after opening Code from an external program</li>
<li>Line duplication is now actioned correctly if there is no selection present</li>
</ul>
<p>Minor updates:</p>
<ul>
Expand Down
12 changes: 7 additions & 5 deletions src/Widgets/SourceView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ namespace Scratch.Widgets {

// If selected text does not exists duplicate current line.
// If selected text is only in one line duplicate in place.
// If seected text covers more than one line, duplicate all lines complete.
// If selected text covers more than one line, duplicate all lines complete.
public void duplicate_selection () {
Gtk.TextIter? start = null;
Gtk.TextIter? end = null;
Expand All @@ -357,7 +357,6 @@ namespace Scratch.Widgets {
buffer.get_selection_bounds (out start, out end);
start_line = start.get_line ();
end_line = end.get_line ();

if (start_line != end_line) {
buffer.get_iter_at_line (out start, start_line);
buffer.get_iter_at_line (out end, end_line);
Expand All @@ -370,10 +369,13 @@ namespace Scratch.Widgets {
selection_end_offset = end.get_offset ();
} else {
buffer.get_iter_at_mark (out start, buffer.get_insert ());
start.backward_line (); //To start of previous line
start.forward_line (); //To start of original line
start.backward_chars (start.get_line_offset ());
end = start.copy ();
end.forward_to_line_end ();
end.forward_chars (end.get_chars_in_line ());
if (end.get_line () != start.get_line ()) { // Line lacked final return character
end.backward_char ();
}

selection = "\n" + buffer.get_text (start, end, true);
}

Expand Down