Browse Source

Adds autoReveal setting for repositories explorer

main
Eric Amodio 6 years ago
parent
commit
d6728b6d82
7 changed files with 36 additions and 9 deletions
  1. +1
    -0
      README.md
  2. +6
    -0
      package.json
  3. +1
    -0
      src/ui/config.ts
  4. +9
    -0
      src/ui/settings/index.html
  5. +1
    -1
      src/views/explorer.ts
  6. +2
    -2
      src/views/nodes/explorerNode.ts
  7. +16
    -6
      src/views/nodes/repositoriesNode.ts

+ 1
- 0
README.md View File

@ -642,6 +642,7 @@ See also [Explorer Settings](#explorer-settings 'Jump to the Explorer settings')
| Name | Description |
| ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gitlens.repositoriesExplorer.autoRefresh` | Specifies whether to automatically refresh the _Repositories_ explorer when the repository or the file system changes |
| `gitlens.repositoriesExplorer.autoReveal` | Specifies whether to automatically reveal repositories in the _Repositories_ explorer when opening files |
| `gitlens.repositoriesExplorer.branches.layout` | Specifies how the _Repositories_ explorer will display branches<br />`list` - displays branches as a list<br />`tree` - displays branches as a tree when branch names contain slashes `/` |
| `gitlens.repositoriesExplorer.enabled` | Specifies whether to show the _Repositories_ explorer |
| `gitlens.repositoriesExplorer.files.compact` | Specifies whether to compact (flatten) unnecessary file nesting in the _Repositories_ explorer<br />Only applies when `gitlens.repositoriesExplorer.files.layout` is set to `tree` or `auto` |

+ 6
- 0
package.json View File

@ -485,6 +485,12 @@
"description": "Specifies whether to automatically refresh the `Repositories` explorer when the repository or the file system changes",
"scope": "window"
},
"gitlens.repositoriesExplorer.autoReveal": {
"type": "boolean",
"default": true,
"description": "Specifies whether to automatically reveal repositories in the `Repositories` explorer when opening files",
"scope": "window"
},
"gitlens.repositoriesExplorer.branches.layout": {
"type": "string",
"default": "tree",

+ 1
- 0
src/ui/config.ts View File

@ -216,6 +216,7 @@ export interface ModeConfig {
export interface RepositoriesExplorerConfig {
autoRefresh: boolean;
autoReveal: boolean;
branches: {
layout: ExplorerBranchesLayout;
};

+ 9
- 0
src/ui/settings/index.html View File

@ -369,6 +369,15 @@
Automatically refreshes when the file system or any repository changes
</label>
</div>
<div class="settings-group__setting nowrap ml-2 hidden" data-enablement="repositoriesExplorer.enabled"
data-visibility="settings.mode =advanced">
<input class="setting" id="repositoriesExplorer.autoReveal" name="repositoriesExplorer.autoReveal"
type="checkbox" disabled />
<label for="repositoriesExplorer.autoReveal">
Automatically reveal repositories when opening files
</label>
</div>
</div>
<div class="section__preview">
<img class="image__preview hidden" src="{{root}}/images/settings/repositories-explorer.png"

+ 1
- 1
src/views/explorer.ts View File

@ -120,7 +120,7 @@ export abstract class ExplorerBase implements TreeDa
Logger.log(`Explorer(${this.id}).refresh`, `reason='${reason}'`);
if (this._root !== undefined) {
await this._root.refresh();
await this._root.refresh(reason);
}
this.triggerNodeUpdate();

+ 2
- 2
src/views/nodes/explorerNode.ts View File

@ -1,7 +1,7 @@
'use strict';
import { Command, Disposable, Event, TreeItem, TreeViewVisibilityChangeEvent } from 'vscode';
import { GitUri } from '../../git/gitService';
import { Explorer } from '../explorer';
import { Explorer, RefreshReason } from '../explorer';
export enum ResourceType {
ActiveFileHistory = 'gitlens:active:history-file',
@ -71,7 +71,7 @@ export abstract class ExplorerNode {
return undefined;
}
refresh(): void | boolean | Promise<void> | Promise<boolean> {}
refresh(reason?: RefreshReason): void | boolean | Promise<void> | Promise<boolean> {}
}
export abstract class ExplorerRefNode extends ExplorerNode {

+ 16
- 6
src/views/nodes/repositoriesNode.ts View File

@ -4,6 +4,7 @@ import { Container } from '../../container';
import { GitUri } from '../../git/gitService';
import { Logger } from '../../logger';
import { Functions } from '../../system';
import { RefreshReason } from '../explorer';
import { RepositoriesExplorer } from '../repositoriesExplorer';
import { MessageNode } from './common';
import { ExplorerNode, ResourceType, SubscribeableExplorerNode, unknownGitUri } from './explorerNode';
@ -112,7 +113,7 @@ export class RepositoriesNode extends SubscribeableExplorerNode
);
}
async refresh() {
async refresh(reason?: RefreshReason) {
if (this._children === undefined) return;
const repositories = [...(await Container.git.getRepositories())];
@ -143,16 +144,25 @@ export class RepositoriesNode extends SubscribeableExplorerNode
}
this._children = children;
// Reset our subscription if the configuration changed
if (reason === RefreshReason.ConfigurationChanged) {
this.unsubscribe();
}
void this.ensureSubscription();
}
protected async subscribe() {
// TODO: Add a setting to control tracking the active editor
const subscriptions = [Container.git.onDidChangeRepositories(this.onRepositoriesChanged, this)];
return Disposable.from(
window.onDidChangeActiveTextEditor(Functions.debounce(this.onActiveEditorChanged, 500), this),
Container.git.onDidChangeRepositories(this.onRepositoriesChanged, this)
);
if (this.explorer.config.autoReveal) {
subscriptions.push(
window.onDidChangeActiveTextEditor(Functions.debounce(this.onActiveEditorChanged, 500), this)
);
}
return Disposable.from(...subscriptions);
}
private async onActiveEditorChanged(editor: TextEditor | undefined) {

Loading…
Cancel
Save