Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix memory leak in syntax highlighting (causing gray webviews) #4459

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 117 additions & 19 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This is a log of all notable changes to Cody for VS Code. [Unreleased] changes a

- Chat: Don't append @ when "Add context" is pressed multiple times. [pull/4439](https://github.com/sourcegraph/cody/pull/4439)
- Performance: Reduced the performance overhead for certain types of context fetching, especially for larger files. This might have caused issues with slow autocomplete before. [pull/4446](https://github.com/sourcegraph/cody/pull/4446)
- Chat: Fixed an issue where the chat view would crash and display a gray screen in VS Code due to an out-of-memory situation. [pull/4459](https://github.com/sourcegraph/cody/pull/4459)

### Changed

Expand Down
2 changes: 1 addition & 1 deletion vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@
"parse-git-diff": "^0.0.14",
"proxy-agent": "^6.4.0",
"react-markdown": "^9.0.1",
"rehype-highlight": "^7.0.0",
"rehype-highlight": "^6.0.0",
"rehype-sanitize": "^6.0.0",
"remark-gfm": "^4.0.0",
"semver": "^7.5.4",
Expand Down
16 changes: 13 additions & 3 deletions vscode/webviews/components/MarkdownFromCody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function markdownPluginProps(): Pick<
'rehypePlugins' | 'remarkPlugins'
> {
if (_markdownPluginProps) {
//return _markdownPluginProps
return _markdownPluginProps
}

_markdownPluginProps = {
Expand All @@ -102,13 +102,23 @@ function markdownPluginProps(): Pick<
} satisfies RehypeSanitizeOptions,
],
[
rehypeHighlight,
// HACK(sqs): Need to use rehype-highlight@^6.0.0 to avoid a memory leak
// (https://github.com/remarkjs/react-markdown/issues/791), but the types are
// slightly off.
rehypeHighlight as any,
{
detect: true,
languages: Object.fromEntries(
Object.entries(all).filter(([language]) => LANGUAGES.includes(language))
),
} satisfies RehypeHighlightOptions,

// `ignoreMissing: true` is required to avoid errors when trying to highlight
// partial code blocks received from the LLM that have (e.g.) "```p" for
// "```python". This is only needed on rehype-highlight@^6.0.0, which we needed
// to downgrade to in order to avoid a memory leak
// (https://github.com/remarkjs/react-markdown/issues/791).
ignoreMissing: true,
} satisfies RehypeHighlightOptions & { ignoreMissing: boolean },
],
],
remarkPlugins: [remarkGFM],
Expand Down
Loading