Make lines extend across the entire width of the scroller

This ensures line decorations render properly, even when the content is
narrower than the editor.
This commit is contained in:
Nathan Sobo
2017-03-15 20:35:25 -06:00
committed by Antonio Scandurra
parent 5c7208751f
commit 1427dbf540
2 changed files with 14 additions and 2 deletions

View File

@@ -231,6 +231,15 @@ describe('TextEditorComponent', () => {
expect(lineNumberNodeForScreenRow(component, 1).classList.contains('folded')).toBe(true)
})
it('makes lines at least as wide as the scroller', async () => {
const {component, element, editor} = buildComponent()
const {scroller, gutterContainer} = component.refs
editor.setText('a')
await component.getNextUpdatePromise()
expect(element.querySelector('.line').offsetWidth).toBe(scroller.offsetWidth - gutterContainer.offsetWidth)
})
describe('mini editors', () => {
it('adds the mini attribute', () => {
const {element, editor} = buildComponent({mini: true})
@@ -395,7 +404,7 @@ describe('TextEditorComponent', () => {
it('correctly autoscrolls after inserting a line that exceeds the current content width', async () => {
const {component, element, editor} = buildComponent()
const {scroller} = component.refs
element.style.width = component.getScrollWidth() + 'px'
element.style.width = component.getGutterContainerWidth() + component.measurements.longestLineWidth + 'px'
await component.getNextUpdatePromise()
editor.setCursorScreenPosition([0, Infinity])

View File

@@ -1496,7 +1496,10 @@ class TextEditorComponent {
if (this.getModel().isSoftWrapped()) {
return this.getClientWidth() - this.getGutterContainerWidth()
} else {
return Math.round(this.measurements.longestLineWidth + this.measurements.baseCharacterWidth)
return Math.max(
Math.round(this.measurements.longestLineWidth + this.measurements.baseCharacterWidth),
this.measurements.scrollerWidth - this.getGutterContainerWidth()
)
}
}