Fix bug when selection end is less than start
This commit is contained in:
@@ -166,15 +166,4 @@ describe('SelectionManager', () => {
|
|||||||
assert.equal(selectionManager.selectionText, '1\n2\n3\n4\n5');
|
assert.equal(selectionManager.selectionText, '1\n2\n3\n4\n5');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('selectionText', () => {
|
|
||||||
it('should return the empty string when start or end selections are not set', () => {
|
|
||||||
assert.equal(selectionManager.selectionText, '');
|
|
||||||
selectionManager.model.selectionStart = [0, 0];
|
|
||||||
assert.equal(selectionManager.selectionText, '');
|
|
||||||
selectionManager.model.selectionStart = null;
|
|
||||||
selectionManager.model.selectionEnd = [0, 0];
|
|
||||||
assert.equal(selectionManager.selectionText, '');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -106,10 +106,6 @@ describe('SelectionManager', () => {
|
|||||||
model.selectionEnd = [1, 2];
|
model.selectionEnd = [1, 2];
|
||||||
assert.equal(model.finalSelectionEnd, null);
|
assert.equal(model.finalSelectionEnd, null);
|
||||||
});
|
});
|
||||||
it('should return null if there is no selection end or selection start length', () => {
|
|
||||||
model.selectionStart = [1, 2];
|
|
||||||
assert.equal(model.finalSelectionEnd, null);
|
|
||||||
});
|
|
||||||
it('should return selection start + length if there is no selection end', () => {
|
it('should return selection start + length if there is no selection end', () => {
|
||||||
model.selectionStart = [2, 2];
|
model.selectionStart = [2, 2];
|
||||||
model.selectionStartLength = 2;
|
model.selectionStartLength = 2;
|
||||||
|
|||||||
@@ -73,9 +73,6 @@ export class SelectionModel {
|
|||||||
|
|
||||||
// Use the selection start if the end doesn't exist or they're reversed
|
// Use the selection start if the end doesn't exist or they're reversed
|
||||||
if (!this.selectionEnd || this._areSelectionValuesReversed()) {
|
if (!this.selectionEnd || this._areSelectionValuesReversed()) {
|
||||||
if (this.selectionStartLength === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return [this.selectionStart[0] + this.selectionStartLength, this.selectionStart[1]];
|
return [this.selectionStart[0] + this.selectionStartLength, this.selectionStart[1]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user