Update buffer-row and screen-row data fields on each line number node

This commit is contained in:
Antonio Scandurra
2017-07-05 11:12:48 +02:00
parent 942dd03bd0
commit bcaf655325
2 changed files with 17 additions and 1 deletions

View File

@@ -685,6 +685,20 @@ describe('TextEditorComponent', () => {
])
}
editor.getBuffer().insert([2, 0], '\n')
await component.getNextUpdatePromise()
{
const bufferRows = Array.from(element.querySelectorAll('.line-number:not(.dummy)')).map((e) => e.dataset.bufferRow)
const screenRows = Array.from(element.querySelectorAll('.line-number:not(.dummy)')).map((e) => e.dataset.screenRow)
expect(bufferRows).toEqual([
'0', '1', '2', '3', '4', '4', '5', '6', '7', '7',
'7', '8', '9', '9', '9', '10', '11', '12', '12', '13'
])
expect(screenRows).toEqual([
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'10', '11', '12', '13', '14', '15', '16', '17', '18', '19'
])
}
})
it('does not blow away class names added to the element by packages when changing the class name', async () => {

View File

@@ -3167,8 +3167,10 @@ class LineNumberComponent {
}
update (props) {
const {nodePool, className, width, marginTop, number} = props
const {nodePool, className, width, marginTop, bufferRow, screenRow, number} = props
if (this.props.bufferRow !== bufferRow) this.element.dataset.bufferRow = bufferRow
if (this.props.screenRow !== screenRow) this.element.dataset.screenRow = screenRow
if (this.props.className !== className) this.element.className = className
if (this.props.width !== width) this.element.style.width = width + 'px'
if (this.props.marginTop !== marginTop) {