editor: preserve scroll position in code editor when validating

This commit is contained in:
jean-emmanuel 2023-03-10 10:33:18 +01:00
parent e36e4cfdc8
commit 79c67a2bbb
2 changed files with 13 additions and 7 deletions

View file

@ -121,7 +121,10 @@ class CodeEditor {
editor.setValue(input.value)
editor.textarea.osc_input = input
editor.selection.setRange({start:0,end:0})
editor.gotoLine(0)
if (!this.widget || widget.hash !== this.widget.hash) {
// preserve active line if widget is the same
editor.gotoLine(0)
}
editor.removeAllListeners('focus')
this.editor.on('focus', (e)=>{
if (this.middledown) {
@ -192,16 +195,14 @@ class CodeEditor {
field.appendChild(this.helpBtn)
field.appendChild(this.fsBtn)
setTimeout(()=>{
editor.getSession().getUndoManager().reset()
editor.resize()
})
editor.getSession().getUndoManager().reset()
editor.resize()
}
fullscreen() {


this.editor.fullscreen = this.field.classList.toggle('fullscreen')
this.editor.setOptions({maxLines: this.editor.fullscreen ? 0 : 30})
this.field.style.setProperty('--prefix', this.editor.fullscreen ? '"' + this.widget.getProp('id') + '."' : '')