11import { heightAtLine } from "../line/spans.js"
22import { getLine , lineAtHeight , updateLineHeight } from "../line/utils_line.js"
3- import { paddingTop , textHeight } from "../measurement/position_measurement.js"
3+ import { paddingTop , textHeight , charWidth } from "../measurement/position_measurement.js"
44import { ie , ie_version } from "../util/browser.js"
55
66// Read the actual heights of the rendered lines, and update their
@@ -9,7 +9,8 @@ export function updateHeightsInViewport(cm) {
99 let display = cm . display
1010 let prevBottom = display . lineDiv . offsetTop
1111 for ( let i = 0 ; i < display . view . length ; i ++ ) {
12- let cur = display . view [ i ] , height
12+ let cur = display . view [ i ] , wrapping = cm . options . lineWrapping
13+ let height , width = 0
1314 if ( cur . hidden ) continue
1415 if ( ie && ie_version < 8 ) {
1516 let bot = cur . node . offsetTop + cur . node . offsetHeight
@@ -18,6 +19,10 @@ export function updateHeightsInViewport(cm) {
1819 } else {
1920 let box = cur . node . getBoundingClientRect ( )
2021 height = box . bottom - box . top
22+ // Check that lines don't extend past the right of the current
23+ // editor width
24+ if ( ! wrapping && cur . text . firstChild )
25+ width = cur . text . firstChild . getBoundingClientRect ( ) . right - box . left - 1
2126 }
2227 let diff = cur . line . height - height
2328 if ( height < 2 ) height = textHeight ( display )
@@ -27,6 +32,14 @@ export function updateHeightsInViewport(cm) {
2732 if ( cur . rest ) for ( let j = 0 ; j < cur . rest . length ; j ++ )
2833 updateWidgetHeight ( cur . rest [ j ] )
2934 }
35+ if ( width > cm . display . sizerWidth ) {
36+ let chWidth = Math . ceil ( width / charWidth ( cm . display ) )
37+ if ( chWidth > cm . display . maxLineLength ) {
38+ cm . display . maxLineLength = chWidth
39+ cm . display . maxLine = cur . line
40+ cm . display . maxLineChanged = true
41+ }
42+ }
3043 }
3144}
3245
0 commit comments