소스 검색

[visual] Only use the first document environment when calculating the preamble (#14343)

GitOrigin-RevId: fc7cb26f2e71bd1142f0269b7b95cacad3cf10a5
Alf Eaton 3 년 전
부모
커밋
c90f4bee62
1개의 변경된 파일과 8개의 추가작업 그리고 2개의 파일을 삭제
  1. 8 2
      services/web/frontend/js/features/source-editor/extensions/visual/atomic-decorations.ts

+ 8 - 2
services/web/frontend/js/features/source-editor/extensions/visual/atomic-decorations.ts

@@ -188,13 +188,19 @@ export const atomicDecorations = (options: Options) => {
       currentOrdinal = ordinalStack.pop() ?? 0
       currentOrdinal = ordinalStack.pop() ?? 0
     }
     }
 
 
+    let seenDocumentEnvironment = false
+
     tree.iterate({
     tree.iterate({
       enter(nodeRef) {
       enter(nodeRef) {
         if (nodeRef.node.type.is('Maketitle')) {
         if (nodeRef.node.type.is('Maketitle')) {
           preamble.to = nodeRef.node.from
           preamble.to = nodeRef.node.from
         } else if (nodeRef.node.type.is('DocumentEnvironment')) {
         } else if (nodeRef.node.type.is('DocumentEnvironment')) {
-          preamble.to =
-            nodeRef.node.getChild('Content')?.from ?? nodeRef.node.from
+          // only count the first instance of DocumentEnvironment
+          if (!seenDocumentEnvironment) {
+            preamble.to =
+              nodeRef.node.getChild('Content')?.from ?? nodeRef.node.from
+            seenDocumentEnvironment = true
+          }
         } else if (nodeRef.node.type.is('Title')) {
         } else if (nodeRef.node.type.is('Title')) {
           const node = nodeRef.node.getChild('TextArgument')
           const node = nodeRef.node.getChild('TextArgument')
           if (node) {
           if (node) {