src/vs/editor/common/services/findSectionHeaders.ts

181 LOC · 148 covered · 33 uncovered · 11 ranges · 43 concepts · 4 introducers · 30 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the fileeditorWebWorker.test|title=EditorWebWorker [Bug] Getting Message "Overlapping ranges are not allowed" and nothing happens with Inline-Chat|occurrence=1 · 0 introduced LOCeditorWebWorker.test|tit…editorWebWorker.test|title=EditorWebWorker computeHumanReadableDiff 2|occurrence=1 · 0 introduced LOCeditorWebWorker.test|tit…editorWebWorker.test|title=EditorWebWorker computeHumanReadableDiff 4|occurrence=1 · 0 introduced LOCeditorWebWorker.test|tit…editorWebWorker.ts ×1 · 1 introduced LOCeditorWebWorker.ts ×1editorWebWorker.test|title=EditorWebWorker computeHumanReadableDiff 3|occurrence=1 · 0 introduced LOCeditorWebWorker.test|tit…textModelSync.impl.ts ×1 · 3 introduced LOCtextModelSync.impl.ts ×1editorWebWorker.ts ×3 · 14 introduced LOCeditorWebWorker.ts ×3editorWebWorker.test|title=EditorWebWorker MoreMinimal, issue #15385 newline changes and other|occurrence=1 · 0 introduced LOCeditorWebWorker.test|tit…editorWebWorker.test|title=EditorWebWorker MoreMinimal|occurrence=1 · 0 introduced LOCeditorWebWorker.test|tit…2|occurrence=1 · 0 introduced LOC2|occurrence=1editorWebWorker.ts ×2 · 23 introduced LOCeditorWebWorker.ts ×2editorWebWorker.ts ×1 · 2 introduced LOCeditorWebWorker.ts ×1editorWebWorker.ts ×1 · 4 introduced LOCeditorWebWorker.ts ×1editorWebWorker.ts ×11 · 67 introduced LOCeditorWebWorker.ts ×11editorWebWorker.ts ×1 · 3 introduced LOCeditorWebWorker.ts ×1editorWebWorker.ts ×8 · 29 introduced LOCeditorWebWorker.ts ×8textModelSync.impl.ts ×1 · 2 introduced LOCtextModelSync.impl.ts ×1textModelSync.impl.ts ×2 · 11 introduced LOCtextModelSync.impl.ts ×2textModelSync.impl.ts ×1 · 2 introduced LOCtextModelSync.impl.ts ×1textModelSync.impl.ts ×1 · 2 introduced LOCtextModelSync.impl.ts ×1editorWebWorker.ts ×3 · 20 introduced LOCeditorWebWorker.ts ×3editorWebWorker.test|title=EditorWebWorker ICommonModel#offsetAt|occurrence=1 · 0 introduced LOCeditorWebWorker.test|tit…textModelSync.impl.ts ×1 · 2 introduced LOCtextModelSync.impl.ts ×1editorWebWorker.test|title=EditorWebWorker ICommonModel#positionAt|occurrence=1 · 0 introduced LOCeditorWebWorker.test|tit…textModelSync.impl.ts ×1 · 13 introduced LOCtextModelSync.impl.ts ×1editorWebWorker.test|title=EditorWebWorker ICommonModel#getValueInRange, issue #17424|occurrence=1 · 0 introduced LOCeditorWebWorker.test|tit…prefixSumComputer.ts ×1 · 2 introduced LOCprefixSumComputer.ts ×1textModelSync.impl.ts ×1 · 8 introduced LOCtextModelSync.impl.ts ×1textModelSync.impl.ts ×1 · 2 introduced LOCtextModelSync.impl.ts ×1textModelSync.impl.ts ×1 · 4 introduced LOCtextModelSync.impl.ts ×1textModelSync.impl.ts ×4 · 13 introduced LOCtextModelSync.impl.ts ×4textModelSync.impl.ts ×1 · 4 introduced LOCtextModelSync.impl.ts ×1textModelSync.impl.ts ×1 · 2 introduced LOCtextModelSync.impl.ts ×1textModelSync.impl.ts ×7 · 22 introduced LOCtextModelSync.impl.ts ×7textModelSync.impl.ts ×3 · 41 introduced LOCtextModelSync.impl.ts ×3mirrorTextModel.ts ×1 · 10 introduced LOCmirrorTextModel.ts ×1textModelSync.impl.ts ×28 · 1416 introduced LOCtextModelSync.impl.ts ×2…findSectionHeaders.test|title=FindSectionHeaders finds simple section headers|occurrence=1, findSectionHeaders.test|title=FindSectionHeaders finds section headers with separators|occurrence=1 · 0 introduced LOCfindSectionHeaders.test|…findSectionHeaders.test|title=FindSectionHeaders handles nested separators correctly|occurrence=1, findSectionHeaders.test|title=FindSectionHeaders handles section headers at chunk boundaries|occurrence=1, +8 · 0 introduced LOCfindSectionHeaders.test|…findSectionHeaders.ts ×2 · 71 introduced LOCfindSectionHeaders.ts ×2findSectionHeaders.ts ×1 · 2 introduced LOCfindSectionHeaders.ts ×1findSectionHeaders.ts ×4 · 17 introduced LOCfindSectionHeaders.ts ×4findSectionHeaders.ts ×4 · 58 introduced LOCfindSectionHeaders.ts ×4editorWebWorker.test|title=EditorWebWorker ICommonModel#getValueInRange, issue #17424|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/editorWebWorker.test|title=EditorWebWorker ICommonModel#getValueInRange, issue #17424|occurrence=1editorWebWorker.test|tit…editorWebWorker.test|title=EditorWebWorker ICommonModel#offsetAt|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/editorWebWorker.test|title=EditorWebWorker ICommonModel#offsetAt|occurrence=1editorWebWorker.test|tit…editorWebWorker.test|title=EditorWebWorker ICommonModel#positionAt|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/editorWebWorker.test|title=EditorWebWorker ICommonModel#positionAt|occurrence=1editorWebWorker.test|tit…editorWebWorker.test|title=EditorWebWorker ICommonModel#validatePosition, issue #15882|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/editorWebWorker.test|title=EditorWebWorker ICommonModel#validatePosition, issue #15882|occurrence=1editorWebWorker.test|tit…2|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/editorWebWorker.test|title=EditorWebWorker MoreMinimal, issue #15385 newline changes and other 2/2|occurrence=12|occurrence=1editorWebWorker.test|title=EditorWebWorker MoreMinimal, issue #15385 newline changes and other|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/editorWebWorker.test|title=EditorWebWorker MoreMinimal, issue #15385 newline changes and other|occurrence=1editorWebWorker.test|tit…editorWebWorker.test|title=EditorWebWorker MoreMinimal, issue #15385 newline changes only|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/editorWebWorker.test|title=EditorWebWorker MoreMinimal, issue #15385 newline changes only|occurrence=1editorWebWorker.test|tit…editorWebWorker.test|title=EditorWebWorker MoreMinimal, merge adjacent edits|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/editorWebWorker.test|title=EditorWebWorker MoreMinimal, merge adjacent edits|occurrence=1editorWebWorker.test|tit…editorWebWorker.test|title=EditorWebWorker MoreMinimal|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/editorWebWorker.test|title=EditorWebWorker MoreMinimal|occurrence=1editorWebWorker.test|tit…editorWebWorker.test|title=EditorWebWorker [Bug] Getting Message "Overlapping ranges are not allowed" and nothing happens with Inline-Chat|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/editorWebWorker.test|title=EditorWebWorker [Bug] Getting Message "Overlapping ranges are not allowed" and nothing happens with Inline-Chat|occurrence=1editorWebWorker.test|tit…editorWebWorker.test|title=EditorWebWorker computeHumanReadableDiff 1|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/editorWebWorker.test|title=EditorWebWorker computeHumanReadableDiff 1|occurrence=1editorWebWorker.test|tit…editorWebWorker.test|title=EditorWebWorker computeHumanReadableDiff 2|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/editorWebWorker.test|title=EditorWebWorker computeHumanReadableDiff 2|occurrence=1editorWebWorker.test|tit…editorWebWorker.test|title=EditorWebWorker computeHumanReadableDiff 3|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/editorWebWorker.test|title=EditorWebWorker computeHumanReadableDiff 3|occurrence=1editorWebWorker.test|tit…editorWebWorker.test|title=EditorWebWorker computeHumanReadableDiff 4|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/editorWebWorker.test|title=EditorWebWorker computeHumanReadableDiff 4|occurrence=1editorWebWorker.test|tit…editorWebWorker.test|title=EditorWebWorker get words via iterator, issue #46930|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/editorWebWorker.test|title=EditorWebWorker get words via iterator, issue #46930|occurrence=1editorWebWorker.test|tit…editorWebWorker.test|title=EditorWebWorker textualSuggest, issue #17785|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/editorWebWorker.test|title=EditorWebWorker textualSuggest, issue #17785|occurrence=1editorWebWorker.test|tit…findSectionHeaders.test|title=FindSectionHeaders correctly advances past matches without infinite loop|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/findSectionHeaders.test|title=FindSectionHeaders correctly advances past matches without infinite loop|occurrence=1findSectionHeaders.test|…findSectionHeaders.test|title=FindSectionHeaders finds multi-line section headers with separators|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/findSectionHeaders.test|title=FindSectionHeaders finds multi-line section headers with separators|occurrence=1findSectionHeaders.test|…findSectionHeaders.test|title=FindSectionHeaders finds section headers with separators|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/findSectionHeaders.test|title=FindSectionHeaders finds section headers with separators|occurrence=1findSectionHeaders.test|…findSectionHeaders.test|title=FindSectionHeaders finds simple section headers|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/findSectionHeaders.test|title=FindSectionHeaders finds simple section headers|occurrence=1findSectionHeaders.test|…findSectionHeaders.test|title=FindSectionHeaders handles consecutive section headers correctly|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/findSectionHeaders.test|title=FindSectionHeaders handles consecutive section headers correctly|occurrence=1findSectionHeaders.test|…findSectionHeaders.test|title=FindSectionHeaders handles empty regex gracefully without infinite loop|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/findSectionHeaders.test|title=FindSectionHeaders handles empty regex gracefully without infinite loop|occurrence=1findSectionHeaders.test|…findSectionHeaders.test|title=FindSectionHeaders handles nested separators correctly|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/findSectionHeaders.test|title=FindSectionHeaders handles nested separators correctly|occurrence=1findSectionHeaders.test|…findSectionHeaders.test|title=FindSectionHeaders handles overlapping multi-line section headers correctly|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/findSectionHeaders.test|title=FindSectionHeaders handles overlapping multi-line section headers correctly|occurrence=1findSectionHeaders.test|…findSectionHeaders.test|title=FindSectionHeaders handles overlapping section headers without duplicates|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/findSectionHeaders.test|title=FindSectionHeaders handles overlapping section headers without duplicates|occurrence=1findSectionHeaders.test|…findSectionHeaders.test|title=FindSectionHeaders handles partially overlapping multiline section headers correctly|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/findSectionHeaders.test|title=FindSectionHeaders handles partially overlapping multiline section headers correctly|occurrence=1findSectionHeaders.test|…findSectionHeaders.test|title=FindSectionHeaders handles section headers at chunk boundaries correctly|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/findSectionHeaders.test|title=FindSectionHeaders handles section headers at chunk boundaries correctly|occurrence=1findSectionHeaders.test|…findSectionHeaders.test|title=FindSectionHeaders handles section headers at chunk boundaries|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/findSectionHeaders.test|title=FindSectionHeaders handles section headers at chunk boundaries|occurrence=1findSectionHeaders.test|…findSectionHeaders.test|title=FindSectionHeaders handles whitespace-only regex gracefully without infinite loop|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/findSectionHeaders.test|title=FindSectionHeaders handles whitespace-only regex gracefully without infinite loop|occurrence=1findSectionHeaders.test|…findSectionHeaders.test|title=FindSectionHeaders section headers must be in comments when specified|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/services/findSectionHeaders.test|title=FindSectionHeaders section headers must be in comments when specified|occurrence=1findSectionHeaders.test|…Focused file · src/vs/editor/common/services/findSectionHeaders.ts · 181 LOCservices/findSectionHead…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- findSectionHeaders.ts ×4
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { IRange } from '../core/range.js';
7 > import { FoldingRules } from '../languages/languageConfiguration.js';
8 > import { isMultilineRegexSource } from '../model/textModelSearch.js';
9 > import { regExpLeadsToEndlessLoop } from '../../../base/common/strings.js';
10 >
11 > export interface ISectionHeaderFinderTarget {
12 > getLineCount(): number;
13 > getLineContent(lineNumber: number): string;
14 > }
15 >
16 > export interface FindSectionHeaderOptions {
17 > foldingRules?: FoldingRules;
18 > findRegionSectionHeaders: boolean;
19 > findMarkSectionHeaders: boolean;
20 > markSectionHeaderRegex: string;
21 > }
22 >
23 > export interface SectionHeader {
24 > /**
25 > * The location of the header text in the text model.
26 > */
27 > range: IRange;
28 > /**
29 > * The section header text.
30 > */
31 > text: string;
32 > /**
33 > * Whether the section header includes a separator line.
34 > */
35 > hasSeparatorLine: boolean;
36 > /**
37 > * This section should be omitted before rendering if it's not in a comment.
38 > */
39 > shouldBeInComments: boolean;
40 > }
41 >
42 > const trimDashesRegex = /^-+|-+$/g;
43 >
44 > const CHUNK_SIZE = 100;
45 > const MAX_SECTION_LINES = 5;
46 >
47 > /**
48 > * Find section headers in the model.
49 > *
50 > * @param model the text model to search in
51 > * @param options options to search with
52 > * @returns an array of section headers
53 > */
54 > export function findSectionHeaders(model: ISectionHeaderFinderTarget, options: FindSectionHeaderOptions): SectionHeader[] {
55 > let headers: SectionHeader[] = []; findSectionHeaders.ts ×4
56 > if (options.findRegionSectionHeaders && options.foldingRules?.markers) {
57 const regionHeaders = collectRegionHeaders(model, options);
58 headers = headers.concat(regionHeaders);
59 }
60 > if (options.findMarkSectionHeaders) { findSectionHeaders.ts ×4
61 > const markHeaders = collectMarkHeaders(model, options);
62 > headers = headers.concat(markHeaders);
63 > }
64 > return headers;
65 > }
67 function collectRegionHeaders(model: ISectionHeaderFinderTarget, options: FindSectionHeaderOptions): SectionHeader[] {
68 const regionHeaders: SectionHeader[] = [];
69 const endLineNumber = model.getLineCount();
70 for (let lineNumber = 1; lineNumber <= endLineNumber; lineNumber++) {
71 const lineContent = model.getLineContent(lineNumber);
72 const match = lineContent.match(options.foldingRules!.markers!.start);
73 if (match) {
74 const range = { startLineNumber: lineNumber, startColumn: match[0].length + 1, endLineNumber: lineNumber, endColumn: lineContent.length + 1 };
75 if (range.endColumn > range.startColumn) {
76 const sectionHeader = {
77 range,
78 ...getHeaderText(lineContent.substring(match[0].length)),
79 shouldBeInComments: false
80 };
81 if (sectionHeader.text || sectionHeader.hasSeparatorLine) {
82 regionHeaders.push(sectionHeader);
83 }
84 }
85 }
86 }
87 return regionHeaders;
88 }
90 > export function collectMarkHeaders(model: ISectionHeaderFinderTarget, options: FindSectionHeaderOptions): SectionHeader[] {
91 > const markHeaders: SectionHeader[] = []; findSectionHeaders.ts ×4
92 > const endLineNumber = model.getLineCount();
93 >
94 > // Validate regex to prevent infinite loops
95 > if (!options.markSectionHeaderRegex || options.markSectionHeaderRegex.trim() === '') {
96 > return markHeaders; findSectionHeaders.ts ×1
97 > }
99 > // Create regex with flags for:
100 > // - 'd' for indices to get proper match positions
101 > // - 'm' for multi-line mode so ^ and $ match line starts/ends
102 > // - 's' for dot-all mode so . matches newlines
103 > const multiline = isMultilineRegexSource(options.markSectionHeaderRegex);
104 > const regex = new RegExp(options.markSectionHeaderRegex, `gdm${multiline ? 's' : ''}`); findSectionHeaders.ts ×4
105 >
106 > // Check if the regex would lead to an endless loop
107 > if (regExpLeadsToEndlessLoop(regex)) {
108 return markHeaders;
109 }
111 > // Process text in overlapping chunks for better performance
112 > for (let startLine = 1; startLine <= endLineNumber; startLine += CHUNK_SIZE - MAX_SECTION_LINES) {
113 > const endLine = Math.min(startLine + CHUNK_SIZE - 1, endLineNumber);
114 > const lines: string[] = [];
115 >
116 > // Collect lines for the current chunk
117 > for (let i = startLine; i <= endLine; i++) {
118 > lines.push(model.getLineContent(i));
119 > }
120 >
121 > const text = lines.join('\n');
122 > regex.lastIndex = 0;
123 >
124 > let match: RegExpExecArray | null;
125 > while ((match = regex.exec(text)) !== null) {
126 > // Calculate which line this match starts on by counting newlines before it
127 > const precedingText = text.substring(0, match.index);
128 > const lineOffset = (precedingText.match(/\n/g) || []).length;
129 > const lineNumber = startLine + lineOffset;
130 >
131 > // Calculate match height to check overlap properly
132 > const matchLines = match[0].split('\n');
133 > const matchHeight = matchLines.length;
134 > const matchEndLine = lineNumber + matchHeight - 1;
135 >
136 > // Calculate start column - need to find the start of the line containing the match
137 > const lineStartIndex = precedingText.lastIndexOf('\n') + 1;
138 > const startColumn = match.index - lineStartIndex + 1;
139 >
140 > // Calculate end column - need to handle multi-line matches
141 > const lastMatchLine = matchLines[matchLines.length - 1];
142 > const endColumn = matchHeight === 1 ? startColumn + match[0].length : lastMatchLine.length + 1;
143 >
144 > const range = {
145 > startLineNumber: lineNumber,
146 > startColumn,
147 > endLineNumber: matchEndLine,
148 > endColumn
149 > };
150 >
151 > const text2 = (match.groups ?? {})['label'] ?? '';
152 > const hasSeparatorLine = ((match.groups ?? {})['separator'] ?? '') !== '';
153 >
154 > const sectionHeader = {
155 > range,
156 > text: text2,
157 > hasSeparatorLine,
158 > shouldBeInComments: true
159 > };
160 >
161 > if (sectionHeader.text || sectionHeader.hasSeparatorLine) {
162 > // only push if the previous one doesn't have this same linbe
163 > if (markHeaders.length === 0 || markHeaders[markHeaders.length - 1].range.endLineNumber < sectionHeader.range.startLineNumber) {
164 > markHeaders.push(sectionHeader);
165 > }
166 > }
167 >
168 > // Move lastIndex past the current match to avoid infinite loop
169 > regex.lastIndex = match.index + match[0].length;
170 > }
171 > }
172 >
173 > return markHeaders;
174 > }
176 function getHeaderText(text: string): { text: string; hasSeparatorLine: boolean } {
177 text = text.trim();
178 const hasSeparatorLine = text.startsWith('-');
179 text = text.replace(trimDashesRegex, '');
180 return { text, hasSeparatorLine };
181 }