Skip to content

Commit

Permalink
TextAction: Duplicate line fix not working for last line in file, clo…
Browse files Browse the repository at this point in the history
  • Loading branch information
Goli4thus authored Mar 28, 2024
1 parent 8c923bd commit 8cce9b5
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -894,8 +894,10 @@ public static void duplicateLineSelection(final HighlightingEditor hlEditor) {
final int[] selEnd = TextViewUtils.getLineOffsetFromIndex(text, sel[1]);

hlEditor.withAutoFormatDisabled(() -> {
final String lines_final = String.format("%s\n", lines);
text.insert(linesEnd + 1, lines_final);
// Prepending the newline instead of appending it is required for making
// this logic work even if it's about the last line in the given file.
final String lines_final = String.format("\n%s", lines);
text.insert(linesEnd, lines_final);
});

final int sel_offset = selEnd[0] - selStart[0] + 1;
Expand Down

0 comments on commit 8cce9b5

Please sign in to comment.