Skip to content

feat: implement inserting code snippets

Andrei Zubov requested to merge azubov/1422-duo-insert-code-snippets into main

Description

This MR adds insert code block functionality to GitLab Duo Chat in vscode extension.

It relies on the existing functionality DuoChat component provides, and patches the render_gfm implementation to support inserting code snippets even if GitLab instance is outdated and does not return insert-code-block custom elements as part of the duo response.

Related Issues

Resolves #1422 (closed)

How has this been tested?

  1. Open a duo chat without opening any editors
  2. Ask duo to generate some code.
  3. Hover on the code block, locate insert code snippet button and press it
  4. Check that the notification shows that there are no active editors
  5. Open a code editor
  6. Press the insert code snippet button again. Check that the code is inserted at the cursor. That should also work with the selection, in this case the selection will be replaced with the code snippet.

Screenshots (if appropriate)

https://gitlab.com/-/project/5261717/uploads/327ea438c2ea82ea2b006838b16c3786/2024-08-22_13-59-25.mkv

What CHANGELOG entry will this MR create?

  • fix: Bug fix fixes - a user-facing issue in production - included in changelog
  • feature: New feature - a user-facing change which adds functionality - included in changelog
  • BREAKING CHANGE: (fix or feature that would cause existing functionality to change) - should bump major version, mentioned in the changelog
  • None - other non-user-facing changes
Edited by Andrei Zubov

Merge request reports

Loading