Open-source AI browser agent for Chrome and Firefox (monorepo) ðŸ§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
Cache Markdown list continuations
Emre Sokullua224ab5a5e12
diff --git a/src/chrome/src/ui/markdown-render.js b/src/chrome/src/ui/markdown-render.jsindex 87fe5835f..de36ae02a 100644--- a/src/chrome/src/ui/markdown-render.js+++ b/src/chrome/src/ui/markdown-render.js@@ -307,11 +307,17 @@ function listContinuationContainer(source, position, prefix, indentation, noListcurrent.leadingQuoteIndent,);const cacheKey = `${current.quoteDepth}:${continuationIndent}:${current.leadingQuoteIndent}`;- const cachedPosition = noListScanPositions.get(cacheKey);+ const cached = noListScanPositions.get(cacheKey);+ if (cached?.container) return cached.container;+ const cachedPosition = cached?.noList;const noList = () => {- noListScanPositions.set(cacheKey, position);+ noListScanPositions.set(cacheKey, { noList: position });return null;};+ const foundList = container => {+ noListScanPositions.set(cacheKey, { container });+ return container;+ };let lineEnd = position;if (source[lineEnd - 1] === '\n') lineEnd -= 1;if (source[lineEnd - 1] === '\r') lineEnd -= 1;@@ -351,7 +357,7 @@ function listContinuationContainer(source, position, prefix, indentation, noList}const listIndent = container.listIndentGroups.at(-1);if (listIndent && continuationIndent >= listIndent && continuationIndent <= listIndent + 3) {- return container;+ return foundList(container);}return noList();}diff --git a/src/firefox/src/ui/markdown-render.js b/src/firefox/src/ui/markdown-render.jsindex 87fe5835f..de36ae02a 100644--- a/src/firefox/src/ui/markdown-render.js+++ b/src/firefox/src/ui/markdown-render.js@@ -307,11 +307,17 @@ function listContinuationContainer(source, position, prefix, indentation, noListcurrent.leadingQuoteIndent,);const cacheKey = `${current.quoteDepth}:${continuationIndent}:${current.leadingQuoteIndent}`;- const cachedPosition = noListScanPositions.get(cacheKey);+ const cached = noListScanPositions.get(cacheKey);+ if (cached?.container) return cached.container;+ const cachedPosition = cached?.noList;const noList = () => {- noListScanPositions.set(cacheKey, position);+ noListScanPositions.set(cacheKey, { noList: position });return null;};+ const foundList = container => {+ noListScanPositions.set(cacheKey, { container });+ return container;+ };let lineEnd = position;if (source[lineEnd - 1] === '\n') lineEnd -= 1;if (source[lineEnd - 1] === '\r') lineEnd -= 1;@@ -351,7 +357,7 @@ function listContinuationContainer(source, position, prefix, indentation, noList}const listIndent = container.listIndentGroups.at(-1);if (listIndent && continuationIndent >= listIndent && continuationIndent <= listIndent + 3) {- return container;+ return foundList(container);}return noList();}