11import { ensureTpsLanguage , getTpsLanguageSupport } from "./editor-monaco-tps-language.js" ;
22
33const cssClassPrefix = "po" ;
4- const largeDraftDecorationViewportLinePadding = 24 ;
4+ const largeDraftDecorationViewportLinePadding = 12 ;
55const visibleRangeDecorationCharacterThreshold = 0 ;
66const largeDraftTextNotificationCharacterThreshold = 16000 ;
77const largeDraftTextNotificationDelayMs = 750 ;
@@ -13,6 +13,7 @@ const findMatchClassName = `${cssClassPrefix}-find-match`;
1313const floatingToolbarMinimumTop = 44 ;
1414const floatingToolbarSelectionOffset = 5 ;
1515const hostStates = new WeakMap ( ) ;
16+ const frontMatterEndLineCache = new WeakMap ( ) ;
1617const gutterSelector = ".margin-view-overlays" ;
1718const minimapSelector = ".minimap" ;
1819const numericWpmRegex = / ^ (?< wpm > \d + ) \s * W P M $ / i;
@@ -1234,17 +1235,30 @@ function getDecorationLineRanges(state, model) {
12341235}
12351236
12361237function resolveFrontMatterEndLine ( model ) {
1238+ const versionId = typeof model . getVersionId === "function"
1239+ ? model . getVersionId ( )
1240+ : - 1 ;
1241+ const cached = frontMatterEndLineCache . get ( model ) ;
1242+ if ( cached ?. versionId === versionId ) {
1243+ return cached . endLineNumber ;
1244+ }
1245+
1246+ let endLineNumber = 0 ;
12371247 if ( model . getLineCount ( ) < 2 || model . getLineContent ( 1 ) !== frontMatterDelimiter ) {
1238- return 0 ;
1248+ frontMatterEndLineCache . set ( model , { endLineNumber, versionId } ) ;
1249+ return endLineNumber ;
12391250 }
12401251
1252+ endLineNumber = 1 ;
12411253 for ( let lineNumber = 2 ; lineNumber <= model . getLineCount ( ) ; lineNumber ++ ) {
12421254 if ( model . getLineContent ( lineNumber ) === frontMatterDelimiter ) {
1243- return lineNumber ;
1255+ endLineNumber = lineNumber ;
1256+ break ;
12441257 }
12451258 }
12461259
1247- return 1 ;
1260+ frontMatterEndLineCache . set ( model , { endLineNumber, versionId } ) ;
1261+ return endLineNumber ;
12481262}
12491263
12501264function shouldUseVisibleRangeDecorations ( state ) {
0 commit comments