Code Suggestions Fail to Respect Existing Indentation Levels
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
Code suggestions inserted by Duo don't maintain proper indentation levels of the surrounding code, causing syntax errors in indentation-sensitive languages like Python. The first line of inserted code begins exactly at cursor position rather than aligning with the proper indentation level.
Steps to reproduce
- Open a Python file in the VS Code editor with Code suggestion feature enabled
- Position cursor within an indented code block (e.g., inside a function or loop)
- Request a code suggestion from Duo
- Accept the suggestion for insertion
See attached video for illustration.
Example Project
What is the current bug behavior?
The first line of the inserted code begins exactly at the cursor position, ignoring the indentation level of the surrounding code. This breaks Python's syntax requirements and requires manual adjustment after insertion.
What is the expected correct behavior?
Code suggestions should automatically detect and respect the indentation level of the surrounding code. When inserted into an indented block, all lines of the suggestion should maintain proper indentation relative to the code context.
Relevant logs and/or screenshots
Screen_Recording_2025-05-02_at_12.07.33
Output of checks
This bug happens on GitLab.com
# GitLab Workflow Diagnostics
## Versions
- IDE: Visual Studio Code (1.99.3)
- Extension: GitLab Workflow version (6.13.0)
- Language Server version: 7.30.0
- GitLab instance version: 18.0.0-pre
## GitLab Duo Code Suggestions (On)
✅ [true] User is authenticated
✅ [true] Code Suggestions are enabled in settings
✅ [true] Code Suggestions API connection is working
✅ [true] The GitLab instance version supports Code Suggestions
✅ [true] Valid GitLab license
✅ [true] GitLab Duo is enabled for the open project(s)
## GitLab Duo Chat (On)
✅ [true] User is authenticated
✅ [true] Chat is enabled in settings
✅ [true] Valid GitLab license
✅ [true] GitLab Duo is enabled for the open project(s)
## Duo workflow settings
### GitLab Duo
- Disabled supported languages: None
- Additional enabled languages: yaml
- [enabled] Duo Code Suggestions
- [enabled] Duo Chat
- [enabled] Enabled without GitLab project
- [enabled] Open files as context
- [disabled] Use Docker
### Other
- [disabled] Debug
### Custom certificates
- Certificate authority: Not configured
- Certificate: Not configured
- Certificate key: Not configured
- [disabled] Ignore certificate errors
### Code security
- [disabled] Real-time security scanning
- [enabled] Scan file on save