From 0c8b42c3e6ba1b8d8d1c39483d0fdb9494bd9633 Mon Sep 17 00:00:00 2001 From: longkai Date: Tue, 3 Dec 2024 21:40:23 +0800 Subject: [PATCH] feat: add flowCollectionPadding option When true, a single space of padding will be added inside the delimiters of non-empty single-line flow collections. Fix #26 --- CHANGELOG.md | 4 ++++ README.md | 1 + package.json | 7 +++++++ src/extension.ts | 1 + 4 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfe66de..809fc62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to the "kubernetes-yaml-formatter" extension will be documen Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. +## 2.3.1 (03 Dec 2024) + +- add `better-yaml.flowCollectionPadding` option. When true, a single space of padding will be added inside the delimiters of non-empty single-line flow collections. Default true. + ## 2.3.0 (19 Nov 2024) - add `better-yaml.documentOptions.version` global option to set YAML version used by documents without a %YAML directive. diff --git a/README.md b/README.md index 0cdc0cf..e08387c 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ This extension contributes the following settings: * `better-yaml.directives`: Include directives in the output. If true, at least the document-start marker --- is always included. If false, no directives or marker is ever included. If null, directives and marker may be included if required. * `better-yaml.commentString`: Change the comment prefix string. By default, empty comment lines are left empty, lines consisting of a single space are replaced by `#`, and all other lines are prefixed with a `#`. * `better-yaml.lineWidth`: Maximum line width (set to 0 to disable folding). This is a soft limit, as only double-quoted semantics allow for inserting a line break in the middle of a word. +* `better-yaml.flowCollectionPadding`: When true, a single space of padding will be added inside the delimiters of non-empty single-line flow collections. * `better-yaml.documentOptions.version`: The YAML version used by documents without a %YAML directive. Must be '1.1' or '1.2'. Default to '1.2'. ## Thanks diff --git a/package.json b/package.json index 01a2e83..0efb99b 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,13 @@ "default": 0, "description": "Maximum line width (set to 0 to disable folding). This is a soft limit, as only double-quoted semantics allow for inserting a line break in the middle of a word." }, + "better-yaml.flowCollectionPadding": { + "type": [ + "boolean" + ], + "default": true, + "description": "When true, a single space of padding will be added inside the delimiters of non-empty single-line flow collections." + }, "better-yaml.documentOptions.version": { "type": [ "string" diff --git a/src/extension.ts b/src/extension.ts index d92138b..8fa6ec4 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -54,6 +54,7 @@ function makeFormattingOptions(conf: vscode.WorkspaceConfiguration, options: vsc indentSeq: conf.get('better-yaml.indentSeq'), directives: conf.get('better-yaml.directives'), lineWidth: conf.get('better-yaml.lineWidth'), + flowCollectionPadding: conf.get('better-yaml.flowCollectionPadding'), } const commentString: string | undefined | null = conf.get('better-yaml.commentString') if (commentString !== null && commentString !== undefined) {