Sfoglia il codice sorgente

Changes config.changed to always return true when initializing

Fixes auto-refresh context on repositories view loading
main
Eric Amodio 6 anni fa
parent
commit
70933cfa13
15 ha cambiato i file con 34 aggiunte e 68 eliminazioni
  1. +7
    -7
      src/annotations/fileAnnotationController.ts
  2. +2
    -4
      src/annotations/lineAnnotationController.ts
  3. +1
    -4
      src/codelens/codeLensController.ts
  4. +1
    -1
      src/configuration.ts
  5. +0
    -3
      src/git/gitService.ts
  6. +2
    -4
      src/git/models/repository.ts
  7. +0
    -3
      src/hovers/lineHoverController.ts
  8. +1
    -3
      src/logger.ts
  9. +3
    -5
      src/statusbar/statusBarController.ts
  10. +6
    -6
      src/system/decorators.ts
  11. +2
    -4
      src/trackers/documentTracker.ts
  12. +2
    -6
      src/views/fileHistoryView.ts
  13. +2
    -6
      src/views/lineHistoryView.ts
  14. +2
    -6
      src/views/repositoriesView.ts
  15. +3
    -6
      src/views/resultsView.ts

+ 7
- 7
src/annotations/fileAnnotationController.ts Vedi File

@ -87,11 +87,9 @@ export class FileAnnotationController implements Disposable {
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
const initializing = configuration.initializing(e);
const cfg = Container.config;
if (initializing || configuration.changed(e, configuration.name('blame')('highlight').value)) {
if (configuration.changed(e, configuration.name('blame')('highlight').value)) {
Decorations.blameHighlight && Decorations.blameHighlight.dispose();
const cfgHighlight = cfg.blame.highlight;
@ -124,7 +122,7 @@ export class FileAnnotationController implements Disposable {
}
}
if (initializing || configuration.changed(e, configuration.name('recentChanges')('highlight').value)) {
if (configuration.changed(e, configuration.name('recentChanges')('highlight').value)) {
Decorations.recentChangesAnnotation && Decorations.recentChangesAnnotation.dispose();
const cfgHighlight = cfg.recentChanges.highlight;
@ -152,21 +150,23 @@ export class FileAnnotationController implements Disposable {
});
}
if (initializing || configuration.changed(e, configuration.name('blame')('toggleMode').value)) {
const initializing = configuration.initializing(e);
if (configuration.changed(e, configuration.name('blame')('toggleMode').value)) {
this._toggleModes.set(FileAnnotationType.Blame, cfg.blame.toggleMode);
if (!initializing && cfg.blame.toggleMode === AnnotationsToggleMode.File) {
void this.clearAll();
}
}
if (initializing || configuration.changed(e, configuration.name('heatmap')('toggleMode').value)) {
if (configuration.changed(e, configuration.name('heatmap')('toggleMode').value)) {
this._toggleModes.set(FileAnnotationType.Heatmap, cfg.heatmap.toggleMode);
if (!initializing && cfg.heatmap.toggleMode === AnnotationsToggleMode.File) {
void this.clearAll();
}
}
if (initializing || configuration.changed(e, configuration.name('recentChanges')('toggleMode').value)) {
if (configuration.changed(e, configuration.name('recentChanges')('toggleMode').value)) {
this._toggleModes.set(FileAnnotationType.RecentChanges, cfg.recentChanges.toggleMode);
if (!initializing && cfg.recentChanges.toggleMode === AnnotationsToggleMode.File) {
void this.clearAll();

+ 2
- 4
src/annotations/lineAnnotationController.ts Vedi File

@ -49,11 +49,9 @@ export class LineAnnotationController implements Disposable {
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
const initializing = configuration.initializing(e);
if (!configuration.changed(e, configuration.name('currentLine').value)) return;
if (!initializing && !configuration.changed(e, configuration.name('currentLine').value)) return;
if (initializing || configuration.changed(e, configuration.name('currentLine')('enabled').value)) {
if (configuration.changed(e, configuration.name('currentLine')('enabled').value)) {
if (Container.config.currentLine.enabled) {
this._enabled = true;
this.resume();

+ 1
- 4
src/codelens/codeLensController.ts Vedi File

@ -28,16 +28,13 @@ export class GitCodeLensController implements Disposable {
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
const initializing = configuration.initializing(e);
const section = configuration.name('codeLens').value;
if (
initializing ||
configuration.changed(e, section, null) ||
configuration.changed(e, configuration.name('defaultDateStyle').value) ||
configuration.changed(e, configuration.name('defaultDateFormat').value)
) {
if (!initializing) {
if (!configuration.initializing(e)) {
Logger.log('CodeLens config changed; resetting CodeLens provider');
}

+ 1
- 1
src/configuration.ts Vedi File

@ -86,7 +86,7 @@ export class Configuration {
}
readonly initializingChangeEvent: ConfigurationChangeEvent = {
affectsConfiguration: (section: string, resource?: Uri) => false
affectsConfiguration: (section: string, resource?: Uri) => true
};
get<T>(section?: string, resource?: Uri | null, defaultValue?: T) {

+ 0
- 3
src/git/gitService.ts Vedi File

@ -145,10 +145,7 @@ export class GitService implements Disposable {
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
const initializing = configuration.initializing(e);
if (
initializing ||
configuration.changed(e, configuration.name('defaultDateStyle').value) ||
configuration.changed(e, configuration.name('defaultDateFormat').value)
) {

+ 2
- 4
src/git/models/repository.ts Vedi File

@ -150,15 +150,13 @@ export class Repository implements Disposable {
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
const initializing = configuration.initializing(e);
const section = configuration.name('remotes').value;
if (initializing || configuration.changed(e, section, this.folder.uri)) {
if (configuration.changed(e, section, this.folder.uri)) {
this._providers = RemoteProviderFactory.loadProviders(
configuration.get<RemotesConfig[] | null | undefined>(section, this.folder.uri)
);
if (!initializing) {
if (!configuration.initializing(e)) {
this._remotes = undefined;
this.fireChange(RepositoryChange.Remotes);
}

+ 0
- 3
src/hovers/lineHoverController.ts Vedi File

@ -41,10 +41,7 @@ export class LineHoverController implements Disposable {
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
const initializing = configuration.initializing(e);
if (
!initializing &&
!configuration.changed(e, configuration.name('hovers')('enabled').value) &&
!configuration.changed(e, configuration.name('hovers')('currentLine')('enabled').value)
) {

+ 1
- 3
src/logger.ts Vedi File

@ -20,10 +20,8 @@ export class Logger {
}
private static onConfigurationChanged(e: ConfigurationChangeEvent) {
const initializing = configuration.initializing(e);
const section = configuration.name('outputLevel').value;
if (initializing || configuration.changed(e, section)) {
if (configuration.changed(e, section)) {
this.level = configuration.get<LogLevel>(section);
if (this.level === LogLevel.Silent) {

+ 3
- 5
src/statusbar/statusBarController.ts Vedi File

@ -28,9 +28,7 @@ export class StatusBarController implements Disposable {
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
const initializing = configuration.initializing(e);
if (initializing || configuration.changed(e, configuration.name('mode').value)) {
if (configuration.changed(e, configuration.name('mode').value)) {
const mode =
Container.config.mode.active && Container.config.mode.statusBar.enabled
? Container.config.modes[Container.config.mode.active]
@ -64,7 +62,7 @@ export class StatusBarController implements Disposable {
}
}
if (!initializing && !configuration.changed(e, configuration.name('statusBar').value)) return;
if (!configuration.changed(e, configuration.name('statusBar').value)) return;
if (Container.config.statusBar.enabled) {
const alignment =
@ -82,7 +80,7 @@ export class StatusBarController implements Disposable {
window.createStatusBarItem(alignment, alignment === StatusBarAlignment.Right ? 1000 : 0);
this._blameStatusBarItem.command = Container.config.statusBar.command;
if (initializing || configuration.changed(e, configuration.name('statusBar')('enabled').value)) {
if (configuration.changed(e, configuration.name('statusBar')('enabled').value)) {
Container.lineTracker.start(
this,
Disposable.from(Container.lineTracker.onDidChangeActiveLines(this.onActiveLinesChanged, this))

+ 6
- 6
src/system/decorators.ts Vedi File

@ -35,6 +35,12 @@ export interface LogContext {
export const LogInstanceNameFn = Symbol('logInstanceNameFn');
export function logName<T>(fn: (c: T, name: string) => string) {
return (target: Function) => {
(target as any)[LogInstanceNameFn] = fn;
};
}
export function debug<T>(
options: {
args?: boolean | { [arg: string]: (arg: any) => string };
@ -48,12 +54,6 @@ export function debug(
return log<T>({ debug: true, ...options });
}
export function logName<T>(fn: (c: T, name: string) => string) {
return (target: Function) => {
(target as any)[LogInstanceNameFn] = fn;
};
}
export function log<T>(
options: {
args?: boolean | { [arg: string]: (arg: any) => string };

+ 2
- 4
src/trackers/documentTracker.ts Vedi File

@ -78,11 +78,9 @@ export class DocumentTracker implements Disposable {
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
const initializing = configuration.initializing(e);
// Only rest the cached state if we aren't initializing
if (
!initializing &&
!configuration.initializing(e) &&
(configuration.changed(e, configuration.name('blame')('ignoreWhitespace').value, null) ||
configuration.changed(e, configuration.name('advanced')('caching')('enabled').value))
) {
@ -92,7 +90,7 @@ export class DocumentTracker implements Disposable {
}
const section = configuration.name('advanced')('blame')('delayAfterEdit').value;
if (initializing || configuration.changed(e, section)) {
if (configuration.changed(e, section)) {
this._dirtyIdleTriggerDelay = configuration.get<number>(section);
this._dirtyIdleTriggeredDebounced = undefined;
}

+ 2
- 6
src/views/fileHistoryView.ts Vedi File

@ -48,10 +48,7 @@ export class FileHistoryView extends ViewBase {
}
protected onConfigurationChanged(e: ConfigurationChangeEvent) {
const initializing = configuration.initializing(e);
if (
!initializing &&
!configuration.changed(e, configuration.name('views')('fileHistory').value) &&
!configuration.changed(e, configuration.name('views').value) &&
!configuration.changed(e, configuration.name('defaultGravatarsStyle').value) &&
@ -61,7 +58,6 @@ export class FileHistoryView extends ViewBase {
}
if (
initializing ||
configuration.changed(e, configuration.name('views')('fileHistory')('enabled').value) ||
configuration.changed(e, configuration.name('views')('fileHistory')('location').value)
) {
@ -69,11 +65,11 @@ export class FileHistoryView extends ViewBase {
setCommandContext(CommandContext.ViewsFileHistoryEditorFollowing, true);
}
if (initializing || configuration.changed(e, configuration.name('views')('fileHistory')('location').value)) {
if (configuration.changed(e, configuration.name('views')('fileHistory')('location').value)) {
this.initialize(this.config.location);
}
if (!initializing && this._root !== undefined) {
if (!configuration.initializing(e) && this._root !== undefined) {
void this.refresh(RefreshReason.ConfigurationChanged);
}
}

+ 2
- 6
src/views/lineHistoryView.ts Vedi File

@ -47,10 +47,7 @@ export class LineHistoryView extends ViewBase {
}
protected onConfigurationChanged(e: ConfigurationChangeEvent) {
const initializing = configuration.initializing(e);
if (
!initializing &&
!configuration.changed(e, configuration.name('views')('lineHistory').value) &&
!configuration.changed(e, configuration.name('views').value) &&
!configuration.changed(e, configuration.name('defaultGravatarsStyle').value) &&
@ -60,7 +57,6 @@ export class LineHistoryView extends ViewBase {
}
if (
initializing ||
configuration.changed(e, configuration.name('views')('lineHistory')('enabled').value) ||
configuration.changed(e, configuration.name('views')('lineHistory')('location').value)
) {
@ -68,11 +64,11 @@ export class LineHistoryView extends ViewBase {
setCommandContext(CommandContext.ViewsLineHistoryEditorFollowing, true);
}
if (initializing || configuration.changed(e, configuration.name('views')('lineHistory')('location').value)) {
if (configuration.changed(e, configuration.name('views')('lineHistory')('location').value)) {
this.initialize(this.config.location);
}
if (!initializing && this._root !== undefined) {
if (!configuration.initializing(e) && this._root !== undefined) {
void this.refresh(RefreshReason.ConfigurationChanged);
}
}

+ 2
- 6
src/views/repositoriesView.ts Vedi File

@ -63,10 +63,7 @@ export class RepositoriesView extends ViewBase {
}
protected onConfigurationChanged(e: ConfigurationChangeEvent) {
const initializing = configuration.initializing(e);
if (
!initializing &&
!configuration.changed(e, configuration.name('views')('repositories').value) &&
!configuration.changed(e, configuration.name('views').value) &&
!configuration.changed(e, configuration.name('defaultGravatarsStyle').value)
@ -75,7 +72,6 @@ export class RepositoriesView extends ViewBase {
}
if (
initializing ||
configuration.changed(e, configuration.name('views')('repositories')('enabled').value) ||
configuration.changed(e, configuration.name('views')('repositories')('location').value)
) {
@ -86,11 +82,11 @@ export class RepositoriesView extends ViewBase {
void this.setAutoRefresh(Container.config.views.repositories.autoRefresh);
}
if (initializing || configuration.changed(e, configuration.name('views')('repositories')('location').value)) {
if (configuration.changed(e, configuration.name('views')('repositories')('location').value)) {
this.initialize(this.config.location);
}
if (!initializing && this._root !== undefined) {
if (!configuration.initializing(e) && this._root !== undefined) {
void this.refresh(RefreshReason.ConfigurationChanged);
}
}

+ 3
- 6
src/views/resultsView.ts Vedi File

@ -68,10 +68,7 @@ export class ResultsView extends ViewBase {
}
protected onConfigurationChanged(e: ConfigurationChangeEvent) {
const initializing = configuration.initializing(e);
if (
!initializing &&
!configuration.changed(e, configuration.name('views')('results').value) &&
!configuration.changed(e, configuration.name('views').value) &&
!configuration.changed(e, configuration.name('defaultGravatarsStyle').value)
@ -79,15 +76,15 @@ export class ResultsView extends ViewBase {
return;
}
if (initializing || configuration.changed(e, configuration.name('views')('results')('location').value)) {
if (configuration.changed(e, configuration.name('views')('results')('location').value)) {
setCommandContext(CommandContext.ViewsResults, this.enabled ? this.config.location : false);
}
if (initializing || configuration.changed(e, configuration.name('views')('results')('location').value)) {
if (configuration.changed(e, configuration.name('views')('results')('location').value)) {
this.initialize(this.config.location);
}
if (!initializing && this._root !== undefined) {
if (!configuration.initializing(e) && this._root !== undefined) {
void this.refresh(RefreshReason.ConfigurationChanged);
}
}

Caricamento…
Annulla
Salva