#629 - Fix array indent to the new property

This commit is contained in:
Elio Struyf
2023-09-14 13:59:58 +02:00
parent 73ce0d23ae
commit c952cf4057
2 changed files with 15 additions and 4 deletions
+1
View File
@@ -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
+14 -4
View File
@@ -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
});
}
}