mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Merge pull request #3583 from Tyriar/3552
Don't include trailing EOL when selecting multiple lines
This commit is contained in:
@@ -122,5 +122,13 @@ describe('SelectionModel', () => {
|
||||
model.selectionEnd = [5, 2];
|
||||
assert.deepEqual(model.finalSelectionEnd, [5, 2]);
|
||||
});
|
||||
it('should not include a trailing EOL when the selection ends at the end of a line', () => {
|
||||
model.selectionStart = [0, 0];
|
||||
model.selectionStartLength = 80;
|
||||
assert.deepEqual(model.finalSelectionEnd, [80, 0]);
|
||||
model.selectionStart = [0, 0];
|
||||
model.selectionStartLength = 160;
|
||||
assert.deepEqual(model.finalSelectionEnd, [80, 1]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -79,6 +79,10 @@ export class SelectionModel {
|
||||
if (!this.selectionEnd || this.areSelectionValuesReversed()) {
|
||||
const startPlusLength = this.selectionStart[0] + this.selectionStartLength;
|
||||
if (startPlusLength > this._bufferService.cols) {
|
||||
// Ensure the trailing EOL isn't included when the selection ends on the right edge
|
||||
if (startPlusLength % this._bufferService.cols === 0) {
|
||||
return [this._bufferService.cols, this.selectionStart[1] + Math.floor(startPlusLength / this._bufferService.cols) - 1];
|
||||
}
|
||||
return [startPlusLength % this._bufferService.cols, this.selectionStart[1] + Math.floor(startPlusLength / this._bufferService.cols)];
|
||||
}
|
||||
return [startPlusLength, this.selectionStart[1]];
|
||||
|
||||
Reference in New Issue
Block a user