Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CodeMirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Moritz Aurel Pascal Schubotz
CodeMirror
Commits
17977949
Commit
17977949
authored
8 years ago
by
Adrian Heine
Browse files
Options
Downloads
Patches
Plain Diff
Turn addToScrollPos into addToScrollTop
parent
8e860c53
No related branches found
No related tags found
Loading
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/display/scrolling.js
+4
-6
4 additions, 6 deletions
src/display/scrolling.js
src/edit/methods.js
+2
-2
2 additions, 2 deletions
src/edit/methods.js
src/model/line_widget.js
+3
-3
3 additions, 3 deletions
src/model/line_widget.js
with
9 additions
and
11 deletions
src/display/scrolling.js
+
4
−
6
View file @
17977949
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
src/edit/methods.js
+
2
−
2
View file @
17977949
...
@@ -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
{
addToScroll
Pos
,
ensureCursorVisible
,
resolveScrollToPos
,
scrollIntoView
,
scrollToCoordsRange
}
from
"
../display/scrolling
"
import
{
addToScroll
Top
,
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
())
addToScroll
Pos
(
this
,
null
,
charCoords
(
this
,
pos
,
"
div
"
).
top
-
headPos
.
top
)
addToScroll
Top
(
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
++
)
...
...
This diff is collapsed.
Click to expand it.
src/model/line_widget.js
+
3
−
3
View file @
17977949
import
{
runInOp
}
from
"
../display/operations
"
import
{
runInOp
}
from
"
../display/operations
"
import
{
addToScroll
Pos
}
from
"
../display/scrolling
"
import
{
addToScroll
Top
}
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
))
addToScroll
Pos
(
cm
,
null
,
diff
)
addToScroll
Top
(
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
)
addToScroll
Pos
(
cm
,
null
,
widget
.
height
)
if
(
aboveVisible
)
addToScroll
Top
(
cm
,
widget
.
height
)
cm
.
curOp
.
forceUpdate
=
true
cm
.
curOp
.
forceUpdate
=
true
}
}
return
true
return
true
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment