From 36acad4d1bd03c5050ac29cfa758fa595a738896 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Fri, 15 Nov 2024 09:03:35 +0000 Subject: [PATCH] Rename $SectioningCommand to $SectioningCtrlSeq or $Section (#21534) GitOrigin-RevId: 5b3173d82ec4c00fe69e2ab059bf48a872a4ca3e --- .../extensions/visual/atomic-decorations.ts | 2 +- .../languages/latex/latex-language.ts | 16 ++++++++-------- .../source-editor/lezer-latex/latex.grammar | 16 ++++++++-------- .../utils/tree-operations/outline.ts | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/services/web/frontend/js/features/source-editor/extensions/visual/atomic-decorations.ts b/services/web/frontend/js/features/source-editor/extensions/visual/atomic-decorations.ts index 75125e9f99..d852c9d77c 100644 --- a/services/web/frontend/js/features/source-editor/extensions/visual/atomic-decorations.ts +++ b/services/web/frontend/js/features/source-editor/extensions/visual/atomic-decorations.ts @@ -548,7 +548,7 @@ export const atomicDecorations = (options: Options) => { break } } - } else if (nodeRef.type.is('$SectioningCommand')) { + } else if (nodeRef.type.is('$SectioningCtrlSeq')) { const ancestorNode = ancestorNodeOfType( state, nodeRef.to, diff --git a/services/web/frontend/js/features/source-editor/languages/latex/latex-language.ts b/services/web/frontend/js/features/source-editor/languages/latex/latex-language.ts index aa19af3497..8e04adcb32 100644 --- a/services/web/frontend/js/features/source-editor/languages/latex/latex-language.ts +++ b/services/web/frontend/js/features/source-editor/languages/latex/latex-language.ts @@ -40,13 +40,13 @@ const Styles = { const typeMap: Record = { // commands that are section headings - PartCtrlSeq: ['$SectioningCommand'], - ChapterCtrlSeq: ['$SectioningCommand'], - SectionCtrlSeq: ['$SectioningCommand'], - SubSectionCtrlSeq: ['$SectioningCommand'], - SubSubSectionCtrlSeq: ['$SectioningCommand'], - ParagraphCtrlSeq: ['$SectioningCommand'], - SubParagraphCtrlSeq: ['$SectioningCommand'], + PartCtrlSeq: ['$SectioningCtrlSeq'], + ChapterCtrlSeq: ['$SectioningCtrlSeq'], + SectionCtrlSeq: ['$SectioningCtrlSeq'], + SubSectionCtrlSeq: ['$SectioningCtrlSeq'], + SubSubSectionCtrlSeq: ['$SectioningCtrlSeq'], + ParagraphCtrlSeq: ['$SectioningCtrlSeq'], + SubParagraphCtrlSeq: ['$SectioningCtrlSeq'], // commands that have a "command tooltip" HrefCommand: ['$CommandTooltipCommand'], Include: ['$CommandTooltipCommand'], @@ -90,7 +90,7 @@ export const LaTeXLanguage = LRLanguage.define({ // enough? For some reason it doesn't work if there's a newline after // \section{a}, but works for \section{a}b $Environment: node => node.getChild('Content'), - $SectioningCommand: node => { + $Section: node => { const BACKWARDS = -1 const lastChild = node.resolveInner(node.to, BACKWARDS) const content = node.getChild('Content') diff --git a/services/web/frontend/js/features/source-editor/lezer-latex/latex.grammar b/services/web/frontend/js/features/source-editor/lezer-latex/latex.grammar index 578ef52bdb..8f9080807c 100644 --- a/services/web/frontend/js/features/source-editor/lezer-latex/latex.grammar +++ b/services/web/frontend/js/features/source-editor/lezer-latex/latex.grammar @@ -480,14 +480,14 @@ SectioningCommand { documentSection { SectioningCommand Content<(sectionText | !section Next)*> } -Book[@isGroup="$SectioningCommand"] { documentSection } -Part[@isGroup="$SectioningCommand"] { documentSection } -Chapter[@isGroup="$SectioningCommand"] { documentSection } -Section[@isGroup="$SectioningCommand"] { documentSection } -SubSection[@isGroup="$SectioningCommand"] { documentSection } -SubSubSection[@isGroup="$SectioningCommand"] { documentSection } -Paragraph[@isGroup="$SectioningCommand"] { documentSection } -SubParagraph[@isGroup="$SectioningCommand"] { SectioningCommand Content } +Book[@isGroup="$Section"] { documentSection } +Part[@isGroup="$Section"] { documentSection } +Chapter[@isGroup="$Section"] { documentSection } +Section[@isGroup="$Section"] { documentSection } +SubSection[@isGroup="$Section"] { documentSection } +SubSubSection[@isGroup="$Section"] { documentSection } +Paragraph[@isGroup="$Section"] { documentSection } +SubParagraph[@isGroup="$Section"] { SectioningCommand Content } sectioningCommand { Book | Part | Chapter | Section | SubSection | SubSubSection | Paragraph | SubParagraph diff --git a/services/web/frontend/js/features/source-editor/utils/tree-operations/outline.ts b/services/web/frontend/js/features/source-editor/utils/tree-operations/outline.ts index b1fda8aa5b..a83d39d01f 100644 --- a/services/web/frontend/js/features/source-editor/utils/tree-operations/outline.ts +++ b/services/web/frontend/js/features/source-editor/utils/tree-operations/outline.ts @@ -149,7 +149,7 @@ export const enterNode = ( return state.doc.sliceString(ctrlSeq.from + 1, ctrlSeq.to) } - const nestingLevel = parent?.type.is('$SectioningCommand') + const nestingLevel = parent?.type.is('$Section') ? getNestingLevel(parent.type.id) : getNestingLevel(getCommandName())