From c952cf40571f2ee8a7aff3cdf825f483d2d3817a Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Thu, 14 Sep 2023 13:59:58 +0200 Subject: [PATCH] #629 - Fix array indent to the new property --- CHANGELOG.md | 1 + src/parsers/ParserEngines.ts | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90132f63..e62b8895 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ ### 🐞 Fixes +- [#629](https://github.com/estruyf/vscode-front-matter/issues/629): Fix array indent to the new property - [#660](https://github.com/estruyf/vscode-front-matter/issues/660): Allow only to select unique content relationship values - [#661](https://github.com/estruyf/vscode-front-matter/issues/661): Fixing the dropdowns when used at the bottom of a collapsible group - [#664](https://github.com/estruyf/vscode-front-matter/issues/664): Fix for parsing draft status in Hexo and Jekyll diff --git a/src/parsers/ParserEngines.ts b/src/parsers/ParserEngines.ts index 9288f2a9..91938ab8 100644 --- a/src/parsers/ParserEngines.ts +++ b/src/parsers/ParserEngines.ts @@ -1,5 +1,4 @@ import * as yaml from 'yaml'; -import * as jsyaml from 'js-yaml'; import * as toml from '@iarna/toml'; import { Format, FrontMatterParser } from '.'; @@ -46,7 +45,16 @@ export const Engines = { parse: (value: string) => { return yaml.parse(removeCarriageReturn(value)); }, - stringify: (obj: any, options?: any) => { + stringify: ( + obj: any, + options?: { + indent?: number; + noArrayIndent?: boolean; + skipInvalid?: true; + noCompatMode?: true; + lineWidth?: number; + } + ) => { // Do our own parsing to keep the comments if (FrontMatterParser.currentContent) { const originalContent = FrontMatterParser.currentContent; @@ -76,9 +84,11 @@ export const Engines = { let updatedValue = docYaml.toJSON(); return yaml.stringify(updatedValue, { - lineWidth: 5000, + lineWidth: options?.lineWidth || 5000, defaultStringType: 'PLAIN', - keepUndefined: false + keepUndefined: false, + indent: options?.indent || 2, + indentSeq: options?.noArrayIndent ? false : true }); } }