Skip to content
Snippets Groups Projects
Commit 17977949 authored by Adrian Heine's avatar Adrian Heine
Browse files

Turn addToScrollPos into addToScrollTop

parent 8e860c53
No related branches found
No related tags found
Loading
...@@ -99,12 +99,10 @@ function calculateScrollPos(cm, rect) { ...@@ -99,12 +99,10 @@ function calculateScrollPos(cm, rect) {
// Store a relative adjustment to the scroll position in the current // Store a relative adjustment to the scroll position in the current
// operation (to be applied when the operation finishes). // operation (to be applied when the operation finishes).
export function addToScrollPos(cm, left, top) { export function addToScrollTop(cm, top) {
if (left != null || top != null) resolveScrollToPos(cm) if (top == null) return
if (left != null) resolveScrollToPos(cm)
cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top
if (top != null)
cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top
} }
// Make sure that at the end of the operation the current cursor is // Make sure that at the end of the operation the current cursor is
......
...@@ -14,7 +14,7 @@ import { clipLine, clipPos, equalCursorPos, Pos } from "../line/pos" ...@@ -14,7 +14,7 @@ import { clipLine, clipPos, equalCursorPos, Pos } from "../line/pos"
import { charCoords, charWidth, clearCaches, clearLineMeasurementCache, coordsChar, cursorCoords, displayHeight, displayWidth, estimateLineHeights, fromCoordSystem, intoCoordSystem, scrollGap, textHeight } from "../measurement/position_measurement" import { charCoords, charWidth, clearCaches, clearLineMeasurementCache, coordsChar, cursorCoords, displayHeight, displayWidth, estimateLineHeights, fromCoordSystem, intoCoordSystem, scrollGap, textHeight } from "../measurement/position_measurement"
import { Range } from "../model/selection" import { Range } from "../model/selection"
import { replaceOneSelection, skipAtomic } from "../model/selection_updates" import { replaceOneSelection, skipAtomic } from "../model/selection_updates"
import { addToScrollPos, ensureCursorVisible, resolveScrollToPos, scrollIntoView, scrollToCoordsRange } from "../display/scrolling" import { addToScrollTop, ensureCursorVisible, resolveScrollToPos, scrollIntoView, scrollToCoordsRange } from "../display/scrolling"
import { heightAtLine } from "../line/spans" import { heightAtLine } from "../line/spans"
import { updateGutterSpace } from "../display/update_display" import { updateGutterSpace } from "../display/update_display"
import { indexOf, insertSorted, isWordChar, sel_dontScroll, sel_move } from "../util/misc" import { indexOf, insertSorted, isWordChar, sel_dontScroll, sel_move } from "../util/misc"
...@@ -322,7 +322,7 @@ export default function(CodeMirror) { ...@@ -322,7 +322,7 @@ export default function(CodeMirror) {
goals.push(headPos.left) goals.push(headPos.left)
let pos = findPosV(this, headPos, dir, unit) let pos = findPosV(this, headPos, dir, unit)
if (unit == "page" && range == doc.sel.primary()) if (unit == "page" && range == doc.sel.primary())
addToScrollPos(this, null, charCoords(this, pos, "div").top - headPos.top) addToScrollTop(this, charCoords(this, pos, "div").top - headPos.top)
return pos return pos
}, sel_move) }, sel_move)
if (goals.length) for (let i = 0; i < doc.sel.ranges.length; i++) if (goals.length) for (let i = 0; i < doc.sel.ranges.length; i++)
......
import { runInOp } from "../display/operations" import { runInOp } from "../display/operations"
import { addToScrollPos } from "../display/scrolling" import { addToScrollTop } from "../display/scrolling"
import { regLineChange } from "../display/view_tracking" import { regLineChange } from "../display/view_tracking"
import { heightAtLine, lineIsHidden } from "../line/spans" import { heightAtLine, lineIsHidden } from "../line/spans"
import { lineNo, updateLineHeight } from "../line/utils_line" import { lineNo, updateLineHeight } from "../line/utils_line"
...@@ -53,7 +53,7 @@ eventMixin(LineWidget) ...@@ -53,7 +53,7 @@ eventMixin(LineWidget)
function adjustScrollWhenAboveVisible(cm, line, diff) { function adjustScrollWhenAboveVisible(cm, line, diff) {
if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop)) if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
addToScrollPos(cm, null, diff) addToScrollTop(cm, diff)
} }
export function addLineWidget(doc, handle, node, options) { export function addLineWidget(doc, handle, node, options) {
...@@ -68,7 +68,7 @@ export function addLineWidget(doc, handle, node, options) { ...@@ -68,7 +68,7 @@ export function addLineWidget(doc, handle, node, options) {
if (cm && !lineIsHidden(doc, line)) { if (cm && !lineIsHidden(doc, line)) {
let aboveVisible = heightAtLine(line) < doc.scrollTop let aboveVisible = heightAtLine(line) < doc.scrollTop
updateLineHeight(line, line.height + widgetHeight(widget)) updateLineHeight(line, line.height + widgetHeight(widget))
if (aboveVisible) addToScrollPos(cm, null, widget.height) if (aboveVisible) addToScrollTop(cm, widget.height)
cm.curOp.forceUpdate = true cm.curOp.forceUpdate = true
} }
return true return true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment