From 7c846da04c0b1ead0513b9dcbb4d43468fa045d6 Mon Sep 17 00:00:00 2001 From: Scott Motte Date: Wed, 23 Sep 2026 07:16:45 -0700 Subject: [PATCH] simplify yaml cloaking setting --- CHANGELOG.md | 12 +++++++++--- README.md | 17 ++--------------- lib/autocloaking.js | 2 +- lib/yaml-cloaking.js | 3 +-- package.json | 15 +-------------- test/suite/lib/yaml-cloaking.test.js | 19 ++++++------------- 6 files changed, 20 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2797ea0..e9a7f10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). diff --git a/README.md b/README.md index e78e06c..248fca6 100644 --- a/README.md +++ b/README.md @@ -370,7 +370,8 @@ stay intact.
Can I cloak environment values in YAML? Yes.
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. @@ -382,20 +383,6 @@ on a best-effort basis. YAML isn't a source for completion or secret peeking.
-
Can I customize which YAML sections are cloaked? Yes.
- -Set `dotenv.yamlSections` to replace the defaults, or use `[]` to disable YAML cloaking. - -```json -{ - "dotenv.yamlSections": ["env_variables", "environment", "env", "secrets"] -} -``` - -  - -
-   ## Related Tools diff --git a/lib/autocloaking.js b/lib/autocloaking.js index 2053165..3954f25 100644 --- a/lib/autocloaking.js +++ b/lib/autocloaking.js @@ -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() } }) diff --git a/lib/yaml-cloaking.js b/lib/yaml-cloaking.js index 693deba..5d75eb6 100644 --- a/lib/yaml-cloaking.js +++ b/lib/yaml-cloaking.js @@ -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) : [] diff --git a/package.json b/package.json index 2c8ea98..c7b6579 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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." } } }, diff --git a/test/suite/lib/yaml-cloaking.test.js b/test/suite/lib/yaml-cloaking.test.js index d96e49a..54cba1a 100644 --- a/test/suite/lib/yaml-cloaking.test.js +++ b/test/suite/lib/yaml-cloaking.test.js @@ -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] }) @@ -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)