From 7fa8c01e319d0044e844e9a06e16ed0618d3935a Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Tue, 5 Nov 2024 11:59:33 +0000 Subject: [PATCH] Disable spell check in setlength arguments (#21491) GitOrigin-RevId: 279f5df7c97b6a6caa5a344bf50b0747402cf61d --- .../source-editor/languages/latex/latex-language.ts | 2 +- .../js/features/source-editor/lezer-latex/latex.grammar | 6 +++++- .../js/features/source-editor/lezer-latex/tokens.mjs | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) 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 7fa86ac275..ffa0b6299c 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 @@ -135,7 +135,7 @@ export const LaTeXLanguage = LRLanguage.define({ ['UsePackage'], ['FigureEnvironment', 'BeginEnv'], ], - ShortTextArgument: [['Date']], + ShortTextArgument: [['Date'], ['SetLengthCommand']], TextArgument: [['TabularEnvironment', 'BeginEnv']], }), // TODO: does this override groups defined in the grammar? 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 f3f21326a8..c9c155deca 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 @@ -107,7 +107,8 @@ TextSubscriptCtrlSeq, TextStrikeOutCtrlSeq, EmphasisCtrlSeq, - UnderlineCtrlSeq + UnderlineCtrlSeq, + SetLengthCtrlSeq } @external specialize {EnvName} specializeEnvName from "./tokens.mjs" { @@ -406,6 +407,9 @@ KnownCommand { } | UnderlineCommand { UnderlineCtrlSeq ArgumentType + } | + SetLengthCommand { + SetLengthCtrlSeq optionalWhitespace? ShortTextArgument optionalWhitespace? ShortTextArgument } } diff --git a/services/web/frontend/js/features/source-editor/lezer-latex/tokens.mjs b/services/web/frontend/js/features/source-editor/lezer-latex/tokens.mjs index 2167923a8d..933f2fc9a9 100644 --- a/services/web/frontend/js/features/source-editor/lezer-latex/tokens.mjs +++ b/services/web/frontend/js/features/source-editor/lezer-latex/tokens.mjs @@ -98,6 +98,7 @@ import { TextStrikeOutCtrlSeq, EmphasisCtrlSeq, UnderlineCtrlSeq, + SetLengthCtrlSeq, } from './latex.terms.mjs' const MAX_ARGUMENT_LOOKAHEAD = 100 @@ -603,6 +604,7 @@ const otherKnowncommands = { '\\sout': TextStrikeOutCtrlSeq, '\\emph': EmphasisCtrlSeq, '\\underline': UnderlineCtrlSeq, + '\\setlength': SetLengthCtrlSeq, } // specializer for control sequences // return new tokens for specific control sequences