mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-03-28 17:42:40 +01:00
#17 - Added support for indentation
This commit is contained in:
@@ -5,6 +5,7 @@ import { TaxonomyType } from "../models";
|
||||
import { CONFIG_KEY, SETTING_TAXONOMY_TAGS, SETTING_TAXONOMY_CATEGORIES, EXTENSION_NAME } from '../constants';
|
||||
import { ArticleHelper, SettingsHelper, FilesHelper } from '../helpers';
|
||||
import { TomlEngine, getFmLanguage, getFormatOpts } from '../helpers/TomlEngine';
|
||||
import { DumpOptions } from 'js-yaml';
|
||||
|
||||
export class Settings {
|
||||
|
||||
@@ -240,11 +241,13 @@ export class Settings {
|
||||
taxonomies = taxonomies.filter(o => o !== selectedOption);
|
||||
}
|
||||
data[matterProp] = [...new Set(taxonomies)].sort();
|
||||
const spaces = vscode.window.activeTextEditor?.options?.tabSize;
|
||||
// Update the file
|
||||
fs.writeFileSync(file.path, matter.stringify(article.content, article.data, {
|
||||
...TomlEngine,
|
||||
...langOpts
|
||||
}), { encoding: "utf8" });
|
||||
...langOpts,
|
||||
indent: spaces || 2
|
||||
} as DumpOptions as any), { encoding: "utf8" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,11 +66,14 @@ export class ArticleHelper {
|
||||
const language = getFmLanguage();
|
||||
const langOpts = getFormatOpts(language);
|
||||
|
||||
const spaces = vscode.window.activeTextEditor?.options?.tabSize;
|
||||
|
||||
return matter.stringify(content, data, ({
|
||||
...TomlEngine,
|
||||
...langOpts,
|
||||
noArrayIndent: !indentArray,
|
||||
lineWidth: 500
|
||||
lineWidth: 500,
|
||||
indent: spaces || 2
|
||||
} as DumpOptions as any));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user