Преглед на файлове

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

GitOrigin-RevId: 82265c6b0cab1ed3a34343efc5d47648e72dc41e
Alf Eaton преди 3 години
родител
ревизия
9c78422efa
променени са 1 файла, в които са добавени 12 реда и са изтрити 7 реда
  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
           // allow Ace to display document before moving, delay until next tick
           // added delay to make this happen later that gotoStoredPosition in
           // added delay to make this happen later that gotoStoredPosition in
           // CursorPositionManager
           // 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)
+          })
         }
         }
       }
       }