Selaa lähdekoodia

More configuation changes

main
Eric Amodio 3 vuotta sitten
vanhempi
commit
a85b58280b
11 muutettua tiedostoa jossa 48 lisäystä ja 62 poistoa
  1. +2
    -2
      src/annotations/autolinks.ts
  2. +3
    -3
      src/annotations/fileAnnotationController.ts
  3. +2
    -2
      src/annotations/lineAnnotationController.ts
  4. +3
    -3
      src/codelens/codeLensController.ts
  5. +23
    -37
      src/configuration.ts
  6. +2
    -2
      src/git/gitService.ts
  7. +3
    -3
      src/git/models/repository.ts
  8. +2
    -2
      src/hovers/lineHoverController.ts
  9. +2
    -2
      src/statusbar/statusBarController.ts
  10. +3
    -3
      src/trackers/documentTracker.ts
  11. +3
    -3
      src/views/viewBase.ts

+ 2
- 2
src/annotations/autolinks.ts Näytä tiedosto

@ -34,14 +34,14 @@ export class Autolinks implements Disposable {
constructor() {
this._disposable = Disposable.from(configuration.onDidChange(this.onConfigurationChanged, this));
this.onConfigurationChanged(configuration.initializingChangeEvent);
this.onConfigurationChanged();
}
dispose() {
this._disposable?.dispose();
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
private onConfigurationChanged(e?: ConfigurationChangeEvent) {
if (configuration.changed(e, 'autolinks')) {
this._references = Container.config.autolinks ?? [];
}

+ 3
- 3
src/annotations/fileAnnotationController.ts Näytä tiedosto

@ -83,7 +83,7 @@ export class FileAnnotationController implements Disposable {
this._disposable = Disposable.from(configuration.onDidChange(this.onConfigurationChanged, this));
this._toggleModes = new Map<FileAnnotationType, AnnotationsToggleMode>();
this.onConfigurationChanged(configuration.initializingChangeEvent);
this.onConfigurationChanged();
}
dispose() {
@ -99,7 +99,7 @@ export class FileAnnotationController implements Disposable {
this._disposable?.dispose();
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
private onConfigurationChanged(e?: ConfigurationChangeEvent) {
const cfg = Container.config;
if (configuration.changed(e, 'blame.highlight')) {
@ -189,7 +189,7 @@ export class FileAnnotationController implements Disposable {
});
}
const initializing = configuration.initializing(e);
const initializing = e == null;
if (configuration.changed(e, 'blame.toggleMode')) {
this._toggleModes.set(FileAnnotationType.Blame, cfg.blame.toggleMode);

+ 2
- 2
src/annotations/lineAnnotationController.ts Näytä tiedosto

@ -40,7 +40,7 @@ export class LineAnnotationController implements Disposable {
Container.fileAnnotations.onDidToggleAnnotations(this.onFileAnnotationsToggled, this),
Authentication.onDidChange(() => void this.refresh(window.activeTextEditor)),
);
this.onConfigurationChanged(configuration.initializingChangeEvent);
this.onConfigurationChanged();
}
dispose() {
@ -50,7 +50,7 @@ export class LineAnnotationController implements Disposable {
this._disposable.dispose();
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
private onConfigurationChanged(e?: ConfigurationChangeEvent) {
if (!configuration.changed(e, 'currentLine')) return;
if (configuration.changed(e, 'currentLine.enabled')) {

+ 3
- 3
src/codelens/codeLensController.ts Näytä tiedosto

@ -19,7 +19,7 @@ export class GitCodeLensController implements Disposable {
constructor() {
this._disposable = Disposable.from(configuration.onDidChange(this.onConfigurationChanged, this));
this.onConfigurationChanged(configuration.initializingChangeEvent);
this.onConfigurationChanged();
}
dispose() {
@ -27,14 +27,14 @@ export class GitCodeLensController implements Disposable {
this._disposable?.dispose();
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
private onConfigurationChanged(e?: ConfigurationChangeEvent) {
if (
configuration.changed(e, 'codeLens') ||
configuration.changed(e, 'defaultDateFormat') ||
configuration.changed(e, 'defaultDateSource') ||
configuration.changed(e, 'defaultDateStyle')
) {
if (!configuration.initializing(e)) {
if (e != null) {
Logger.log('CodeLens config changed; resetting CodeLens provider');
}

+ 23
- 37
src/configuration.ts Näytä tiedosto

@ -13,15 +13,7 @@ import {
import { Config } from './config';
import { Objects } from './system';
const extensionId = 'gitlens';
type ConfigInspection<T> = {
key: string;
defaultValue?: T;
globalValue?: T;
workspaceValue?: T;
workspaceFolderValue?: T;
};
const configPrefix = 'gitlens';
export interface ConfigurationWillChangeEvent {
change: ConfigurationChangeEvent;
@ -29,7 +21,7 @@ export interface ConfigurationWillChangeEvent {
}
export class Configuration {
static configure(context: ExtensionContext) {
static configure(context: ExtensionContext): void {
context.subscriptions.push(
workspace.onDidChangeConfiguration(configuration.onConfigurationChanged, configuration),
);
@ -51,7 +43,7 @@ export class Configuration {
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
if (!e.affectsConfiguration(extensionId)) {
if (!e.affectsConfiguration(configPrefix)) {
this._onDidChangeAny.fire(e);
return;
@ -70,8 +62,6 @@ export class Configuration {
this._onDidChange.fire(e);
}
readonly initializingChangeEvent: ConfigurationChangeEvent = { affectsConfiguration: () => true };
get(): Config;
get<T extends ConfigPath>(
section: T,
@ -85,40 +75,33 @@ export class Configuration {
): Config | ConfigPathValue<T> {
return defaultValue === undefined
? workspace
.getConfiguration(section === undefined ? undefined : extensionId, scope)
.get<ConfigPathValue<T>>(section === undefined ? extensionId : section)!
.getConfiguration(section === undefined ? undefined : configPrefix, scope)
.get<ConfigPathValue<T>>(section === undefined ? configPrefix : section)!
: workspace
.getConfiguration(section === undefined ? undefined : extensionId, scope)
.get<ConfigPathValue<T>>(section === undefined ? extensionId : section, defaultValue)!;
.getConfiguration(section === undefined ? undefined : configPrefix, scope)
.get<ConfigPathValue<T>>(section === undefined ? configPrefix : section, defaultValue)!;
}
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) {
getAny<T>(section: string, 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>(
e: ConfigurationChangeEvent,
e: ConfigurationChangeEvent | undefined,
section: T,
scope?: ConfigurationScope | null | undefined,
): boolean {
return e.affectsConfiguration(`${extensionId}.${section}`, scope!);
return e?.affectsConfiguration(`${configPrefix}.${section}`, scope!) ?? true;
}
initializing(e: ConfigurationChangeEvent) {
return e === this.initializingChangeEvent;
}
inspect<T extends ConfigPath>(
section: T,
scope?: ConfigurationScope | null,
): ConfigInspection<ConfigPathValue<T>> | undefined {
inspect<T extends ConfigPath, V extends ConfigPathValue<T>>(section: T, scope?: ConfigurationScope | null) {
return workspace
.getConfiguration(section === undefined ? undefined : extensionId, scope)
.inspect(section === undefined ? extensionId : section);
.getConfiguration(section === undefined ? undefined : configPrefix, scope)
.inspect<V>(section === undefined ? configPrefix : section);
}
inspectAny<T>(section: string, scope?: ConfigurationScope | null) {
@ -270,10 +253,15 @@ export class Configuration {
value: ConfigPathValue<T> | undefined,
target: ConfigurationTarget,
): Thenable<void> {
return workspace.getConfiguration(extensionId).update(section, value, target);
return workspace.getConfiguration(configPrefix).update(section, value, target);
}
updateAny(section: string, value: any, target: ConfigurationTarget, scope?: ConfigurationScope | null) {
updateAny(
section: string,
value: any,
target: ConfigurationTarget,
scope?: ConfigurationScope | null,
): Thenable<void> {
return workspace
.getConfiguration(undefined, target === ConfigurationTarget.Global ? undefined : scope!)
.update(section, value, target);
@ -307,17 +295,15 @@ export class Configuration {
export const configuration = new Configuration();
type PathImpl<T, Key extends keyof T> = Key extends string
type SubPath<T, Key extends keyof T> = Key extends string
? T[Key] extends Record<string, any>
?
| `${Key}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>> & string}`
| `${Key}.${SubPath<T[Key], Exclude<keyof T[Key], keyof any[]>> & string}`
| `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}`
: never
: never;
type PathImpl2<T> = PathImpl<T, keyof T> | keyof T;
type Path<T> = PathImpl2<T> extends string | keyof T ? PathImpl2<T> : keyof T;
type Path<T> = SubPath<T, keyof T> | keyof T extends string | keyof T ? SubPath<T, keyof T> | keyof T : keyof T;
type PathValue<T, P extends Path<T>> = P extends `${infer Key}.${infer Rest}`
? Key extends keyof T

+ 2
- 2
src/git/gitService.ts Näytä tiedosto

@ -162,7 +162,7 @@ export class GitService implements Disposable {
void this.updateContext(this._repositoryTree);
}),
);
this.onConfigurationChanged(configuration.initializingChangeEvent);
this.onConfigurationChanged();
this._repositoriesLoadingPromise = this.onWorkspaceFoldersChanged();
}
@ -237,7 +237,7 @@ export class GitService implements Disposable {
}
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
private onConfigurationChanged(e?: ConfigurationChangeEvent) {
if (
configuration.changed(e, 'defaultDateFormat') ||
configuration.changed(e, 'defaultDateSource') ||

+ 3
- 3
src/git/models/repository.ts Näytä tiedosto

@ -265,7 +265,7 @@ export class Repository implements Disposable {
watcher.onDidDelete(this.onRepositoryChanged, this),
configuration.onDidChange(this.onConfigurationChanged, this),
);
this.onConfigurationChanged(configuration.initializingChangeEvent);
this.onConfigurationChanged();
if (!this.supportsChangeEvents) {
void this.tryWatchingForChangesViaBuiltInApi();
@ -307,11 +307,11 @@ export class Repository implements Disposable {
return this._updatedAt;
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
private onConfigurationChanged(e?: ConfigurationChangeEvent) {
if (configuration.changed(e, 'remotes', this.folder.uri)) {
this._providers = RemoteProviderFactory.loadProviders(configuration.get('remotes', this.folder.uri));
if (!configuration.initializing(e)) {
if (e != null) {
this.resetCaches('remotes');
this.fireChange(RepositoryChange.Remotes);
}

+ 2
- 2
src/hovers/lineHoverController.ts Näytä tiedosto

@ -26,7 +26,7 @@ export class LineHoverController implements Disposable {
constructor() {
this._disposable = Disposable.from(configuration.onDidChange(this.onConfigurationChanged, this));
this.onConfigurationChanged(configuration.initializingChangeEvent);
this.onConfigurationChanged();
}
dispose() {
@ -36,7 +36,7 @@ export class LineHoverController implements Disposable {
this._disposable.dispose();
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
private onConfigurationChanged(e?: ConfigurationChangeEvent) {
if (!configuration.changed(e, 'hovers.enabled') && !configuration.changed(e, 'hovers.currentLine.enabled')) {
return;
}

+ 2
- 2
src/statusbar/statusBarController.ts Näytä tiedosto

@ -27,7 +27,7 @@ export class StatusBarController implements Disposable {
constructor() {
this._disposable = Disposable.from(configuration.onDidChange(this.onConfigurationChanged, this));
this.onConfigurationChanged(configuration.initializingChangeEvent);
this.onConfigurationChanged();
}
dispose() {
@ -40,7 +40,7 @@ export class StatusBarController implements Disposable {
this._disposable.dispose();
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
private onConfigurationChanged(e?: ConfigurationChangeEvent) {
if (configuration.changed(e, 'mode')) {
const mode =
Container.config.mode.active && Container.config.mode.statusBar.enabled

+ 3
- 3
src/trackers/documentTracker.ts Näytä tiedosto

@ -76,7 +76,7 @@ export class DocumentTracker implements Disposable {
workspace.onDidSaveTextDocument(this.onTextDocumentSaved, this),
);
void this.onConfigurationChanged(configuration.initializingChangeEvent);
void this.onConfigurationChanged();
}
dispose() {
@ -89,10 +89,10 @@ export class DocumentTracker implements Disposable {
void this.onActiveTextEditorChanged(window.activeTextEditor);
}
private async onConfigurationChanged(e: ConfigurationChangeEvent) {
private async onConfigurationChanged(e?: ConfigurationChangeEvent) {
// Only rest the cached state if we aren't initializing
if (
!configuration.initializing(e) &&
e != null &&
(configuration.changed(e, 'blame.ignoreWhitespace') || configuration.changed(e, 'advanced.caching.enabled'))
) {
for (const d of this._documentMap.values()) {

+ 3
- 3
src/views/viewBase.ts Näytä tiedosto

@ -149,7 +149,7 @@ export abstract class ViewBase<
this.initialize({ showCollapseAll: this.showCollapseAll });
setImmediate(() => this.onConfigurationChanged(configuration.initializingChangeEvent));
setImmediate(() => this.onConfigurationChanged());
}
protected get showCollapseAll(): boolean {
@ -210,8 +210,8 @@ export abstract class ViewBase<
protected abstract getRoot(): RootNode;
protected abstract registerCommands(): void;
protected onConfigurationChanged(e: ConfigurationChangeEvent): void {
if (!configuration.initializing(e) && this.root != null) {
protected onConfigurationChanged(e?: ConfigurationChangeEvent): void {
if (e != null && this.root != null) {
void this.refresh(true);
}
}

Ladataan…
Peruuta
Tallenna