Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@ public String getSelectedText(int selX1, int selY1, int selX2, int selY2, boolea
if (rowLineWrap && x2 == columns) {
// If the line was wrapped, we shouldn't lose trailing space:
lastPrintingCharIndex = x2Index - 1;
// Keep trailing spaces for wrapped lines, except for the synthetic
// blank that can appear when a double-width character wraps at the
// last available column.

if (lastPrintingCharIndex >= x1Index && line[lastPrintingCharIndex] == ' ') {
int prevPrintingCharIndex = lastPrintingCharIndex - 1;
int prevCodePointIndex = Character.isLowSurrogate(line[prevPrintingCharIndex]) ? prevPrintingCharIndex - 1 : prevPrintingCharIndex;
if (prevCodePointIndex >= x1Index && WcWidth.width(Character.codePointAt(line, prevCodePointIndex)) == 2) {
// Only trim if the double-width char starts at the last column.
// This is when the terminal inserts a synthetic trailing blank.
int colOfPrev = lineObject.findStartOfColumn(columns - 1);
if (colOfPrev == prevPrintingCharIndex) {
lastPrintingCharIndex--;
}
}
}
} else {
for (i = x1Index; i < x2Index; ++i) {
char c = line[i];
Expand Down