Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 9292fc9

Browse files
author
Antonio Scandurra
committed
Clear rightmost screen position when resetting a display layer
1 parent fc24cf4 commit 9292fc9

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

spec/display-layer-spec.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,24 @@ describe('DisplayLayer', () => {
5454

5555
describe('reset()', () => {
5656
it('updates the screen lines to reflect the new parameters', () => {
57-
const buffer = new TextBuffer({
58-
text: 'abc def\nghi jkl\nmno pqr'
59-
})
60-
57+
const buffer = new TextBuffer({text: 'abc def\nghi jkl\nmno pqr'})
6158
const displayLayer = buffer.addDisplayLayer({})
6259
expect(displayLayer.translateScreenPosition(Point(1, 3))).toEqual(Point(1, 3))
6360

6461
displayLayer.reset({softWrapColumn: 4})
6562
expect(displayLayer.translateScreenPosition(Point(1, 3))).toEqual(Point(0, 7))
6663
})
64+
65+
it('resets the rightmost screen position', () => {
66+
const buffer = new TextBuffer({text: 'abc def\nghi jkl\nmnopqrst'})
67+
const displayLayer = buffer.addDisplayLayer({softWrapColumn: 5})
68+
expect(displayLayer.getApproximateRightmostScreenPosition()).toEqual(Point(0, 0))
69+
expect(displayLayer.getRightmostScreenPosition()).toEqual(Point(4, 5))
70+
71+
displayLayer.reset({softWrapColumn: 4})
72+
expect(displayLayer.getApproximateRightmostScreenPosition()).toEqual(Point(0, 0))
73+
expect(displayLayer.getRightmostScreenPosition()).toEqual(Point(0, 4))
74+
})
6775
})
6876

6977
describe('destroy', function () {

src/display-layer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class DisplayLayer {
128128
this.cachedScreenLines.length = 0
129129
this.screenLineLengths.length = 0
130130
this.tabCounts.length = 0
131+
this.rightmostScreenPosition = Point(0, 0)
131132
}
132133

133134
doBackgroundWork (deadline) {

0 commit comments

Comments
 (0)