Bladeren bron

Adds logging to explorer refresh

main
Eric Amodio 7 jaren geleden
bovenliggende
commit
3dd302ce74
2 gewijzigde bestanden met toevoegingen van 29 en 7 verwijderingen
  1. +25
    -7
      src/views/gitExplorer.ts
  2. +4
    -0
      src/views/statusNode.ts

+ 25
- 7
src/views/gitExplorer.ts Bestand weergeven

@ -7,9 +7,20 @@ import { ExtensionKey, GitExplorerFilesLayout, IConfig } from '../configuration'
import { CommandContext, GlyphChars, setCommandContext, WorkspaceState } from '../constants';
import { BranchHistoryNode, CommitFileNode, CommitNode, ExplorerNode, HistoryNode, MessageNode, RepositoriesNode, RepositoryNode, StashNode } from './explorerNodes';
import { GitService, GitUri, RepoChangedReasons } from '../gitService';
import { Logger } from '../logger';
export * from './explorerNodes';
enum RefreshReason {
ActiveEditorChanged = 'active-editor-changed',
AutoRefreshChanged = 'auto-refresh-changed',
Command = 'command',
NodeCommand = 'node-command',
RepoChanged = 'repo-changed',
ViewChanged = 'view-changed',
VisibleEditorsChanged = 'visible-editors-changed'
}
export enum GitExplorerView {
Auto = 'auto',
History = 'history',
@ -139,7 +150,7 @@ export class GitExplorer implements TreeDataProvider {
if (root === this._root) return;
this._root = root;
this.refresh(undefined, root);
this.refresh(RefreshReason.ActiveEditorChanged, undefined, root);
}
private onConfigurationChanged() {
@ -175,7 +186,9 @@ export class GitExplorer implements TreeDataProvider {
this._root = undefined;
}
this.refresh();
Logger.log(`GitExplorer[view=${this._view}].onRepoChanged(${reasons.join()})`);
this.refresh(RefreshReason.RepoChanged);
}
private onVisibleEditorsChanged(editors: TextEditor[]) {
@ -186,11 +199,16 @@ export class GitExplorer implements TreeDataProvider {
if (this._root === undefined) return;
this._root = undefined;
this.refresh();
this.refresh(RefreshReason.VisibleEditorsChanged);
}
}
async refresh(node?: ExplorerNode, root?: ExplorerNode) {
async refresh(reason: RefreshReason | undefined, node?: ExplorerNode, root?: ExplorerNode) {
if (reason === undefined) {
reason = RefreshReason.Command;
}
Logger.log(`GitExplorer[view=${this._view}].refresh`, `reason='${reason}'`);
if (this._root === undefined || (root === undefined && this._view === GitExplorerView.History)) {
this._root = await this.getRootNode(window.activeTextEditor);
}
@ -203,7 +221,7 @@ export class GitExplorer implements TreeDataProvider {
node.maxCount = args.maxCount;
}
this.refresh(node);
this.refresh(RefreshReason.NodeCommand, node);
}
async reset(view: GitExplorerView, force: boolean = false) {
@ -214,7 +232,7 @@ export class GitExplorer implements TreeDataProvider {
}
this._root = await this.getRootNode(window.activeTextEditor);
if (force) {
this.refresh();
this.refresh(RefreshReason.ViewChanged);
}
}
@ -352,7 +370,7 @@ export class GitExplorer implements TreeDataProvider {
setCommandContext(CommandContext.GitExplorerAutoRefresh, enabled);
if (userToggle) {
this.refresh();
this.refresh(RefreshReason.AutoRefreshChanged);
}
}

+ 4
- 0
src/views/statusNode.ts Bestand weergeven

@ -2,6 +2,7 @@ import { commands, ExtensionContext, TreeItem, TreeItemCollapsibleState, Uri } f
import { WorkspaceState } from '../constants';
import { ExplorerNode, ResourceType } from './explorerNode';
import { GitService, GitStatus, GitUri, Repository, RepositoryStorage } from '../gitService';
import { Logger } from '../logger';
import { StatusFilesNode } from './statusFilesNode';
import { StatusUpstreamNode } from './statusUpstreamNode';
@ -115,11 +116,14 @@ export class StatusNode extends ExplorerNode {
// This is because of https://github.com/Microsoft/vscode/issues/34789
if (this._status !== undefined && status !== undefined &&
((this._status.files.length === status.files.length) || (this._status.files.length > 0 && status.files.length > 0))) {
Logger.log(`GitExplorer.StatusNode.onFileSystemChanged(${uri && uri.fsPath}); triggering node refresh`);
commands.executeCommand('gitlens.gitExplorer.refreshNode', this);
return;
}
Logger.log(`GitExplorer.StatusNode.onFileSystemChanged(${uri && uri.fsPath}); triggering refresh`);
commands.executeCommand('gitlens.gitExplorer.refresh');
}
}

Laden…
Annuleren
Opslaan