Skip to content
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
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

All notable changes to the Official Dotenv VS Code extension will be documented in this file.

## [Unreleased](https://github.com/dotenvx/dotenv-vscode/compare/v1.5.2...master)
## [Unreleased](https://github.com/dotenvx/dotenv-vscode/compare/v1.5.6...master)

### Fixed
## [1.5.6](https://github.com/dotenvx/dotenv-vscode/compare/v1.5.4...v1.5.6) (2026-09-23)

### Changed

* Honor cloak color and icon settings in the Dotenv Editor, and folder-specific cloaking and secret-peeking settings in multi-root workspaces.
* Use the shared auto-cloaking setting for YAML, removing the separate YAML section setting.

## [1.5.5](https://github.com/dotenvx/dotenv-vscode/compare/v1.5.2...v1.5.5) (2026-09-23)

### Changed

* Honor the auto-cloaking setting in the Dotenv Editor, including on load, settings changes, and tab switches (#139).

Expand Down
17 changes: 2 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ stay intact.
<details><summary>Can I cloak environment values in YAML? <strong>Yes.</strong></summary><br>

In the normal YAML editor, values under `env_variables`, `environment`, and
`env` are masked.
`env` are masked. The same **Dotenv: Enable Autocloaking** checkbox controls
both `.env` and YAML files and is enabled by default.

This includes Docker Compose maps and lists and Kubernetes `name`/`value` entries.
Quotes and comments stay visible.
Expand All @@ -382,20 +383,6 @@ on a best-effort basis. YAML isn't a source for completion or secret peeking.

</details>

<details><summary>Can I customize which YAML sections are cloaked? <strong>Yes.</strong></summary><br>

Set `dotenv.yamlSections` to replace the defaults, or use `[]` to disable YAML cloaking.

```json
{
"dotenv.yamlSections": ["env_variables", "environment", "env", "secrets"]
}
```

&nbsp;

</details>

&nbsp;

## Related Tools
Expand Down
2 changes: 1 addition & 1 deletion lib/autocloaking.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function decorateMasking (context) {
const resetting = settings.resetAutocloaking()
decorateVisibleEditors()
await resetting
} else if (event.affectsConfiguration('dotenv.cloakColor') || event.affectsConfiguration('dotenv.cloakIcon') || event.affectsConfiguration('dotenv.yamlSections')) {
} else if (event.affectsConfiguration('dotenv.cloakColor') || event.affectsConfiguration('dotenv.cloakIcon')) {
decorateVisibleEditors()
}
})
Expand Down
3 changes: 1 addition & 2 deletions lib/yaml-cloaking.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ const values = require('./yaml-values')
const mask = vscode.window.createTextEditorDecorationType({ letterSpacing: '-1ch', opacity: '0', color: 'transparent' })
function supported (document) { return document.languageId === 'yaml' }
function ranges (document) {
const config = vscode.workspace.getConfiguration('dotenv', document.uri)
return values.ranges(document.getText(), config.get('yamlSections', values.defaultSections))
return values.ranges(document.getText())
}
function decorate (editor) {
const patches = supported(editor.document) && settings.autocloakingEnabled(editor.document.uri) ? ranges(editor.document) : []
Expand Down
15 changes: 1 addition & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"scope": "resource",
"type": "boolean",
"default": true,
"description": "Enable auto-cloaking for your .env files"
"description": "Enable auto-cloaking for .env files and environment values in YAML"
},
"dotenv.enableSecretpeeking": {
"scope": "resource",
Expand All @@ -56,19 +56,6 @@
"type": "string",
"default": "█",
"description": "Change the icon of the cloak for your .env files"
},
"dotenv.yamlSections": {
"type": "array",
"scope": "resource",
"items": {
"type": "string"
},
"default": [
"env_variables",
"environment",
"env"
],
"description": "YAML section names whose environment values are cloaked in the normal YAML editor. Use an empty array to disable YAML cloaking."
}
}
},
Expand Down
19 changes: 6 additions & 13 deletions test/suite/lib/yaml-cloaking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,17 @@ const vscode = require('vscode')
const values = require('../../../lib/yaml-values')

describe('YAML decoration integration', () => {
it('applies exact value ranges, respects section settings, and clears on toggle or language change', async () => {
it('cloaks standard YAML sections and follows the shared auto-cloaking setting', async () => {
const document = await vscode.workspace.openTextDocument({ language: 'yaml', content: 'image: public\nenvironment:\n TOKEN: "secret" # visible\ncustom:\n KEY: hidden\n' })
let enabled = true
let sections = values.defaultSections
let patches
const module = { exports: {} }
const dependencies = {
vscode: {
Range: vscode.Range,
window: { createTextEditorDecorationType: () => ({}) },
workspace: {
getConfiguration: (name, uri) => {
assert.strictEqual(uri, document.uri)
return { get: () => sections }
}
}
window: { createTextEditorDecorationType: () => ({}) }
},
'./settings': { autocloakingEnabled: () => enabled, cloakColor: () => '#000000', cloakIcon: () => '█' },
'./settings': { autocloakingEnabled: uri => { assert.strictEqual(uri, document.uri); return enabled }, cloakColor: () => '#000000', cloakIcon: () => '█' },
'./yaml-values': values
}
vm.runInNewContext(fs.readFileSync(path.join(__dirname, '../../../lib/yaml-cloaking.js'), 'utf8'), { module, require: name => dependencies[name] })
Expand All @@ -33,13 +26,13 @@ describe('YAML decoration integration', () => {
assert.strictEqual(patches.length, 1)
assert.strictEqual(document.getText(patches[0].range), 'secret')
assert.strictEqual(patches[0].renderOptions.after.contentText, '██████')
sections = ['custom']
module.exports.decorate(editor)
assert.strictEqual(document.getText(patches[0].range), 'hidden')
enabled = false
module.exports.decorate(editor)
assert.strictEqual(patches.length, 0)
enabled = true
module.exports.decorate(editor)
assert.strictEqual(patches.length, 1)
assert.strictEqual(document.getText(patches[0].range), 'secret')
editor.document = { languageId: 'plaintext' }
module.exports.decorate(editor)
assert.strictEqual(patches.length, 0)
Expand Down
Loading