#666 - Support config splitting

This commit is contained in:
Elio Struyf
2024-02-13 09:28:19 +01:00
parent da7d5e6854
commit 183e77b77b
+29 -18
View File
@@ -1,17 +1,19 @@
import {
EXTENSION_NAME,
SETTING_CONFIG_DYNAMIC_FILE_PATH,
SETTING_PROJECTS
} from './../constants/settings';
import { parseWinPath } from './parseWinPath';
import { Telemetry } from './Telemetry';
import { Notifications } from './Notifications';
import { commands, Uri, workspace, window } from 'vscode';
import * as vscode from 'vscode';
import {
commands,
Uri,
workspace,
window,
WorkspaceConfiguration,
FileSystemWatcher,
Disposable,
ProgressLocation
} from 'vscode';
import { ContentType, CustomTaxonomy, Project } from '../models';
import {
SETTING_TAXONOMY_TAGS,
SETTING_TAXONOMY_CATEGORIES,
EXTENSION_NAME,
CONFIG_KEY,
CONTEXT,
ExtensionState,
@@ -35,8 +37,13 @@ import {
SETTING_GLOBAL_NOTIFICATIONS,
SETTING_GLOBAL_NOTIFICATIONS_DISABLED,
SETTING_MEDIA_SUPPORTED_MIMETYPES,
SETTING_MEDIA_CONTENTTYPES,
SETTING_COMMA_SEPARATED_FIELDS,
SETTING_REMOVE_QUOTES
SETTING_REMOVE_QUOTES,
SETTING_CONFIG_DYNAMIC_FILE_PATH,
SETTING_PROJECTS,
SETTING_TAXONOMY_TAGS,
SETTING_TAXONOMY_CATEGORIES
} from '../constants';
import { Folders } from '../commands/Folders';
import { join, basename, dirname, parse } from 'path';
@@ -59,13 +66,13 @@ export class Settings {
public static globalConfigFolder = '.frontmatter/config';
public static globalConfigPath: string | undefined = undefined;
public static globalConfig: any;
private static config: vscode.WorkspaceConfiguration;
private static config: WorkspaceConfiguration;
private static isInitialized: boolean = false;
private static listeners: { id: string; callback: (global?: any) => void }[] = [];
private static fileCreationWatcher: vscode.FileSystemWatcher | undefined;
private static fileChangeWatcher: vscode.FileSystemWatcher | undefined;
private static fileSaveListener: vscode.Disposable;
private static fileDeleteListener: vscode.Disposable;
private static fileCreationWatcher: FileSystemWatcher | undefined;
private static fileChangeWatcher: FileSystemWatcher | undefined;
private static fileSaveListener: Disposable;
private static fileDeleteListener: Disposable;
private static readConfigPromise: Promise<void> | undefined = undefined;
private static project: Project | undefined = undefined;
private static configDebouncer = debounceCallback();
@@ -109,10 +116,10 @@ export class Settings {
commands.registerCommand(COMMAND_NAME.settingsRefresh, Settings.refreshConfig);
}
Settings.config = vscode.workspace.getConfiguration(CONFIG_KEY);
Settings.config = workspace.getConfiguration(CONFIG_KEY);
Settings.attachListener('settings-init', async () => {
Settings.config = vscode.workspace.getConfiguration(CONFIG_KEY);
Settings.config = workspace.getConfiguration(CONFIG_KEY);
});
Settings.onConfigChange();
@@ -674,7 +681,7 @@ export class Settings {
try {
await window.withProgress(
{
location: vscode.ProgressLocation.Notification,
location: ProgressLocation.Notification,
title: l10n.t(
LocalizationKey.helpersSettingsHelperReadConfigProgressTitle,
EXTENSION_NAME
@@ -866,6 +873,10 @@ export class Settings {
else if (Settings.isEqualOrStartsWith(relSettingName, SETTING_TAXONOMY_CONTENT_TYPES)) {
Settings.updateGlobalConfigArraySetting(SETTING_TAXONOMY_CONTENT_TYPES, 'name', configJson);
}
// Media Content types
else if (Settings.isEqualOrStartsWith(relSettingName, SETTING_MEDIA_CONTENTTYPES)) {
Settings.updateGlobalConfigArraySetting(SETTING_MEDIA_CONTENTTYPES, 'name', configJson);
}
// Data files
else if (Settings.isEqualOrStartsWith(relSettingName, SETTING_DATA_FILES)) {
Settings.updateGlobalConfigArraySetting(SETTING_DATA_FILES, 'id', configJson);