From 79c67a2bbbef02c5d90267fa29f77787f865e176 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 10 Mar 2023 10:33:18 +0100 Subject: [PATCH] editor: preserve scroll position in code editor when validating --- CHANGELOG.md | 7 ++++++- src/client/ui/ui-code-editor.js | 13 +++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a23f3eb..c95ae6bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ - linkId not working between two encoder widgets - fader: `gradient` breakpoints not positioned correctly +- editor + - when focusing the label property with `F2`, select all text in the text area + - preserve scroll position in code editor when validating + + - scripting - expose file browser (from the file widget) as a scripting function @@ -14,7 +19,7 @@ - misc - add polish locales (@ Manz4rk) - - add css classes to some notification popups to allow targetting them with css themes + - add css classes to some notification popups to allow targetting them with css themes ## 1.22.0 diff --git a/src/client/ui/ui-code-editor.js b/src/client/ui/ui-code-editor.js index 498cce06..9b5c0083 100644 --- a/src/client/ui/ui-code-editor.js +++ b/src/client/ui/ui-code-editor.js @@ -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') + '."' : '')