瀏覽代碼

Adds type-safe core configuration checks

main
Eric Amodio 1 年之前
父節點
當前提交
f5459e93ed
共有 14 個檔案被更改,包括 127 行新增81 行删除
  1. +2
    -1
      src/annotations/annotations.ts
  2. +4
    -2
      src/commands/git/push.ts
  3. +18
    -6
      src/constants.ts
  4. +8
    -3
      src/env/node/fetch.ts
  5. +11
    -9
      src/env/node/git/localGitProvider.ts
  6. +8
    -6
      src/git/gitProviderService.ts
  7. +3
    -2
      src/git/models/repository.ts
  8. +2
    -1
      src/plus/github/github.ts
  9. +2
    -1
      src/plus/gitlab/gitlab.ts
  10. +47
    -35
      src/system/configuration.ts
  11. +1
    -1
      src/telemetry/telemetry.ts
  12. +10
    -4
      src/webviews/commitDetails/commitDetailsWebview.ts
  13. +3
    -0
      src/webviews/rebase/rebaseEditor.ts
  14. +8
    -10
      src/webviews/webviewWithConfigBase.ts

+ 2
- 1
src/annotations/annotations.ts 查看文件

@ -9,6 +9,7 @@ import type {
import { OverviewRulerLane, ThemeColor, Uri, window } from 'vscode';
import type { Config } from '../config';
import { HeatmapLocations } from '../config';
import type { CoreConfiguration } from '../constants';
import { Colors, GlyphChars } from '../constants';
import type { CommitFormatOptions } from '../git/formatters/commitFormatter';
import { CommitFormatter } from '../git/formatters/commitFormatter';
@ -192,7 +193,7 @@ export function getGutterRenderOptions(
let width;
if (chars >= 0) {
const spacing = configuration.getAny<number>('editor.letterSpacing');
const spacing = configuration.getAny<CoreConfiguration, number>('editor.letterSpacing');
if (spacing != null && spacing !== 0) {
width = `calc(${chars}ch + ${Math.round(chars * spacing) + (avatars ? 13 : -6)}px)`;
} else {

+ 4
- 2
src/commands/git/push.ts 查看文件

@ -1,4 +1,5 @@
import { CoreGitConfiguration, GlyphChars } from '../../constants';
import type { CoreGitConfiguration } from '../../constants';
import { GlyphChars } from '../../constants';
import type { Container } from '../../container';
import { getRemoteNameFromBranchName } from '../../git/models/branch';
import type { GitBranchReference, GitReference } from '../../git/models/reference';
@ -160,7 +161,8 @@ export class PushGitCommand extends QuickCommand {
}
private async *confirmStep(state: PushStepState, context: Context): AsyncStepResultGenerator<Flags[]> {
const useForceWithLease = configuration.getAny<boolean>(CoreGitConfiguration.UseForcePushWithLease) ?? false;
const useForceWithLease =
configuration.getAny<CoreGitConfiguration, boolean>('git.useForcePushWithLease') ?? false;
let step: QuickPickStep<FlagsQuickPickItem<Flags>>;

+ 18
- 6
src/constants.ts 查看文件

@ -357,12 +357,24 @@ export type CoreGitCommands =
| 'git.pushForce'
| 'git.undoCommit';
export const enum CoreGitConfiguration {
AutoRepositoryDetection = 'git.autoRepositoryDetection',
RepositoryScanMaxDepth = 'git.repositoryScanMaxDepth',
FetchOnPull = 'git.fetchOnPull',
UseForcePushWithLease = 'git.useForcePushWithLease',
}
export type CoreConfiguration =
| 'editor.letterSpacing'
| 'files.encoding'
| 'files.exclude'
| 'http.proxy'
| 'http.proxySupport'
| 'http.proxyStrictSSL'
| 'search.exclude'
| 'workbench.editorAssociations'
| 'workbench.tree.renderIndentGuides';
export type CoreGitConfiguration =
| 'git.autoRepositoryDetection'
| 'git.enabled'
| 'git.fetchOnPull'
| 'git.path'
| 'git.repositoryScanMaxDepth'
| 'git.useForcePushWithLease';
export const enum GlyphChars {
AngleBracketLeftHeavy = '\u2770',

+ 8
- 3
src/env/node/fetch.ts 查看文件

@ -2,6 +2,7 @@ import * as process from 'process';
import * as url from 'url';
import { HttpsProxyAgent } from 'https-proxy-agent';
import fetch from 'node-fetch';
import type { CoreConfiguration } from '../../constants';
import { configuration } from '../../system/configuration';
import { Logger } from '../../system/logger';
@ -16,7 +17,7 @@ export function getProxyAgent(strictSSL?: boolean): HttpsProxyAgent | undefined
proxyUrl = proxy.url ?? undefined;
strictSSL = strictSSL ?? proxy.strictSSL;
} else {
const proxySupport = configuration.getAny<'off' | 'on' | 'override' | 'fallback'>(
const proxySupport = configuration.getAny<CoreConfiguration, 'off' | 'on' | 'override' | 'fallback'>(
'http.proxySupport',
undefined,
'override',
@ -25,8 +26,12 @@ export function getProxyAgent(strictSSL?: boolean): HttpsProxyAgent | undefined
if (proxySupport === 'off') {
strictSSL = strictSSL ?? true;
} else {
strictSSL = strictSSL ?? configuration.getAny<boolean>('http.proxyStrictSSL', undefined, true);
proxyUrl = configuration.getAny<string>('http.proxy') || process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
strictSSL =
strictSSL ?? configuration.getAny<CoreConfiguration, boolean>('http.proxyStrictSSL', undefined, true);
proxyUrl =
configuration.getAny<CoreConfiguration, string>('http.proxy') ||
process.env.HTTPS_PROXY ||
process.env.HTTP_PROXY;
}
}

+ 11
- 9
src/env/node/git/localGitProvider.ts 查看文件

@ -14,7 +14,8 @@ import type {
GitExtension,
} from '../../../@types/vscode.git';
import { getCachedAvatarUri } from '../../../avatars';
import { CoreGitConfiguration, GlyphChars, Schemes } from '../../../constants';
import type { CoreConfiguration, CoreGitConfiguration } from '../../../constants';
import { GlyphChars, Schemes } from '../../../constants';
import type { Container } from '../../../container';
import { emojify } from '../../../emojis';
import { Features } from '../../../features';
@ -304,7 +305,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
private async findGit(): Promise<GitLocation> {
const scope = getLogScope();
if (!configuration.getAny<boolean>('git.enabled', null, true)) {
if (!configuration.getAny<CoreGitConfiguration, boolean>('git.enabled', null, true)) {
Logger.log(scope, 'Built-in Git is disabled ("git.enabled": false)');
void showGitDisabledErrorMessage();
@ -335,7 +336,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
void subscribeToScmOpenCloseRepository.call(this);
const potentialGitPaths =
configuration.getAny<string | string[]>('git.path') ?? this.container.storage.getWorkspace('gitPath');
configuration.getAny<CoreGitConfiguration, string | string[]>('git.path') ??
this.container.storage.getWorkspace('gitPath');
const start = hrtime();
@ -389,8 +391,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
void (await this.ensureGit());
const autoRepositoryDetection =
configuration.getAny<boolean | 'subFolders' | 'openEditors'>(
CoreGitConfiguration.AutoRepositoryDetection,
configuration.getAny<CoreGitConfiguration, boolean | 'subFolders' | 'openEditors'>(
'git.autoRepositoryDetection',
) ?? true;
const folder = workspace.getWorkspaceFolder(uri);
@ -576,7 +578,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
depth =
depth ??
configuration.get('advanced.repositorySearchDepth', folder.uri) ??
configuration.getAny<number>(CoreGitConfiguration.RepositoryScanMaxDepth, folder.uri, 1);
configuration.getAny<CoreGitConfiguration, number>('git.repositoryScanMaxDepth', folder.uri, 1);
Logger.log(scope, `searching (depth=${depth})...`);
@ -602,8 +604,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
// Get any specified excludes -- this is a total hack, but works for some simple cases and something is better than nothing :)
const excludedConfig = {
...configuration.getAny<Record<string, boolean>>('files.exclude', folder.uri, {}),
...configuration.getAny<Record<string, boolean>>('search.exclude', folder.uri, {}),
...configuration.getAny<CoreConfiguration, Record<string, boolean>>('files.exclude', folder.uri, {}),
...configuration.getAny<CoreConfiguration, Record<string, boolean>>('search.exclude', folder.uri, {}),
};
const excludedPaths = [
@ -4920,7 +4922,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
}
async function getEncoding(uri: Uri): Promise<string> {
const encoding = configuration.getAny<string>('files.encoding', uri);
const encoding = configuration.getAny<CoreConfiguration, string>('files.encoding', uri);
if (encoding == null || encoding === 'utf8') return 'utf8';
const encodingExists = (await import(/* webpackChunkName: "encoding" */ 'iconv-lite')).encodingExists;

+ 8
- 6
src/git/gitProviderService.ts 查看文件

@ -11,7 +11,8 @@ import type {
} from 'vscode';
import { Disposable, EventEmitter, FileType, ProgressLocation, Uri, window, workspace } from 'vscode';
import { resetAvatarCache } from '../avatars';
import { ContextKeys, CoreGitConfiguration, GlyphChars, Schemes } from '../constants';
import type { CoreGitConfiguration } from '../constants';
import { ContextKeys, GlyphChars, Schemes } from '../constants';
import type { Container } from '../container';
import { setContext } from '../context';
import { AccessDeniedError, ProviderNotFoundError } from '../errors';
@ -505,9 +506,10 @@ export class GitProviderService implements Disposable {
this.updateContext();
}
const autoRepositoryDetection = configuration.getAny<boolean | 'subFolders' | 'openEditors'>(
CoreGitConfiguration.AutoRepositoryDetection,
);
const autoRepositoryDetection = configuration.getAny<
CoreGitConfiguration,
boolean | 'subFolders' | 'openEditors'
>('git.autoRepositoryDetection');
if (this.container.telemetry.enabled) {
queueMicrotask(() =>
@ -2311,8 +2313,8 @@ export class GitProviderService implements Disposable {
}
const autoRepositoryDetection =
configuration.getAny<boolean | 'subFolders' | 'openEditors'>(
CoreGitConfiguration.AutoRepositoryDetection,
configuration.getAny<CoreGitConfiguration, boolean | 'subFolders' | 'openEditors'>(
'git.autoRepositoryDetection',
) ?? true;
const closed =

+ 3
- 2
src/git/models/repository.ts 查看文件

@ -3,7 +3,8 @@ import { Disposable, EventEmitter, ProgressLocation, RelativePattern, Uri, windo
import { md5 } from '@env/crypto';
import { ForcePushMode } from '../../@types/vscode.git.enums';
import type { CreatePullRequestActionContext } from '../../api/gitlens';
import { CoreGitConfiguration, Schemes } from '../../constants';
import type { CoreGitConfiguration } from '../../constants';
import { Schemes } from '../../constants';
import type { Container } from '../../container';
import type { FeatureAccess, Features, PlusFeatures } from '../../features';
import { showCreatePullRequestPrompt, showGenericErrorMessage } from '../../messages';
@ -804,7 +805,7 @@ export class Repository implements Disposable {
const upstream = await this.hasUpstreamBranch();
if (upstream) {
void (await executeCoreGitCommand(options?.rebase ? 'git.pullRebase' : 'git.pull', this.path));
} else if (configuration.getAny<boolean>(CoreGitConfiguration.FetchOnPull, Uri.file(this.path))) {
} else if (configuration.getAny<CoreGitConfiguration, boolean>('git.fetchOnPull', Uri.file(this.path))) {
await this.container.git.fetch(this.path);
}

+ 2
- 1
src/plus/github/github.ts 查看文件

@ -7,6 +7,7 @@ import type { Event } from 'vscode';
import { Disposable, EventEmitter, Uri, window } from 'vscode';
import { fetch, getProxyAgent, wrapForForcedInsecureSSL } from '@env/fetch';
import { isWeb } from '@env/platform';
import type { CoreConfiguration } from '../../constants';
import type { Container } from '../../container';
import {
AuthenticationError,
@ -196,7 +197,7 @@ export class GitHubApi implements Disposable {
}
}),
configuration.onDidChangeOther(e => {
if (e.affectsConfiguration('http.proxy') || e.affectsConfiguration('http.proxyStrictSSL')) {
if (configuration.changedAny<CoreConfiguration>(e, ['http.proxy', 'http.proxyStrictSSL'])) {
this.resetCaches();
}
}),

+ 2
- 1
src/plus/gitlab/gitlab.ts 查看文件

@ -3,6 +3,7 @@ import { Disposable, Uri, window } from 'vscode';
import type { RequestInit, Response } from '@env/fetch';
import { fetch, getProxyAgent, wrapForForcedInsecureSSL } from '@env/fetch';
import { isWeb } from '@env/platform';
import type { CoreConfiguration } from '../../constants';
import type { Container } from '../../container';
import {
AuthenticationError,
@ -46,7 +47,7 @@ export class GitLabApi implements Disposable {
}
}),
configuration.onDidChangeOther(e => {
if (e.affectsConfiguration('http.proxy') || e.affectsConfiguration('http.proxyStrictSSL')) {
if (configuration.changedAny<CoreConfiguration>(e, ['http.proxy', 'http.proxyStrictSSL'])) {
this._projectIds.clear();
this._proxyAgents.clear();
}

+ 47
- 35
src/system/configuration.ts 查看文件

@ -64,23 +64,23 @@ export class Configuration {
queueMicrotask(() => (this._overrides = undefined));
}
get<T extends ConfigPath>(section: T, scope?: ConfigurationScope | null): ConfigPathValue<T>;
get<T extends ConfigPath>(
section: T,
get<S extends ConfigPath>(section: S, scope?: ConfigurationScope | null): ConfigPathValue<S>;
get<S extends ConfigPath>(
section: S,
scope: ConfigurationScope | null | undefined,
defaultValue: NonNullable<ConfigPathValue<T>>,
): NonNullable<ConfigPathValue<T>>;
get<T extends ConfigPath>(
section: T,
defaultValue: NonNullable<ConfigPathValue<S>>,
): NonNullable<ConfigPathValue<S>>;
get<S extends ConfigPath>(
section: S,
scope?: ConfigurationScope | null,
defaultValue?: NonNullable<ConfigPathValue<T>>,
defaultValue?: NonNullable<ConfigPathValue<S>>,
skipOverrides?: boolean,
): ConfigPathValue<T> {
): ConfigPathValue<S> {
const value =
defaultValue === undefined
? workspace.getConfiguration(configPrefix, scope).get<ConfigPathValue<T>>(section)!
: workspace.getConfiguration(configPrefix, scope).get<ConfigPathValue<T>>(section, defaultValue)!;
return skipOverrides || this._overrides?.get == null ? value : this._overrides.get<T>(section, value);
? workspace.getConfiguration(configPrefix, scope).get<ConfigPathValue<S>>(section)!
: workspace.getConfiguration(configPrefix, scope).get<ConfigPathValue<S>>(section, defaultValue)!;
return skipOverrides || this._overrides?.get == null ? value : this._overrides.get<S>(section, value);
}
getAll(skipOverrides?: boolean): Config {
@ -88,17 +88,17 @@ export class Configuration {
return skipOverrides || this._overrides?.getAll == null ? config : this._overrides.getAll(config);
}
getAny<T>(section: string, scope?: ConfigurationScope | null): T | undefined;
getAny<T>(section: string, scope: ConfigurationScope | null | undefined, defaultValue: T): T;
getAny<T>(section: string, scope?: ConfigurationScope | null, defaultValue?: T): T | undefined {
getAny<S extends string, T>(section: S, scope?: ConfigurationScope | null): T | undefined;
getAny<S extends string, T>(section: S, scope: ConfigurationScope | null | undefined, defaultValue: T): T;
getAny<S extends string, T>(section: S, scope?: ConfigurationScope | null, defaultValue?: T): T | undefined {
return defaultValue === undefined
? workspace.getConfiguration(undefined, scope).get<T>(section)
: workspace.getConfiguration(undefined, scope).get<T>(section, defaultValue);
}
changed<T extends ConfigPath>(
changed<S extends ConfigPath>(
e: ConfigurationChangeEvent | undefined,
section: T | T[],
section: S | S[],
scope?: ConfigurationScope | null | undefined,
): boolean {
if (e == null) return true;
@ -108,17 +108,29 @@ export class Configuration {
: e.affectsConfiguration(`${configPrefix}.${section}`, scope!);
}
inspect<T extends ConfigPath, V extends ConfigPathValue<T>>(section: T, scope?: ConfigurationScope | null) {
changedAny<S extends string>(
e: ConfigurationChangeEvent | undefined,
section: S | S[],
scope?: ConfigurationScope | null | undefined,
): boolean {
if (e == null) return true;
return Array.isArray(section)
? section.some(s => e.affectsConfiguration(s, scope!))
: e.affectsConfiguration(section, scope!);
}
inspect<S extends ConfigPath, V extends ConfigPathValue<S>>(section: S, scope?: ConfigurationScope | null) {
return workspace
.getConfiguration(configPrefix, scope)
.inspect<V>(section === undefined ? configPrefix : section);
}
inspectAny<T>(section: string, scope?: ConfigurationScope | null) {
inspectAny<S extends string, T>(section: S, scope?: ConfigurationScope | null) {
return workspace.getConfiguration(undefined, scope).inspect<T>(section);
}
isUnset<T extends ConfigPath>(section: T, scope?: ConfigurationScope | null): boolean {
isUnset<S extends ConfigPath>(section: S, scope?: ConfigurationScope | null): boolean {
const inspect = this.inspect(section, scope)!;
if (inspect.workspaceFolderValue !== undefined) return false;
if (inspect.workspaceValue !== undefined) return false;
@ -127,10 +139,10 @@ export class Configuration {
return true;
}
async migrate<T extends ConfigPath>(
async migrate<S extends ConfigPath>(
from: string,
to: T,
options: { fallbackValue?: ConfigPathValue<T>; migrationFn?(value: any): ConfigPathValue<T> },
to: S,
options: { fallbackValue?: ConfigPathValue<S>; migrationFn?(value: any): ConfigPathValue<S> },
): Promise<boolean> {
const inspection = this.inspect(from as any);
if (inspection === undefined) return false;
@ -196,10 +208,10 @@ export class Configuration {
return migrated;
}
async migrateIfMissing<T extends ConfigPath>(
async migrateIfMissing<S extends ConfigPath>(
from: string,
to: T,
options: { migrationFn?(value: any): ConfigPathValue<T> },
to: S,
options: { migrationFn?(value: any): ConfigPathValue<S> },
): Promise<void> {
const fromInspection = this.inspect(from as any);
if (fromInspection === undefined) return;
@ -263,25 +275,25 @@ export class Configuration {
}
}
matches<T extends ConfigPath>(match: T, section: ConfigPath, value: unknown): value is ConfigPathValue<T> {
matches<S extends ConfigPath>(match: S, section: ConfigPath, value: unknown): value is ConfigPathValue<S> {
return match === section;
}
name<T extends ConfigPath>(section: T): string {
name<S extends ConfigPath>(section: S): string {
return section;
}
update<T extends ConfigPath>(
section: T,
value: ConfigPathValue<T> | undefined,
update<S extends ConfigPath>(
section: S,
value: ConfigPathValue<S> | undefined,
target: ConfigurationTarget,
): Thenable<void> {
return workspace.getConfiguration(configPrefix).update(section, value, target);
}
updateAny(
section: string,
value: any,
updateAny<S extends string, T>(
section: S,
value: T,
target: ConfigurationTarget,
scope?: ConfigurationScope | null,
): Thenable<void> {
@ -290,7 +302,7 @@ export class Configuration {
.update(section, value, target);
}
updateEffective<T extends ConfigPath>(section: T, value: ConfigPathValue<T> | undefined): Thenable<void> {
updateEffective<S extends ConfigPath>(section: S, value: ConfigPathValue<S> | undefined): Thenable<void> {
const inspect = this.inspect(section)!;
if (inspect.workspaceFolderValue !== undefined) {
if (value === inspect.workspaceFolderValue) return Promise.resolve(undefined);

+ 1
- 1
src/telemetry/telemetry.ts 查看文件

@ -50,7 +50,7 @@ export class TelemetryService implements Disposable {
constructor(private readonly container: Container) {
container.context.subscriptions.push(
configuration.onDidChange(e => {
if (!e.affectsConfiguration('telemetry.enabled')) return;
if (!configuration.changed(e, 'telemetry.enabled')) return;
this.ensureTelemetry(container);
}),

+ 10
- 4
src/webviews/commitDetails/commitDetailsWebview.ts 查看文件

@ -2,6 +2,7 @@ import type { CancellationToken, ConfigurationChangeEvent, TextDocumentShowOptio
import { CancellationTokenSource, Disposable, Uri, ViewColumn, window } from 'vscode';
import { serializeAutolink } from '../../annotations/autolinks';
import type { CopyShaToClipboardCommandArgs } from '../../commands';
import type { CoreConfiguration } from '../../constants';
import { Commands, ContextKeys } from '../../constants';
import type { Container } from '../../container';
import { getContext } from '../../context';
@ -114,7 +115,9 @@ export class CommitDetailsWebviewProvider implements WebviewProvider
pullRequest: undefined,
dateFormat: configuration.get('defaultDateFormat') ?? 'MMMM Do, YYYY h:mma',
// indent: configuration.getAny('workbench.tree.indent') ?? 8,
indentGuides: configuration.getAny('workbench.tree.renderIndentGuides') ?? 'onHover',
indentGuides:
configuration.getAny<CoreConfiguration, Context['indentGuides']>('workbench.tree.renderIndentGuides') ??
'onHover',
navigationStack: {
count: 0,
position: 0,
@ -203,14 +206,17 @@ export class CommitDetailsWebviewProvider implements WebviewProvider
}
private onOtherConfigurationChanged(e: ConfigurationChangeEvent) {
// if (e.affectsConfiguration('workbench.tree.indent')) {
// if (configuration.changedAny<CoreConfiguration>(e, 'workbench.tree.indent')) {
// this.updatePendingContext({ indent: configuration.getAny('workbench.tree.indent') ?? 8 });
// this.updateState();
// }
if (e.affectsConfiguration('workbench.tree.renderIndentGuides')) {
if (configuration.changedAny<CoreConfiguration>(e, 'workbench.tree.renderIndentGuides')) {
this.updatePendingContext({
indentGuides: configuration.getAny('workbench.tree.renderIndentGuides') ?? 'onHover',
indentGuides:
configuration.getAny<CoreConfiguration, Context['indentGuides']>(
'workbench.tree.renderIndentGuides',
) ?? 'onHover',
});
this.updateState();
}

+ 3
- 0
src/webviews/rebase/rebaseEditor.ts 查看文件

@ -8,6 +8,7 @@ import type {
import { ConfigurationTarget, Disposable, Position, Range, Uri, window, workspace, WorkspaceEdit } from 'vscode';
import { getNonce } from '@env/crypto';
import { ShowCommitsInViewCommand } from '../../commands';
import type { CoreConfiguration } from '../../constants';
import { ContextKeys } from '../../constants';
import type { Container } from '../../container';
import { emojify } from '../../emojis';
@ -138,6 +139,7 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
get enabled(): boolean {
const associations = configuration.inspectAny<
CoreConfiguration,
{ [key: string]: string } | { viewType: string; filenamePattern: string }[]
>('workbench.editorAssociations')?.globalValue;
if (associations == null || associations.length === 0) return true;
@ -163,6 +165,7 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
this._disableAfterNextUse = false;
const inspection = configuration.inspectAny<
CoreConfiguration,
{ [key: string]: string } | { viewType: string; filenamePattern: string }[]
>('workbench.editorAssociations');

+ 8
- 10
src/webviews/webviewWithConfigBase.ts 查看文件

@ -1,11 +1,14 @@
import type { ConfigurationChangeEvent } from 'vscode';
import { ConfigurationTarget, Disposable } from 'vscode';
import type { CoreConfiguration } from '../constants';
import type { Container } from '../container';
import { CommitFormatter } from '../git/formatters/commitFormatter';
import { GitCommit, GitCommitIdentity } from '../git/models/commit';
import { GitFileChange, GitFileIndexStatus } from '../git/models/file';
import { PullRequest, PullRequestState } from '../git/models/pullRequest';
import type { ConfigPath } from '../system/configuration';
import { configuration } from '../system/configuration';
import { map } from '../system/iterable';
import { Logger } from '../system/logger';
import type { CustomConfigPath, IpcMessage } from './protocol';
import {
@ -173,14 +176,9 @@ export abstract class WebviewProviderWithConfigBase implements WebviewPro
}
private onOtherConfigurationChanged(e: ConfigurationChangeEvent) {
let notify = false;
for (const setting of this.customSettings.values()) {
if (e.affectsConfiguration(setting.name)) {
notify = true;
break;
}
}
const notify = configuration.changedAny<CustomSetting['name']>(e, [
...map(this.customSettings.values(), s => s.name),
]);
if (!notify) return;
void this.notifyDidChangeConfiguration();
@ -205,7 +203,7 @@ export abstract class WebviewProviderWithConfigBase implements WebviewPro
[
'currentLine.useUncommittedChangesFormat',
{
name: 'currentLine.useUncommittedChangesFormat',
name: 'currentLine.uncommittedChangesFormat',
enabled: () => configuration.get('currentLine.uncommittedChangesFormat') != null,
update: async enabled =>
configuration.updateEffective(
@ -238,7 +236,7 @@ export abstract class WebviewProviderWithConfigBase implements WebviewPro
}
interface CustomSetting {
name: string;
name: ConfigPath | CoreConfiguration;
enabled: () => boolean;
update: (enabled: boolean) => Promise<void>;
}

Loading…
取消
儲存