mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
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:
committed by
Antonio Scandurra
parent
5c7208751f
commit
1427dbf540
@@ -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])
|
||||
|
||||
@@ -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()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user