microsoft / microsoft/vscode

Diff Editor hides semantically significant YAML indentation changes

Open
#336,452 0 comments 0 reactions 1 assignee Claimed by @hediet View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

Does this issue occur when all extensions are disabled?: No

- VS Code Version: 1.136.1
- OS Version: Ubuntu/Linux x64, kernel 7.0.0-31-generic

Steps to Reproduce:

1. Create or modify a GitHub Actions workflow YAML file.
2. Change the indentation of a workflow step without changing the actual text.
3. Open the file's Git diff in VS Code.
4. Compare the current commit with the previous commit.
5. Observe that the Diff Editor may hide the indentation-only changes.

Example change:

```diff
- - name: Run lintian (report only)
- shell: bash
- run: |
- set -euo pipefail
+ - name: Run lintian (report only)
+ shell: bash
+ run: |
+ set -euo pipefail
```

Expected Behavior:

The Diff Editor should clearly display all indentation changes.

In YAML and GitHub Actions workflow files, leading whitespace is syntactically meaningful because it determines the structure and nesting of the document.

Actual Behavior:

The Diff Editor displayed mainly comment and blank-line changes, while the important indentation changes were hidden.

The complete changes were visible using Git from the terminal:
```bash
git diff HEAD^ HEAD -- .github/workflows/ppa.yml
```
This made the change appear to be much smaller than it actually was and could cause users to miss important YAML structure changes during code review.

Additional Information:

The issue was reproduced in both Visual Studio Code and Trae CN, which is also based on the VS Code architecture.

The behavior appears to be related to whitespace-difference handling, such as:
```json
"diffEditor.ignoreTrimWhitespace": true
```
However, ignoring whitespace differences can be misleading for YAML files, where indentation changes can alter the meaning and execution structure of the document.

Workaround:
```json
"diffEditor.ignoreTrimWhitespace": false
```
I have not yet confirmed whether this behavior also occurs in the latest VS Code Insiders build.

Image

Image

Image

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.