Browse Source

Jump to line after the stored scroll position has been restored (#12324)

GitOrigin-RevId: 82265c6b0cab1ed3a34343efc5d47648e72dc41e
Alf Eaton 3 years ago
parent
commit
9c78422efa
1 changed files with 12 additions and 7 deletions
  1. 12 7
      services/web/frontend/js/ide/editor/EditorManager.js

+ 12 - 7
services/web/frontend/js/ide/editor/EditorManager.js

@@ -281,14 +281,19 @@ export default EditorManager = (function () {
           // allow Ace to display document before moving, delay until next tick
           // added delay to make this happen later that gotoStoredPosition in
           // CursorPositionManager
-          return setTimeout(() => this.jumpToLine(options), 0)
-        } else if (options.gotoOffset != null) {
-          return setTimeout(() => {
-            return this.$scope.$broadcast(
-              'editor:gotoOffset',
-              options.gotoOffset
+          setTimeout(() => this.jumpToLine(options))
+          // when opening a doc in CM6, jump to the line again after a stored scroll position has been restored
+          if (isNewDoc) {
+            window.addEventListener(
+              'editor:scroll-position-restored',
+              () => this.jumpToLine(options),
+              { once: true }
             )
-          }, 0)
+          }
+        } else if (options.gotoOffset != null) {
+          setTimeout(() => {
+            this.$scope.$broadcast('editor:gotoOffset', options.gotoOffset)
+          })
         }
       }