mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Merge pull request #18087 from atom/aw/gutter-measurement-update
Update soft wrap margins on gutter re-measurement
This commit is contained in:
@@ -2085,6 +2085,26 @@ describe('TextEditorComponent', () => {
|
||||
const bLabels = Array.from(bNumbers, e => e.textContent)
|
||||
expect(bLabels).toEqual(['b - 0', 'b - 1', 'b - 2', 'b - 3', 'b - 4', 'b - 5'])
|
||||
})
|
||||
|
||||
it("updates the editor's soft wrap width when a custom gutter's measurement is available", () => {
|
||||
const {component, element, editor} = buildComponent({
|
||||
lineNumberGutterVisible: false,
|
||||
width: 400,
|
||||
softWrapped: true,
|
||||
attach: false,
|
||||
})
|
||||
const gutter = editor.addGutter({name: 'a', priority: 10})
|
||||
gutter.getElement().style.width = '100px'
|
||||
|
||||
jasmine.attachToDOM(element)
|
||||
|
||||
expect(component.getGutterContainerWidth()).toBe(100)
|
||||
|
||||
// Component client width - gutter container width - vertical scrollbar width
|
||||
const softWrapColumn = Math.floor(
|
||||
(400 - 100 - component.getVerticalScrollbarWidth()) / component.getBaseCharacterWidth())
|
||||
expect(editor.getSoftWrapColumn()).toBe(softWrapColumn)
|
||||
})
|
||||
})
|
||||
|
||||
describe('block decorations', () => {
|
||||
|
||||
@@ -387,8 +387,9 @@ class TextEditorComponent {
|
||||
}
|
||||
|
||||
measureContentDuringUpdateSync () {
|
||||
let gutterDimensionsChanged = false
|
||||
if (this.remeasureGutterDimensions) {
|
||||
this.measureGutterDimensions()
|
||||
gutterDimensionsChanged = this.measureGutterDimensions()
|
||||
this.remeasureGutterDimensions = false
|
||||
}
|
||||
const wasHorizontalScrollbarVisible = (
|
||||
@@ -419,7 +420,7 @@ class TextEditorComponent {
|
||||
this.linesToMeasure.clear()
|
||||
this.measuredContent = true
|
||||
|
||||
return wasHorizontalScrollbarVisible !== isHorizontalScrollbarVisible
|
||||
return gutterDimensionsChanged || wasHorizontalScrollbarVisible !== isHorizontalScrollbarVisible
|
||||
}
|
||||
|
||||
updateSyncAfterMeasuringContent () {
|
||||
|
||||
Reference in New Issue
Block a user