fix duplicate logic
This commit is contained in:
parent
1bd49276c0
commit
7cd725264a
1 changed files with 6 additions and 27 deletions
|
|
@ -1,8 +1,7 @@
|
|||
import { LineStream } from "../diff/util";
|
||||
import {
|
||||
isMarkdownFile,
|
||||
MarkdownBlockStateTracker,
|
||||
headerIsMarkdown,
|
||||
MarkdownBlockStateTracker
|
||||
} from "./markdownUtils";
|
||||
|
||||
/**
|
||||
|
|
@ -85,33 +84,13 @@ export async function* stopAtLinesWithMarkdownSupport(
|
|||
|
||||
// Use optimized state tracker for markdown block analysis
|
||||
const stateTracker = new MarkdownBlockStateTracker(allLines);
|
||||
let nestCount = 0;
|
||||
const trimmedLines = allLines.map((l) => l.trim());
|
||||
|
||||
for (let i = 0; i < trimmedLines.length; i++) {
|
||||
const line = trimmedLines[i];
|
||||
|
||||
if (nestCount > 0) {
|
||||
if (line.match(/^`+$/)) {
|
||||
// Use optimized state tracker for markdown block logic
|
||||
if (stateTracker.shouldStopAtPosition(i)) {
|
||||
for (let j = 0; j < i; j++) {
|
||||
yield allLines[j];
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if (line.startsWith("```")) {
|
||||
nestCount++;
|
||||
}
|
||||
} else {
|
||||
if (line.startsWith("```")) {
|
||||
const header = line.replaceAll("`", "");
|
||||
const isMarkdown = headerIsMarkdown(header);
|
||||
|
||||
if (isMarkdown) {
|
||||
nestCount = 1;
|
||||
}
|
||||
for (let i = 0; i < allLines.length; i++) {
|
||||
if (stateTracker.shouldStopAtPosition(i)) {
|
||||
for (let j = 0; j < i; j++) {
|
||||
yield allLines[j];
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue