Skip to content

Commit 853f7fd

Browse files
authored
Merge pull request #149 from docker/divider-line-toggle-setting
Add a setting to toggle the build stage divider lines
2 parents 6de9f8e + d7ec76e commit 853f7fd

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ All notable changes to the Docker DX extension will be documented in this file.
99
- Dockerfile
1010
- include the Dockerfile Language Server written in TypeScript into the extension
1111
- draw horizontal lines between each `FROM` instruction to help users visually distinguish the different parts of a Dockerfile ([#147](https://github.com/docker/vscode-extension/issues/147))
12+
- a new `docker.extension.editor.dockerfileBuildStageDecorationLines` setting to toggle the divider lines, defaults to `true`
1213

1314
## [0.10.0] - 2025-06-12
1415

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@
7777
"default": true,
7878
"scope": "application"
7979
},
80+
"docker.extension.editor.dockerfileBuildStageDecorationLines": {
81+
"type": "boolean",
82+
"description": "Render a divider line between each build stage of a Dockerfile.",
83+
"default": true,
84+
"scope": "resource"
85+
},
8086
"docker.lsp.telemetry": {
8187
"type": "string",
8288
"description": "Determines what telemetry is collected by Docker. If vscode.env.isTelemetryEnabled is false, then telemetry collection is disabled regardless of what has been set for this configuration value.",

src/utils/editor.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ const decoration = vscode.window.createTextEditorDecorationType({
1212
});
1313

1414
function getDecorationRanges(document: vscode.TextDocument): vscode.Range[] {
15-
if (document.languageId === 'dockerfile' && document.uri.scheme === 'file') {
15+
if (
16+
vscode.workspace
17+
.getConfiguration('docker.extension.editor', document)
18+
.get<boolean>('dockerfileBuildStageDecorationLines') &&
19+
document.languageId === 'dockerfile' &&
20+
document.uri.scheme === 'file'
21+
) {
1622
const dockerfile = DockerfileParser.parse(document.getText());
1723
return dockerfile.getFROMs().map((from) => {
1824
const line = from.getRange().start.line;
@@ -23,6 +29,25 @@ function getDecorationRanges(document: vscode.TextDocument): vscode.Range[] {
2329
}
2430

2531
export function hookDecorators(ctx: vscode.ExtensionContext): void {
32+
vscode.workspace.onDidChangeConfiguration(
33+
(event) => {
34+
if (
35+
event.affectsConfiguration(
36+
'docker.extension.editor.dockerfileBuildStageDecorationLines',
37+
)
38+
) {
39+
vscode.window.visibleTextEditors.forEach((editor) =>
40+
editor.setDecorations(
41+
decoration,
42+
getDecorationRanges(editor.document),
43+
),
44+
);
45+
}
46+
},
47+
null,
48+
ctx.subscriptions,
49+
);
50+
2651
vscode.window.visibleTextEditors.forEach((editor) =>
2752
editor.setDecorations(decoration, getDecorationRanges(editor.document)),
2853
);

0 commit comments

Comments
 (0)