Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

Scope cached Markdown list continuations

Emre Sokullu1d886d33a057
diff --git a/src/chrome/src/ui/markdown-render.js b/src/chrome/src/ui/markdown-render.js
index de36ae02a..d9c1c792b 100644
--- a/src/chrome/src/ui/markdown-render.js
+++ b/src/chrome/src/ui/markdown-render.js
@@ -308,14 +308,17 @@ function listContinuationContainer(source, position, prefix, indentation, noList
);
const cacheKey = `${current.quoteDepth}:${continuationIndent}:${current.leadingQuoteIndent}`;
const cached = noListScanPositions.get(cacheKey);
- if (cached?.container) return cached.container;
+ if (cached?.container && position < cached.end) return cached.container;
const cachedPosition = cached?.noList;
const noList = () => {
noListScanPositions.set(cacheKey, { noList: position });
return null;
};
const foundList = container => {
- noListScanPositions.set(cacheKey, { container });
+ noListScanPositions.set(cacheKey, {
+ container,
+ end: unfinishedContainerEnd(source, position, container, new Map()),
+ });
return container;
};
let lineEnd = position;
diff --git a/src/firefox/src/ui/markdown-render.js b/src/firefox/src/ui/markdown-render.js
index de36ae02a..d9c1c792b 100644
--- a/src/firefox/src/ui/markdown-render.js
+++ b/src/firefox/src/ui/markdown-render.js
@@ -308,14 +308,17 @@ function listContinuationContainer(source, position, prefix, indentation, noList
);
const cacheKey = `${current.quoteDepth}:${continuationIndent}:${current.leadingQuoteIndent}`;
const cached = noListScanPositions.get(cacheKey);
- if (cached?.container) return cached.container;
+ if (cached?.container && position < cached.end) return cached.container;
const cachedPosition = cached?.noList;
const noList = () => {
noListScanPositions.set(cacheKey, { noList: position });
return null;
};
const foundList = container => {
- noListScanPositions.set(cacheKey, { container });
+ noListScanPositions.set(cacheKey, {
+ container,
+ end: unfinishedContainerEnd(source, position, container, new Map()),
+ });
return container;
};
let lineEnd = position;