Skip to content

Commit 38fa966

Browse files
committed
restore scroll position affter update code or value
1 parent 68db94c commit 38fa966

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

codemirror.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,19 @@
8888
'code': function(newVal, oldVal) {
8989
const editor_value = this.editor.getValue()
9090
if (newVal !== editor_value) {
91+
let scrollInfo = this.editor.getScrollInfo()
9192
this.editor.setValue(newVal)
9293
this.content = newVal
94+
this.editor.scrollTo(scrollInfo.left, scrollInfo.top)
9395
}
9496
},
9597
'value': function(newVal, oldVal) {
9698
const editor_value = this.editor.getValue()
9799
if (newVal !== editor_value) {
100+
let scrollInfo = this.editor.getScrollInfo()
98101
this.editor.setValue(newVal)
99102
this.content = newVal
103+
this.editor.scrollTo(scrollInfo.left, scrollInfo.top)
100104
}
101105
}
102106
}

0 commit comments

Comments
 (0)