Bläddra i källkod

Removes docked history view (wip)

main
Eric Amodio 6 år sedan
förälder
incheckning
37798357cb
26 ändrade filer med 172 tillägg och 483 borttagningar
  1. +15
    -28
      README.md
  2. +4
    -138
      package.json
  3. +1
    -2
      src/commands/showGitExplorer.ts
  4. +1
    -6
      src/commands/showHistoryExplorer.ts
  5. +0
    -2
      src/constants.ts
  6. +0
    -7
      src/ui/config.ts
  7. +0
    -0
      src/ui/images/settings/gitlens-explorer-avatars.png
  8. Binär
      src/ui/images/settings/gitlens-explorer-history.png
  9. Binär
      src/ui/images/settings/gitlens-explorer-repository-history-docked.png
  10. Binär
      src/ui/images/settings/gitlens-explorer-repository-history-undocked.png
  11. +0
    -0
      src/ui/images/settings/gitlens-explorer-tree-compact.png
  12. +0
    -0
      src/ui/images/settings/gitlens-explorer-tree.png
  13. +0
    -0
      src/ui/images/settings/gitlens-explorer.png
  14. +0
    -0
      src/ui/images/settings/gitlens-file-history-explorer-avatars.png
  15. +0
    -0
      src/ui/images/settings/gitlens-file-history-explorer.png
  16. Binär
      src/ui/images/settings/gitlens-history-explorer-close.png
  17. +7
    -51
      src/ui/settings/index.html
  18. +96
    -0
      src/views/explorer.ts
  19. +27
    -185
      src/views/gitExplorer.ts
  20. +21
    -64
      src/views/historyExplorer.ts

+ 15
- 28
README.md Visa fil

@ -146,19 +146,16 @@ For more advanced customizations, refer to the [settings documentation](#gitlens
### GitLens Explorer
A [customizable](#gitlens-explorer-settings 'Jump to the GitLens Explorer settings') explorer to navigate and explore repositories or file histories. The _GitLens_ explorer provides two views (modes) — a Repository view and a File History view.
- A toolbar provides _Search Commits_, _Switch to Repository View_ or _Switch to File History View_, and _Refresh_ commands
- Quickly switch between views using the _Switch to Repository View_ or _Switch to File History View_ commands
- A context menu provides _Automatic Layout_, _List Layout_, _Tree Layout_, _Enable Automatic Refresh_ or _Disable Automatic Refresh_, and _Follow Renames_ or _Don't Follow Renames_ commands
#### Repository view
<p align="center">
<img src="https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/ss-gitlens-explorer-repository.png" alt="GitLens Explorer Repository view" />
<img src="https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/ss-gitlens-explorer-repository.png" alt="GitLens Explorer" />
</p>
The repository view provides a full Git repository explorer, which has the following features,
A [customizable](#gitlens-explorer-settings 'Jump to the GitLens Explorer settings') explorer to navigate and explore repositories.
- A toolbar provides _Search Commits_, and _Refresh_ commands
- A context menu provides _Automatic Layout_, _List Layout_, _Tree Layout_, and _Enable Automatic Refresh_ or _Disable Automatic Refresh_ commands
The explorer provides a full Git repository explorer, which has the following features,
- **Repository Status**
@ -223,20 +220,6 @@ The repository view provides a full Git repository explorer, which has the follo
- Revisions (commits) expand to show the set of files changed, complete with status indicators for adds, changes, renames, and deletes
- See the _Revisions (commits) expand_ section under **Branches** above for more details
### File History view
<p align="center">
<img src="https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/ss-gitlens-explorer-history.png" alt="GitLens Explorer File History view" />
</p>
The file history view provides the revision history of the current file, which has the following features,
- Automatically updates to track the current editor
- A context menu provides _Open File_, _Open File in Remote_ (if available), and _Refresh_ commands
- An inline toolbar provides an _Open File_ command
- Context menus for each revision (commit) provides
- _Open Changes_, _Open Changes with Working File_, _Open File_, _Open Revision_, _Open File in Remote_ (if available), _Open Revision in Remote_ (if available), _Apply Changes_, _Compare with Selected_ (when available), _Select for Compare_, and _Show Commit File Details_ commands
---
### GitLens File History Explorer
@ -245,7 +228,12 @@ The file history view provides the revision history of the current file, which h
<img src="https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/ss-gitlens-history-explorer.png" alt="GitLens File History Explorer" />
</p>
A [customizable](#gitlens-file-history-explorer-settings 'Jump to the GitLens File History Explorer settings') stand-alone explorer to visualize the history of the current file &mdash; undocked version of the _GitLens_ Explorer history view
A [customizable](#gitlens-file-history-explorer-settings 'Jump to the GitLens File History Explorer settings') explorer to visualize the revision history of the current file.
- A toolbar provides a _Refresh_ command
- A context menu provides a _Follow Renames_ or _Don't Follow Renames_ command
The file history view provides the revision history of the current file, which has the following features,
- Automatically updates to track the current editor
- A context menu provides _Open File_, _Open File in Remote_ (if available), and _Refresh_ commands
@ -681,14 +669,13 @@ See also [Explorer Settings](#explorer-settings 'Jump to the Explorer settings')
| ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gitlens.gitExplorer.autoRefresh` | Specifies whether to automatically refresh the _GitLens_ explorer when the repository or the file system changes |
| `gitlens.gitExplorer.branches.layout` | Specifies how the _GitLens_ explorer will display branches<br />`list` - displays branches as a list<br />`tree` - displays branches as a tree when branch names contain slashes `/` |
| `gitlens.gitExplorer.enabled` | Specifies whether to show the _GitLens_ explorer" |
| `gitlens.gitExplorer.enabled` | Specifies whether to show the _GitLens_ explorer |
| `gitlens.gitExplorer.files.compact` | Specifies whether to compact (flatten) unnecessary file nesting in the _GitLens_ explorer<br />Only applies when `gitlens.gitExplorer.files.layout` is set to `tree` or `auto` |
| `gitlens.gitExplorer.files.layout` | Specifies how the _GitLens_ explorer will display files<br />`auto` - automatically switches between displaying files as a `tree` or `list` based on the `gitlens.gitExplorer.files.threshold` value and the number of files at each nesting level<br />`list` - displays files as a list<br />`tree` - displays files as a tree |
| `gitlens.gitExplorer.files.threshold` | Specifies when to switch between displaying files as a `tree` or `list` based on the number of files in a nesting level in the _GitLens_ explorer<br />Only applies when `gitlens.gitExplorer.files.layout` is set to `auto` |
| `gitlens.gitExplorer.includeWorkingTree` | Specifies whether to include working tree files inside the `Repository Status` node of the _GitLens_ explorer |
| `gitlens.gitExplorer.location` | Specifies where to show the _GitLens_ explorer<br />`gitlens` - adds to the GitLens view<br />`explorer` - adds to the Explorer view<br />`scm` - adds to the Source Control view |
| `gitlens.gitExplorer.showTrackingBranch` | Specifies whether to show the tracking branch when displaying local branches in the _GitLens_ explorer" |
| `gitlens.gitExplorer.view` | Specifies the starting view of the _GitLens_ explorer<br />`auto` - shows the last selected view, defaults to `repository`<br />`history` - shows the commit history of the current file<br />`repository` - shows a repository explorer" |
| `gitlens.gitExplorer.showTrackingBranch` | Specifies whether to show the tracking branch when displaying local branches in the _GitLens_ explorer |
### GitLens File History Explorer Settings

+ 4
- 138
package.json Visa fil

@ -555,22 +555,6 @@
"description": "Specifies whether to show the tracking branch when displaying local branches in the `GitLens` explorer",
"scope": "window"
},
"gitlens.gitExplorer.view": {
"type": "string",
"default": "auto",
"enum": [
"auto",
"history",
"repository"
],
"enumDescriptions": [
"Shows the last selected view, defaults to `repository`",
"Shows the commit history of the current file",
"Shows a repository explorer"
],
"description": "Specifies the starting view of the `GitLens` explorer",
"scope": "window"
},
"gitlens.heatmap.ageThreshold": {
"type": "string",
"default": "90",
@ -1985,15 +1969,6 @@
"category": "GitLens"
},
{
"command": "gitlens.gitExplorer.undockHistory",
"title": "Undock File History from GitLens Explorer",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-undock.svg",
"light": "images/light/icon-undock.svg"
}
},
{
"command": "gitlens.gitExplorer.refresh",
"title": "Refresh",
"category": "GitLens",
@ -2033,52 +2008,6 @@
"category": "GitLens"
},
{
"command": "gitlens.gitExplorer.setRenameFollowingOn",
"title": "Follow Renames",
"category": "GitLens"
},
{
"command": "gitlens.gitExplorer.setRenameFollowingOff",
"title": "Don't Follow Renames",
"category": "GitLens"
},
{
"command": "gitlens.gitExplorer.switchToHistoryView",
"title": "Switch to File History View",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-history.svg",
"light": "images/light/icon-history.svg"
}
},
{
"command": "gitlens.gitExplorer.switchToRepositoryView",
"title": "Switch to Repository View",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-repo.svg",
"light": "images/light/icon-repo.svg"
}
},
{
"command": "gitlens.historyExplorer.close",
"title": "Close",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-close.svg",
"light": "images/light/icon-close.svg"
}
},
{
"command": "gitlens.historyExplorer.dock",
"title": "Dock File History to GitLens Explorer",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-dock.svg",
"light": "images/light/icon-dock.svg"
}
},
{
"command": "gitlens.historyExplorer.refresh",
"title": "Refresh",
"category": "GitLens",
@ -2560,34 +2489,6 @@
"when": "false"
},
{
"command": "gitlens.gitExplorer.setRenameFollowingOn",
"when": "false"
},
{
"command": "gitlens.gitExplorer.setRenameFollowingOff",
"when": "false"
},
{
"command": "gitlens.gitExplorer.switchToHistoryView",
"when": "gitlens:enabled && !gitlens:historyExplorer && gitlens:gitExplorer:view == repository"
},
{
"command": "gitlens.gitExplorer.switchToRepositoryView",
"when": "gitlens:enabled && !gitlens:historyExplorer && gitlens:gitExplorer:view == history"
},
{
"command": "gitlens.gitExplorer.undockHistory",
"when": "gitlens:enabled && !gitlens:historyExplorer"
},
{
"command": "gitlens.historyExplorer.close",
"when": "false"
},
{
"command": "gitlens.historyExplorer.dock",
"when": "gitlens:enabled && gitlens:historyExplorer"
},
{
"command": "gitlens.historyExplorer.refresh",
"when": "false"
},
@ -2876,38 +2777,23 @@
"group": "navigation@1"
},
{
"command": "gitlens.gitExplorer.undockHistory",
"when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == history && !gitlens:historyExplorer",
"group": "navigation@2"
},
{
"command": "gitlens.gitExplorer.switchToHistoryView",
"when": "view =~ /^gitlens.gitExplorer:/ && !gitlens:historyExplorer && gitlens:gitExplorer:view == repository",
"group": "navigation@3"
},
{
"command": "gitlens.gitExplorer.switchToRepositoryView",
"when": "view =~ /^gitlens.gitExplorer:/ && !gitlens:historyExplorer && gitlens:gitExplorer:view == history",
"group": "navigation@3"
},
{
"command": "gitlens.gitExplorer.refresh",
"when": "view =~ /^gitlens.gitExplorer:/",
"group": "navigation@8"
},
{
"command": "gitlens.gitExplorer.setFilesLayoutToAuto",
"when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == repository",
"when": "view =~ /^gitlens.gitExplorer:/",
"group": "1_gitlens"
},
{
"command": "gitlens.gitExplorer.setFilesLayoutToList",
"when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == repository",
"when": "view =~ /^gitlens.gitExplorer:/",
"group": "1_gitlens"
},
{
"command": "gitlens.gitExplorer.setFilesLayoutToTree",
"when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == repository",
"when": "view =~ /^gitlens.gitExplorer:/",
"group": "1_gitlens"
},
{
@ -2921,31 +2807,11 @@
"group": "2_gitlens"
},
{
"command": "gitlens.gitExplorer.setRenameFollowingOn",
"when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == history && !config.gitlens.advanced.fileHistoryFollowsRenames",
"group": "2_gitlens_1"
},
{
"command": "gitlens.gitExplorer.setRenameFollowingOff",
"when": "view =~ /^gitlens.gitExplorer:/ && gitlens:gitExplorer:view == history && config.gitlens.advanced.fileHistoryFollowsRenames",
"group": "2_gitlens_1"
},
{
"command": "gitlens.historyExplorer.refresh",
"when": "view =~ /^gitlens.historyExplorer:/",
"group": "navigation@1"
},
{
"command": "gitlens.historyExplorer.dock",
"when": "view =~ /^gitlens.historyExplorer:/ && gitlens:gitExplorer",
"group": "navigation@9"
},
{
"command": "gitlens.historyExplorer.close",
"when": "view =~ /^gitlens.historyExplorer:/ && !gitlens:gitExplorer",
"group": "navigation@9"
},
{
"command": "gitlens.historyExplorer.setRenameFollowingOn",
"when": "view =~ /^gitlens.historyExplorer:/ && !config.gitlens.advanced.fileHistoryFollowsRenames",
"group": "1_gitlens"
@ -3204,7 +3070,7 @@
},
{
"command": "gitlens.showQuickFileHistory",
"when": "viewItem =~ /gitlens:file\\b/ && gitlens:gitExplorer:view == repository",
"when": "viewItem =~ /gitlens:file\\b/",
"group": "8_gitlens@1"
},
{

+ 1
- 2
src/commands/showGitExplorer.ts Visa fil

@ -1,5 +1,4 @@
'use strict';
import { GitExplorerView } from '../configuration';
import { Container } from '../container';
import { Command, Commands } from './common';
@ -9,6 +8,6 @@ export class ShowGitExplorerCommand extends Command {
}
execute() {
return Container.gitExplorer.show(GitExplorerView.Repository);
return Container.gitExplorer.show();
}
}

+ 1
- 6
src/commands/showHistoryExplorer.ts Visa fil

@ -1,5 +1,4 @@
'use strict';
import { GitExplorerView } from '../configuration';
import { Container } from '../container';
import { Command, Commands } from './common';
@ -9,10 +8,6 @@ export class ShowHistoryExplorerCommand extends Command {
}
execute() {
if (Container.config.historyExplorer.enabled) {
return Container.historyExplorer.show();
}
return Container.gitExplorer.show(GitExplorerView.History);
return Container.historyExplorer.show();
}
}

+ 0
- 2
src/constants.ts Visa fil

@ -32,7 +32,6 @@ export enum CommandContext {
ExplorersCanCompare = 'gitlens:explorers:canCompare',
GitExplorer = 'gitlens:gitExplorer',
GitExplorerAutoRefresh = 'gitlens:gitExplorer:autoRefresh',
GitExplorerView = 'gitlens:gitExplorer:view',
HasRemotes = 'gitlens:hasRemotes',
HistoryExplorer = 'gitlens:historyExplorer',
Key = 'gitlens:key',
@ -124,6 +123,5 @@ export const ImageMimetypes: { [key: string]: string } = {
export enum WorkspaceState {
GitExplorerAutoRefresh = 'gitlens:gitExplorer:autoRefresh',
GitExplorerView = 'gitlens:gitExplorer:view',
ResultsExplorerKeepResults = 'gitlens:resultsExplorer:keepResults'
}

+ 0
- 7
src/ui/config.ts Visa fil

@ -56,12 +56,6 @@ export enum FileAnnotationType {
RecentChanges = 'recentChanges'
}
export enum GitExplorerView {
Auto = 'auto',
History = 'history',
Repository = 'repository'
}
export enum GravatarDefaultStyle {
Faces = 'wavatar',
Geometric = 'identicon',
@ -191,7 +185,6 @@ export interface IGitExplorerConfig {
includeWorkingTree: boolean;
location: 'explorer' | 'gitlens' | 'scm';
showTrackingBranch: boolean;
view: GitExplorerView;
}
export interface IHistoryExplorerConfig {

src/ui/images/settings/gitlens-explorer-repository-avatars.png → src/ui/images/settings/gitlens-explorer-avatars.png Visa fil


Binär
src/ui/images/settings/gitlens-explorer-history.png Visa fil

Före Efter
Bredd: 600  |  Höjd: 360  |  Storlek: 49 KiB

Binär
src/ui/images/settings/gitlens-explorer-repository-history-docked.png Visa fil

Före Efter
Bredd: 600  |  Höjd: 360  |  Storlek: 2.5 KiB

Binär
src/ui/images/settings/gitlens-explorer-repository-history-undocked.png Visa fil

Före Efter
Bredd: 600  |  Höjd: 360  |  Storlek: 2.4 KiB

src/ui/images/settings/gitlens-explorer-repository-tree-compact.png → src/ui/images/settings/gitlens-explorer-tree-compact.png Visa fil


src/ui/images/settings/gitlens-explorer-repository-tree.png → src/ui/images/settings/gitlens-explorer-tree.png Visa fil


src/ui/images/settings/gitlens-explorer-repository.png → src/ui/images/settings/gitlens-explorer.png Visa fil


src/ui/images/settings/gitlens-explorer-history-avatars.png → src/ui/images/settings/gitlens-file-history-explorer-avatars.png Visa fil


src/ui/images/settings/gitlens-history-explorer.png → src/ui/images/settings/gitlens-file-history-explorer.png Visa fil


Binär
src/ui/images/settings/gitlens-history-explorer-close.png Visa fil

Före Efter
Bredd: 600  |  Höjd: 360  |  Storlek: 2.4 KiB

+ 7
- 51
src/ui/settings/index.html Visa fil

@ -272,22 +272,6 @@
</select>
</div>
<div class="settings-group__setting ml-2" data-enablement="gitExplorer.enabled &amp; historyExplorer.enabled =false">
<label for="gitExplorer.view">When opened, show the</label>
<select class="setting hidden" id="gitExplorer.view" name="gitExplorer.view" data-visibility="historyExplorer.enabled =false"
disabled>
<option value="auto">last selected view</option>
<option value="repository">Repository view</option>
<option value="history">History view</option>
</select>
<select class="setting hidden" id="gitExplorer.view-undocked" name="!gitExplorer.view" data-visibility="historyExplorer.enabled"
disabled>
<option value="auto">last selected view</option>
<option value="repository" selected>Repository view</option>
<option value="history">History view</option>
</select>
</div>
<div class="settings-group__setting ml-2 hidden" data-enablement="gitExplorer.enabled" data-visibility="settings.mode =advanced">
<label for="gitExplorer.branches.layout">Layout branches</label>
<select class="setting" id="gitExplorer.branches.layout" name="gitExplorer.branches.layout" disabled>
@ -323,33 +307,13 @@
</div>
</div>
<div class="section__preview">
<img class="image__preview hidden" src="{{root}}/images/settings/gitlens-explorer-repository.png" data-visibility="gitExplorer.enabled &amp; gitExplorer.view !history &amp; gitExplorer.files.layout !tree"
/>
<img class="image__preview hidden" src="{{root}}/images/settings/gitlens-explorer-repository-tree-compact.png" data-visibility="gitExplorer.enabled &amp; gitExplorer.view !history &amp; gitExplorer.files.layout =tree &amp; gitExplorer.files.compact"
/>
<img class="image__preview hidden" src="{{root}}/images/settings/gitlens-explorer-repository-tree.png" data-visibility="gitExplorer.enabled &amp; gitExplorer.view !history &amp; gitExplorer.files.layout =tree &amp; gitExplorer.files.compact =false"
/>
<img class="image__preview hidden" src="{{root}}/images/settings/gitlens-explorer-repository.png" data-visibility="gitExplorer.enabled &amp; gitExplorer.view =history &amp; historyExplorer.enabled &amp; gitExplorer.files.layout !tree"
/>
<img class="image__preview hidden" src="{{root}}/images/settings/gitlens-explorer-repository-tree-compact.png" data-visibility="gitExplorer.enabled &amp; gitExplorer.view =history &amp; historyExplorer.enabled &amp; gitExplorer.files.layout =tree &amp; gitExplorer.files.compact"
<img class="image__preview hidden" src="{{root}}/images/settings/gitlens-explorer.png" data-visibility="gitExplorer.enabled &amp; gitExplorer.files.layout !tree"
/>
<img class="image__preview hidden" src="{{root}}/images/settings/gitlens-explorer-repository-tree.png" data-visibility="gitExplorer.enabled &amp; gitExplorer.view =history &amp; historyExplorer.enabled &amp; gitExplorer.files.layout =tree &amp; gitExplorer.files.compact =false"
<img class="image__preview hidden" src="{{root}}/images/settings/gitlens-explorer-tree-compact.png" data-visibility="gitExplorer.enabled &amp; gitExplorer.files.layout =tree &amp; gitExplorer.files.compact"
/>
<img class="image__preview--overlay hidden" src="{{root}}/images/settings/gitlens-explorer-repository-avatars.png" data-visibility="gitExplorer.enabled &amp; gitExplorer.view !history &amp; explorers.avatars"
/>
<img class="image__preview--overlay hidden" src="{{root}}/images/settings/gitlens-explorer-repository-avatars.png" data-visibility="gitExplorer.enabled &amp; gitExplorer.view =history &amp; historyExplorer.enabled &amp; explorers.avatars"
/>
<img class="image__preview--overlay hidden" src="{{root}}/images/settings/gitlens-explorer-repository-history-docked.png"
data-visibility="gitExplorer.enabled &amp; gitExplorer.view !history &amp; historyExplorer.enabled =false"
/>
<img class="image__preview--overlay hidden" src="{{root}}/images/settings/gitlens-explorer-repository-history-undocked.png"
data-visibility="gitExplorer.enabled &amp; historyExplorer.enabled" />
<img class="image__preview hidden" src="{{root}}/images/settings/gitlens-explorer-history.png" data-visibility="gitExplorer.enabled &amp; gitExplorer.view =history &amp; historyExplorer.enabled =false"
<img class="image__preview hidden" src="{{root}}/images/settings/gitlens-explorer-tree.png" data-visibility="gitExplorer.enabled &amp; gitExplorer.files.layout =tree &amp; gitExplorer.files.compact =false"
/>
<img class="image__preview--overlay hidden" src="{{root}}/images/settings/gitlens-explorer-history-avatars.png" data-visibility="gitExplorer.enabled &amp; gitExplorer.view =history &amp; historyExplorer.enabled =false &amp; explorers.avatars"
<img class="image__preview--overlay hidden" src="{{root}}/images/settings/gitlens-explorer-avatars.png" data-visibility="gitExplorer.enabled &amp; explorers.avatars"
/>
</div>
<p class="settings-group__hint">
@ -373,7 +337,7 @@
<i class="icon icon__info"></i>
</a>
</h2>
<p class="section__title-hint">Adds a GitLens File History explorer to visualize the history of the current file</p>
<p class="section__title-hint">Adds a GitLens File History explorer to visualize the revision history of the current file</p>
</div>
<div class="section__settings">
<div class="settings-group">
@ -381,7 +345,6 @@
<input class="setting" id="historyExplorer.enabled" name="historyExplorer.enabled" type="checkbox" />
<label for="historyExplorer.enabled">Show the GitLens File History explorer</label>
</div>
<p class="setting__hint hidden" data-visibility="gitExplorer.enabled &amp; historyExplorer.enabled =false">The current file history will be shown (docked) in the GitLens explorer</p>
<div class="settings-group__setting ml-2" data-enablement="historyExplorer.enabled">
<label for="historyExplorer.location">Show in the</label>
@ -398,16 +361,9 @@
</div>
</div>
<div class="section__preview">
<img class="image__preview hidden" src="{{root}}/images/settings/gitlens-history-explorer.png" data-visibility="historyExplorer.enabled"
/>
<img class="image__preview--overlay hidden" src="{{root}}/images/settings/gitlens-history-explorer-close.png" data-visibility="historyExplorer.enabled &amp; gitExplorer.enabled =false"
/>
<img class="image__preview--overlay hidden" src="{{root}}/images/settings/gitlens-explorer-history-avatars.png" data-visibility="historyExplorer.enabled &amp; historyExplorer.avatars"
/>
<img class="image__preview hidden" src="{{root}}/images/settings/gitlens-explorer-history.png" data-visibility="gitExplorer.enabled &amp; historyExplorer.enabled =false"
<img class="image__preview hidden" src="{{root}}/images/settings/gitlens-file-history-explorer.png" data-visibility="historyExplorer.enabled"
/>
<img class="image__preview--overlay hidden" src="{{root}}/images/settings/gitlens-explorer-history-avatars.png" data-visibility="gitExplorer.enabled &amp; historyExplorer.enabled =false &amp; historyExplorer.avatars"
<img class="image__preview--overlay hidden" src="{{root}}/images/settings/gitlens-file-history-explorer-avatars.png" data-visibility="historyExplorer.enabled &amp; historyExplorer.avatars"
/>
</div>
</div>

+ 96
- 0
src/views/explorer.ts Visa fil

@ -0,0 +1,96 @@
'use strict';
import {
ConfigurationChangeEvent,
Disposable,
Event,
EventEmitter,
TreeDataProvider,
TreeItem,
TreeView
} from 'vscode';
// import { configuration } from '../configuration';
// import { Container } from '../container';
import { Logger } from '../logger';
import { RefreshNodeCommandArgs } from './explorerCommands';
import { ExplorerNode, RefreshReason } from './nodes';
export abstract class ExplorerBase implements TreeDataProvider<ExplorerNode>, Disposable {
protected _onDidChangeTreeData = new EventEmitter<ExplorerNode>();
public get onDidChangeTreeData(): Event<ExplorerNode> {
return this._onDidChangeTreeData.event;
}
protected _disposable: Disposable | undefined;
protected _roots: ExplorerNode[] = [];
protected _tree: TreeView<ExplorerNode> | undefined;
constructor() {
this.registerCommands();
}
dispose() {
this._disposable && this._disposable.dispose();
}
abstract get id(): string;
protected abstract registerCommands(): void;
protected abstract onConfigurationChanged(e: ConfigurationChangeEvent): void;
abstract getChildren(node?: ExplorerNode): Promise<ExplorerNode[]>;
getParent(element: ExplorerNode): ExplorerNode | undefined {
return undefined;
}
abstract getTreeItem(node: ExplorerNode): Promise<TreeItem>;
protected getQualifiedCommand(command: string) {
return `gitlens.${this.id}.${command}`;
}
refresh(reason?: RefreshReason) {
if (reason === undefined) {
reason = RefreshReason.Command;
}
Logger.log(`Explorer(${this.id}).refresh`, `reason='${reason}'`);
this._onDidChangeTreeData.fire();
}
refreshNode(node: ExplorerNode, args?: RefreshNodeCommandArgs) {
Logger.log(`Explorer(${this.id}).refreshNode(${(node as { id?: string }).id || ''})`);
if (args !== undefined && node.supportsPaging) {
node.maxCount = args.maxCount;
}
node.refresh();
// Since a root node won't actually refresh, force everything
this.updateNode(node);
}
refreshNodes() {
Logger.log(`Explorer(${this.id}).refreshNodes`);
this._roots.forEach(n => n.refresh());
this._onDidChangeTreeData.fire();
}
async show() {
if (this._tree === undefined || this._roots === undefined || this._roots.length === 0) return;
try {
await this._tree.reveal(this._roots[0], { select: false });
}
catch (ex) {
Logger.error(ex);
}
}
updateNode(node: ExplorerNode | undefined) {
Logger.log(`Explorer(${this.id}).updateNode`);
if (node !== undefined) {
node = this._roots.includes(node) ? undefined : node;
}
this._onDidChangeTreeData.fire(node);
}
}

+ 27
- 185
src/views/gitExplorer.ts Visa fil

@ -6,27 +6,19 @@ import {
Event,
EventEmitter,
TextDocumentShowOptions,
TextEditor,
TreeDataProvider,
TreeItem,
TreeView,
Uri,
window
} from 'vscode';
import {
configuration,
ExplorerFilesLayout,
GitExplorerView,
IExplorersConfig,
IGitExplorerConfig
} from '../configuration';
import { CommandContext, GlyphChars, setCommandContext, WorkspaceState } from '../constants';
import { configuration, ExplorerFilesLayout, IExplorersConfig, IGitExplorerConfig } from '../configuration';
import { CommandContext, setCommandContext, WorkspaceState } from '../constants';
import { Container } from '../container';
import { GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { Functions } from '../system';
import { RefreshNodeCommandArgs } from '../views/explorerCommands';
import { HistoryExplorer } from './historyExplorer';
import { ExplorerNode, MessageNode, RefreshReason, RepositoriesNode, RepositoryNode } from './nodes';
export * from './nodes';
@ -36,7 +28,7 @@ export interface OpenFileRevisionCommandArgs {
showOptions?: TextDocumentShowOptions;
}
export class GitExplorer extends Disposable implements TreeDataProvider<ExplorerNode> {
export class GitExplorer implements TreeDataProvider<ExplorerNode>, Disposable {
private _disposable: Disposable | undefined;
private _root?: ExplorerNode;
private _tree: TreeView<ExplorerNode> | undefined;
@ -52,8 +44,6 @@ export class GitExplorer extends Disposable implements TreeDataProvider
}
constructor() {
super(() => this.dispose());
Container.explorerCommands;
commands.registerCommand('gitlens.gitExplorer.refresh', this.refresh, this);
commands.registerCommand('gitlens.gitExplorer.refreshNode', this.refreshNode, this);
@ -83,34 +73,8 @@ export class GitExplorer extends Disposable implements TreeDataProvider
() => this.setAutoRefresh(Container.config.gitExplorer.autoRefresh, false),
this
);
commands.registerCommand(
'gitlens.gitExplorer.setRenameFollowingOn',
() => HistoryExplorer.setRenameFollowing(true),
this
);
commands.registerCommand(
'gitlens.gitExplorer.setRenameFollowingOff',
() => HistoryExplorer.setRenameFollowing(false),
this
);
commands.registerCommand(
'gitlens.gitExplorer.switchToHistoryView',
() => this.switchTo(GitExplorerView.History),
this
);
commands.registerCommand(
'gitlens.gitExplorer.switchToRepositoryView',
() => this.switchTo(GitExplorerView.Repository),
this
);
commands.registerCommand('gitlens.gitExplorer.undockHistory', this.undockHistory, this);
Container.context.subscriptions.push(
window.onDidChangeActiveTextEditor(Functions.debounce(this.onActiveEditorChanged, 500), this),
window.onDidChangeVisibleTextEditors(Functions.debounce(this.onVisibleEditorsChanged, 500), this),
configuration.onDidChange(this.onConfigurationChanged, this)
);
Container.context.subscriptions.push(configuration.onDidChange(this.onConfigurationChanged, this));
void this.onConfigurationChanged(configuration.initializingChangeEvent);
}
@ -125,8 +89,7 @@ export class GitExplorer extends Disposable implements TreeDataProvider
!initializing &&
!configuration.changed(e, configuration.name('gitExplorer').value) &&
!configuration.changed(e, configuration.name('explorers').value) &&
!configuration.changed(e, configuration.name('defaultGravatarsStyle').value) &&
!configuration.changed(e, configuration.name('advanced')('fileHistoryFollowsRenames').value)
!configuration.changed(e, configuration.name('defaultGravatarsStyle').value)
) {
return;
}
@ -143,32 +106,8 @@ export class GitExplorer extends Disposable implements TreeDataProvider
void this.setAutoRefresh(Container.config.gitExplorer.autoRefresh);
}
// if (!initializing && configuration.changed(e, configuration.name('gitExplorer')('undockHistory').value)) {
// if (Container.config.historyExplorer.enabled) {
// this.undockHistory(!initializing);
// }
// // else {
// // this.dockHistory(!initializing);
// // }
// }
let view = this.view;
if (initializing || configuration.changed(e, configuration.name('gitExplorer')('view').value)) {
view = this.config.view;
if (view === GitExplorerView.Auto) {
view = Container.context.workspaceState.get<GitExplorerView>(
WorkspaceState.GitExplorerView,
GitExplorerView.Repository
);
}
}
if (initializing) {
this.view = view;
setCommandContext(CommandContext.GitExplorerView, this.view);
this.setRoot(await this.getRootNode(window.activeTextEditor));
this.setRoot(await this.getRootNode());
}
if (initializing || configuration.changed(e, configuration.name('gitExplorer')('location').value)) {
@ -181,46 +120,21 @@ export class GitExplorer extends Disposable implements TreeDataProvider
treeDataProvider: this
});
this._disposable = this._tree;
return;
}
void this.reset(
view!,
configuration.changed(e, configuration.name('advanced')('fileHistoryFollowsRenames').value)
);
}
private async onActiveEditorChanged(editor: TextEditor | undefined) {
if (this.view !== GitExplorerView.History) return;
const root = await this.getRootNode(editor);
if (!this.setRoot(root)) return;
void this.refresh(RefreshReason.ActiveEditorChanged, root);
if (!initializing && this._root !== undefined) {
this.refresh(RefreshReason.ConfigurationChanged);
}
}
private onRepositoriesChanged() {
if (this.view !== GitExplorerView.Repository) return;
this.clearRoot();
Logger.log(`GitExplorer[view=${this.view}].onRepositoriesChanged`);
Logger.log(`GitExplorer.onRepositoriesChanged`);
void this.refresh(RefreshReason.RepoChanged);
}
private onVisibleEditorsChanged(editors: TextEditor[]) {
if (this._root === undefined || this.view !== GitExplorerView.History) return;
// If we have no visible editors, or no trackable visible editors reset the view
if (editors.length === 0 || !editors.some(e => e.document && Container.git.isTrackable(e.document.uri))) {
this.clearRoot();
void this.refresh(RefreshReason.VisibleEditorsChanged);
}
}
get autoRefresh() {
return (
this.config.autoRefresh &&
@ -232,14 +146,6 @@ export class GitExplorer extends Disposable implements TreeDataProvider
return { ...Container.config.explorers, ...Container.config.gitExplorer };
}
private _view: GitExplorerView | undefined;
private get view(): GitExplorerView | undefined {
return this._view;
}
private set view(value: GitExplorerView | undefined) {
this._view = Container.config.historyExplorer.enabled ? GitExplorerView.Repository : value;
}
getParent(): ExplorerNode | undefined {
return undefined;
}
@ -253,13 +159,7 @@ export class GitExplorer extends Disposable implements TreeDataProvider
}
if (this._root === undefined) {
return [
new MessageNode(
this.view === GitExplorerView.History
? `No active file ${GlyphChars.Dash} no history to show`
: 'No repositories found'
)
];
return [new MessageNode('No repositories found')];
}
if (node === undefined) return this._root.getChildren();
@ -279,11 +179,11 @@ export class GitExplorer extends Disposable implements TreeDataProvider
reason = RefreshReason.Command;
}
Logger.log(`GitExplorer[view=${this.view}].refresh`, `reason='${reason}'`);
Logger.log(`GitExplorer.refresh`, `reason='${reason}'`);
if (this._root === undefined || (root === undefined && this.view === GitExplorerView.History)) {
if (this._root === undefined) {
this.clearRoot();
this.setRoot(await this.getRootNode(window.activeTextEditor));
this.setRoot(await this.getRootNode());
}
if (this._root !== undefined) {
@ -294,7 +194,7 @@ export class GitExplorer extends Disposable implements TreeDataProvider
}
refreshNode(node: ExplorerNode, args?: RefreshNodeCommandArgs) {
Logger.log(`GitExplorer[view=${this.view}].refreshNode(${(node as { id?: string }).id || ''})`);
Logger.log(`GitExplorer.refreshNode(${(node as { id?: string }).id || ''})`);
if (args !== undefined && node.supportsPaging) {
node.maxCount = args.maxCount;
@ -306,20 +206,6 @@ export class GitExplorer extends Disposable implements TreeDataProvider
this._onDidChangeTreeData.fire(node === this._root ? undefined : node);
}
async reset(view: GitExplorerView, force: boolean = false) {
this.setView(view);
if (force && this._root !== undefined) {
this.clearRoot();
}
const requiresRefresh = this.setRoot(await this.getRootNode(window.activeTextEditor));
if (requiresRefresh || force) {
return this.refresh(RefreshReason.ViewChanged);
}
}
private _autoRefreshDisposable: Disposable | undefined;
async setAutoRefresh(enabled: boolean, workspaceEnabled?: boolean) {
@ -356,25 +242,9 @@ export class GitExplorer extends Disposable implements TreeDataProvider
}
}
setView(view: GitExplorerView) {
if (this.view === view) return;
if (Container.config.gitExplorer.view === GitExplorerView.Auto) {
Container.context.workspaceState.update(WorkspaceState.GitExplorerView, view);
}
this.view = view;
setCommandContext(CommandContext.GitExplorerView, this.view);
if (view !== GitExplorerView.Repository) {
Container.git.stopWatchingFileSystem();
}
}
async show(view: GitExplorerView) {
async show() {
if (this._root === undefined || this._tree === undefined) return;
await this.switchTo(view);
const [child] = await this._root!.getChildren();
try {
@ -385,17 +255,6 @@ export class GitExplorer extends Disposable implements TreeDataProvider
}
}
async switchTo(view: GitExplorerView) {
if (this.view === view) return false;
await this.reset(view, true);
return true;
}
// async dockHistory(switchView: boolean = true) {
// Container.historyExplorer.dock(switchView);
// }
private clearRoot() {
if (this._root === undefined) return;
@ -403,35 +262,22 @@ export class GitExplorer extends Disposable implements TreeDataProvider
this._root = undefined;
}
private async getRootNode(editor?: TextEditor): Promise<ExplorerNode | undefined> {
switch (this.view) {
case GitExplorerView.History: {
const promise = this.getHistoryNode(editor || window.activeTextEditor);
this._loading = promise.then(_ => Functions.wait(0));
return promise;
}
default: {
const promise = Container.git.getRepositories();
this._loading = promise.then(_ => Functions.wait(0));
const repositories = [...(await promise)];
if (repositories.length === 0) return undefined;
private async getRootNode(): Promise<ExplorerNode | undefined> {
const promise = Container.git.getRepositories();
this._loading = promise.then(_ => Functions.wait(0));
const openedRepos = repositories.filter(r => !r.closed);
if (openedRepos.length === 0) return undefined;
const repositories = [...(await promise)];
if (repositories.length === 0) return undefined;
if (openedRepos.length === 1) {
const repo = openedRepos[0];
return new RepositoryNode(GitUri.fromRepoPath(repo.path), repo, this, true);
}
const openedRepos = repositories.filter(r => !r.closed);
if (openedRepos.length === 0) return undefined;
return new RepositoriesNode(openedRepos, this);
}
if (openedRepos.length === 1) {
const repo = openedRepos[0];
return new RepositoryNode(GitUri.fromRepoPath(repo.path), repo, this, true);
}
}
private getHistoryNode(editor: TextEditor | undefined): Promise<ExplorerNode | undefined> {
return HistoryExplorer.getHistoryNode(this, editor, this._root);
return new RepositoriesNode(openedRepos, this);
}
private setFilesLayout(layout: ExplorerFilesLayout) {
@ -448,8 +294,4 @@ export class GitExplorer extends Disposable implements TreeDataProvider
this._root = root;
return true;
}
private undockHistory(switchView: boolean = true) {
return Container.historyExplorer.undock(switchView);
}
}

+ 21
- 64
src/views/historyExplorer.ts Visa fil

@ -14,18 +14,18 @@ import {
window
} from 'vscode';
import { UriComparer } from '../comparers';
import { configuration, GitExplorerView, IExplorersConfig, IHistoryExplorerConfig } from '../configuration';
import { configuration, IExplorersConfig, IHistoryExplorerConfig } from '../configuration';
import { CommandContext, GlyphChars, setCommandContext } from '../constants';
import { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { Logger } from '../logger';
import { Functions } from '../system';
import { RefreshNodeCommandArgs } from '../views/explorerCommands';
import { Explorer, ExplorerNode, HistoryNode, MessageNode, RefreshReason } from './nodes';
import { ExplorerNode, HistoryNode, MessageNode, RefreshReason } from './nodes';
export * from './nodes';
export class HistoryExplorer extends Disposable implements TreeDataProvider<ExplorerNode> {
export class HistoryExplorer implements TreeDataProvider<ExplorerNode>, Disposable {
private _disposable: Disposable | undefined;
private _root?: ExplorerNode;
private _tree: TreeView<ExplorerNode> | undefined;
@ -36,22 +36,18 @@ export class HistoryExplorer extends Disposable implements TreeDataProvider
}
constructor() {
super(() => this.dispose());
Container.explorerCommands;
commands.registerCommand('gitlens.historyExplorer.refresh', this.refresh, this);
commands.registerCommand('gitlens.historyExplorer.refreshNode', this.refreshNode, this);
commands.registerCommand('gitlens.historyExplorer.close', () => this.dock(false), this);
commands.registerCommand('gitlens.historyExplorer.dock', this.dock, this);
commands.registerCommand(
'gitlens.historyExplorer.setRenameFollowingOn',
() => HistoryExplorer.setRenameFollowing(true),
() => this.setRenameFollowing(true),
this
);
commands.registerCommand(
'gitlens.historyExplorer.setRenameFollowingOff',
() => HistoryExplorer.setRenameFollowing(false),
() => this.setRenameFollowing(false),
this
);
@ -88,15 +84,6 @@ export class HistoryExplorer extends Disposable implements TreeDataProvider
setCommandContext(CommandContext.HistoryExplorer, this.config.enabled ? this.config.location : false);
}
if (initializing || configuration.changed(e, configuration.name('historyExplorer')('enabled').value)) {
if (this.config.enabled) {
void this.undock(!initializing, !configuration.changed(e, configuration.name('mode').value));
}
else {
void this.dock(!initializing, !configuration.changed(e, configuration.name('mode').value));
}
}
if (initializing) {
this.setRoot(await this.getRootNode(window.activeTextEditor));
}
@ -155,17 +142,6 @@ export class HistoryExplorer extends Disposable implements TreeDataProvider
return node.getTreeItem();
}
async dock(switchView: boolean = true, updateConfig: boolean = true) {
if (switchView) {
void (await Container.gitExplorer.switchTo(GitExplorerView.History));
}
void (await setCommandContext(CommandContext.HistoryExplorer, false));
if (updateConfig) {
void (await configuration.updateEffective(configuration.name('historyExplorer')('enabled').value, false));
}
}
getQualifiedCommand(command: string) {
return `gitlens.historyExplorer.${command}`;
}
@ -208,17 +184,6 @@ export class HistoryExplorer extends Disposable implements TreeDataProvider
}
}
async undock(switchView: boolean = true, updateConfig: boolean = true) {
if (switchView) {
void (await Container.gitExplorer.switchTo(GitExplorerView.Repository));
}
void (await setCommandContext(CommandContext.HistoryExplorer, this.config.location));
if (updateConfig) {
void (await configuration.updateEffective(configuration.name('historyExplorer')('enabled').value, true));
}
}
private clearRoot() {
if (this._root === undefined) return;
@ -226,26 +191,7 @@ export class HistoryExplorer extends Disposable implements TreeDataProvider
this._root = undefined;
}
private getRootNode(editor: TextEditor | undefined): Promise<ExplorerNode | undefined> {
return HistoryExplorer.getHistoryNode(this, editor, this._root);
}
private setRoot(root: ExplorerNode | undefined): boolean {
if (this._root === root) return false;
if (this._root !== undefined) {
this._root.dispose();
}
this._root = root;
return true;
}
static async getHistoryNode(
explorer: Explorer,
editor: TextEditor | undefined,
root: ExplorerNode | undefined
): Promise<ExplorerNode | undefined> {
private async getRootNode(editor: TextEditor | undefined): Promise<ExplorerNode | undefined> {
// If we have no active editor, or no visible editors, or no trackable visible editors reset the view
if (
editor == null ||
@ -256,7 +202,7 @@ export class HistoryExplorer extends Disposable implements TreeDataProvider
}
// If we do have a visible trackable editor, don't change from the last state (avoids issues when focus switches to the problems/output/debug console panes)
if (editor.document === undefined || !Container.git.isTrackable(editor.document.uri)) return root;
if (editor.document === undefined || !Container.git.isTrackable(editor.document.uri)) return this._root;
let gitUri = await GitUri.fromUri(editor.document.uri);
@ -277,18 +223,29 @@ export class HistoryExplorer extends Disposable implements TreeDataProvider
}
}
if (UriComparer.equals(uri || gitUri, root && root.uri)) return root;
if (UriComparer.equals(uri || gitUri, this._root && this._root.uri)) return this._root;
if (uri !== undefined) {
gitUri = await GitUri.fromUri(uri);
}
return new HistoryNode(gitUri, repo, explorer);
return new HistoryNode(gitUri, repo, this);
}
static setRenameFollowing(enabled: boolean) {
private setRenameFollowing(enabled: boolean) {
return configuration.updateEffective(
configuration.name('advanced')('fileHistoryFollowsRenames').value,
enabled
);
}
private setRoot(root: ExplorerNode | undefined): boolean {
if (this._root === root) return false;
if (this._root !== undefined) {
this._root.dispose();
}
this._root = root;
return true;
}
}

Laddar…
Avbryt
Spara