Skip to content

VS Code incorrectly renders Duo code blocks, breaking 'Insert at Cursor' functionality

Checklist

Summary

VS Code extension incorrectly renders code blocks within Duo chat responses, causing improper formatting and breaking the "Insert at Cursor" functionality. This issue disrupts normal development workflows as users cannot directly use the generated code.

Steps to reproduce

  1. Open VS Code with the GitLab extension
  2. Use GitLab Duo to generate code (especially code containing HTML tags or nested code blocks)
  3. Observe the rendering in VS Code
  4. Try to use "Insert at Cursor" functionality with the rendered code

What is the current bug behavior?

  1. Code blocks inside another code block are not rendered correctly in VS Code
  2. After VS Code fails to render the code correctly, all further code is greyed out
  3. When using "Insert at Cursor", the code includes special characters for HTML tags and other formatting, making it unusable
  4. Users are forced to switch context to GitLab UI to copy the correctly rendered code

What is the expected correct behavior?

  1. Code blocks should render correctly in VS Code, similar to how they appear in the GitLab UI
  2. "Insert at Cursor" functionality should insert clean, usable code without special characters or formatting issues
  3. Users should be able to use Duo-generated code directly from VS Code without having to switch context

Relevant logs and/or screenshots

A screenshot was provided showing the difference between the rendering in VS Code (incorrect) and GitLab UI (correct). I reproduced it in gitlab.com with latest VScode version and extension- screenshot below: image

Possible fixes

This is similar to:

The issue was previously fixed around v17.5 of GitLab but has regressed.

Edited by ŁUKASZ KORBASIEWICZ