Ver código fonte

Updates the tree layout for branches

- Removes mix-tree support
  - Avoids nesting on the current branch
  - Caches basename
  - Replaces folder icons with theme icons
    - Folder icons will now follow the file icon theme used
  - Fixes minor nitpicks
main
Eric Amodio 6 anos atrás
pai
commit
16d855a3a0
17 arquivos alterados com 141 adições e 119 exclusões
  1. +7
    -3
      CHANGELOG.md
  2. +20
    -19
      README.md
  3. +3
    -1
      images/dark/folder.svg
  4. +3
    -1
      images/light/folder.svg
  5. +3
    -4
      package.json
  6. +23
    -6
      src/git/models/branch.ts
  7. +9
    -9
      src/ui/config.ts
  8. +12
    -4
      src/ui/settings/index.html
  9. +4
    -1
      src/ui/shared/app-base.ts
  10. +1
    -0
      src/ui/welcome/index.html
  11. +10
    -41
      src/views/branchFolderNode.ts
  12. +8
    -10
      src/views/branchNode.ts
  13. +16
    -9
      src/views/branchesNode.ts
  14. +1
    -0
      src/views/folderNode.ts
  15. +8
    -1
      src/views/gitExplorer.ts
  16. +5
    -9
      src/views/remoteNode.ts
  17. +8
    -1
      src/views/resultsExplorer.ts

+ 7
- 3
CHANGELOG.md Ver arquivo

@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
### Added
- Adds a tree layout option to branches in the *GitLens* explorer — closes [#258](https://github.com/eamodio/vscode-gitlens/issues/258) thanks to [PR #260](https://github.com/eamodio/vscode-gitlens/pull/260) by Yukai Huang ([@Yukaii](https://github.com/Yukaii))!
### Fixed
- Fixes [#35](https://github.com/eamodio/vscode-gitlens/issues/35) - Copy Commit Sha to Clipboard not working (linux)
## [8.0.0-beta3] - 2018-02-03
### Added
- Adds an all-new GitLens welcome page via the *Welcome* (`gitlens.showWelcomePage`) command — provides a welcome / onboarding experience
@ -71,9 +78,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Removes `gitlens.annotations.line.hover.changes` setting, use `gitlens.hovers.annotations.changes` instead
- Removes `gitlens.annotations.line.hover.details` setting, use `gitlens.hovers.annotations.details` instead
### Fixed
- Fixes [#35](https://github.com/eamodio/vscode-gitlens/issues/35) - Copy Commit Sha to Clipboard not working (linux)
## [7.5.10] - 2018-02-01
### Added
- Adds support for custom remotes with split project/repo url structure — closes [#267](https://github.com/eamodio/vscode-gitlens/issues/267)

+ 20
- 19
README.md Ver arquivo

@ -325,7 +325,7 @@ An on-demand, [customizable](#gitlens-results-view-settings "Jump to the GitLens
- Use `#<sha>` to search for a commit with id of `<sha>` &mdash; See [Git docs](https://git-scm.com/docs/git-log "Open Git docs")
- Use `~<pattern>` to search for commits with differences whose patch text contains added/removed lines that match `<pattern>` &mdash; See [Git docs](https://git-scm.com/docs/git-log#git-log--Gltregexgt "Open Git docs")
- Use `=<string>` to search for commits with differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file &mdash; See [Git docs](https://git-scm.com/docs/git-log#git-log--Sltstringgt "Open Git docs")
- Provides a *Show in Results* option to show the search results in the **GitLens Results** view
- Provides a *Show in Results* option to show the search results in the *GitLens Results* view
---
### Navigate and Explore
@ -490,15 +490,15 @@ See also [Explorer Settings](#explorer-settings "Jump to the Explorer settings")
|Name | Description
|-----|------------
|`gitlens.gitExplorer.autoRefresh`|Specifies whether or not to automatically refresh the **GitLens** view when the repository or the file system changes
|`gitlens.gitExplorer.branches.layout`| Specifies how the **Branches** view will display branches<br />`list` - display all branches<br />`tree` - organize branch as folder if branch name contains slashes "/"<br />`mix-tree` - display branch folders along with normal branch alphabetically
|`gitlens.gitExplorer.enabled`|Specifies whether or not to show the **GitLens** view"
|`gitlens.gitExplorer.files.compact`|Specifies whether or not to compact (flatten) unnecessary file nesting in the **GitLens** view<br />Only applies when displaying files as a `tree` or `auto`
|`gitlens.gitExplorer.files.layout`|Specifies how the **GitLens** view will display files<br /> `auto` - automatically switches between displaying files as a `tree` or `list` based on the `gitlens.gitExplorer.files.threshold` setting 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** view<br />Only applies when displaying files as `auto`
|`gitlens.gitExplorer.includeWorkingTree`|Specifies whether or not to include working tree files inside the `Repository Status` node of the **GitLens** view
|`gitlens.gitExplorer.showTrackingBranch`|Specifies whether or not to show the tracking branch when displaying local branches in the **GitLens** view"
|`gitlens.gitExplorer.view`|Specifies the starting view (mode) of the **GitLens** view<br /> `auto` - shows the last selected view, defaults to `repository`<br />`history` - shows the commit history of the active file<br />`repository` - shows a repository explorer"
|`gitlens.gitExplorer.autoRefresh`|Specifies whether or not 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 or not to show the *GitLens* explorer"
|`gitlens.gitExplorer.files.compact`|Specifies whether or not to compact (flatten) unnecessary file nesting in the *GitLens* explorer<br />Only applies when displaying files as a `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` setting 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 displaying files as `auto`
|`gitlens.gitExplorer.includeWorkingTree`|Specifies whether or not to include working tree files inside the `Repository Status` node of the *GitLens* explorer
|`gitlens.gitExplorer.showTrackingBranch`|Specifies whether or not to show the tracking branch when displaying local branches in the *GitLens* explorer"
|`gitlens.gitExplorer.view`|Specifies the starting view (mode) of the *GitLens* explorer<br /> `auto` - shows the last selected view, defaults to `repository`<br />`history` - shows the commit history of the active file<br />`repository` - shows a repository explorer"
### GitLens Results View Settings
@ -506,20 +506,20 @@ See also [Explorer Settings](#explorer-settings "Jump to the Explorer settings")
|Name | Description
|-----|------------
|`gitlens.resultsExplorer.files.compact`|Specifies whether or not to compact (flatten) unnecessary file nesting in the **GitLens Results** view<br />Only applies when displaying files as a `tree` or `auto`
|`gitlens.resultsExplorer.files.layout`|Specifies how the **GitLens Results** view will display files<br /> `auto` - automatically switches between displaying files as a `tree` or `list` based on the `gitlens.resultsExplorer.files.threshold` setting and the number of files at each nesting level<br /> `list` - displays files as a list<br /> `tree` - displays files as a tree
|`gitlens.resultsExplorer.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 Results** view<br />Only applies when displaying files as `auto`
|`gitlens.resultsExplorer.files.compact`|Specifies whether or not to compact (flatten) unnecessary file nesting in the *GitLens Results* view<br />Only applies when displaying files as a `tree` or `auto`
|`gitlens.resultsExplorer.files.layout`|Specifies how the *GitLens Results* view will display files<br /> `auto` - automatically switches between displaying files as a `tree` or `list` based on the `gitlens.resultsExplorer.files.threshold` setting and the number of files at each nesting level<br /> `list` - displays files as a list<br /> `tree` - displays files as a tree
|`gitlens.resultsExplorer.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 Results* view<br />Only applies when displaying files as `auto`
### Explorer Settings
|Name | Description
|-----|------------
|`gitlens.explorers.avatars`|Specifies whether or not to show avatar images instead of commit (or status) icons in the **GitLens** and **GitLens Results** views
|`gitlens.explorers.commitFileFormat`|Specifies the format of a committed file in the **GitLens** and **GitLens Results** views<br />Available tokens<br /> ${directory} - directory name<br /> ${file} - file name<br /> ${filePath} - formatted file name and path<br /> ${path} - full file path
|`gitlens.explorers.commitFormat`|Specifies the format of committed changes in the **GitLens** and **GitLens Results** views<br />Available tokens<br /> ${id} - commit id<br /> ${author} - commit author<br /> ${message} - commit message<br /> ${ago} - relative commit date (e.g. 1 day ago)<br /> ${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br /> ${authorAgo} - commit author, relative commit date<br />See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting
|`gitlens.explorers.stashFileFormat`|Specifies the format of a stashed file in the **GitLens** and **GitLens Results** views<br />Available tokens<br /> ${directory} - directory name<br /> ${file} - file name<br /> ${filePath} - formatted file name and path<br /> ${path} - full file path
|`gitlens.explorers.stashFormat`|Specifies the format of stashed changes in the **GitLens** and **GitLens Results** views<br />Available tokens<br /> ${id} - commit id<br /> ${author} - commit author<br /> ${message} - commit message<br /> ${ago} - relative commit date (e.g. 1 day ago)<br /> ${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br /> ${authorAgo} - commit author, relative commit date<br />See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting
|`gitlens.explorers.statusFileFormat`|Specifies the format of the status of a working or committed file in the **GitLens** and **GitLens Results** views<br />Available tokens<br /> ${directory} - directory name<br /> ${file} - file name<br /> ${filePath} - formatted file name and path<br /> ${path} - full file path<br />${working} - optional indicator if the file is uncommitted
|`gitlens.explorers.avatars`|Specifies whether or not to show avatar images instead of commit (or status) icons in the *GitLens* and *GitLens Results* views
|`gitlens.explorers.commitFileFormat`|Specifies the format of a committed file in the *GitLens* and *GitLens Results* views<br />Available tokens<br /> ${directory} - directory name<br /> ${file} - file name<br /> ${filePath} - formatted file name and path<br /> ${path} - full file path
|`gitlens.explorers.commitFormat`|Specifies the format of committed changes in the *GitLens* and *GitLens Results* views<br />Available tokens<br /> ${id} - commit id<br /> ${author} - commit author<br /> ${message} - commit message<br /> ${ago} - relative commit date (e.g. 1 day ago)<br /> ${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br /> ${authorAgo} - commit author, relative commit date<br />See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting
|`gitlens.explorers.stashFileFormat`|Specifies the format of a stashed file in the *GitLens* and *GitLens Results* views<br />Available tokens<br /> ${directory} - directory name<br /> ${file} - file name<br /> ${filePath} - formatted file name and path<br /> ${path} - full file path
|`gitlens.explorers.stashFormat`|Specifies the format of stashed changes in the *GitLens* and *GitLens Results* views<br />Available tokens<br /> ${id} - commit id<br /> ${author} - commit author<br /> ${message} - commit message<br /> ${ago} - relative commit date (e.g. 1 day ago)<br /> ${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br /> ${authorAgo} - commit author, relative commit date<br />See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting
|`gitlens.explorers.statusFileFormat`|Specifies the format of the status of a working or committed file in the *GitLens* and *GitLens Results* views<br />Available tokens<br /> ${directory} - directory name<br /> ${file} - file name<br /> ${filePath} - formatted file name and path<br /> ${path} - full file path<br />${working} - optional indicator if the file is uncommitted
### Code Lens Settings
@ -647,6 +647,7 @@ Add [`"gitlens.insiders": true`](#general-settings "Jump to GitLens settings") t
A big thanks to the people that have contributed to this project:
- Amanda Cameron ([@AmandaCameron](https://github.com/AmandaCameron)) &mdash; [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=AmandaCameron))
- Yukai Huang ([@Yukaii](https://github.com/Yukaii)) &mdash; [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=Yukaii))
- Helmut Januschka ([@hjanuschka](https://github.com/hjanuschka)) &mdash; [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=hjanuschka))
- Chris Kaczor ([@ckaczor](https://github.com/ckaczor)) &mdash; [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=ckaczor))
- Peng Lyu ([@rebornix](https://github.com/rebornix)) &mdash; [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=rebornix))

+ 3
- 1
images/dark/folder.svg Ver arquivo

@ -1,2 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><style type="text/css">.icon-canvas-transparent{opacity:0;fill:#F6F6F6;} .icon-vs-out{opacity:0;fill:#F6F6F6;} .icon-vs-fg{opacity:0;fill:#F0EFF1;} .icon-folder{fill:#C5C5C5;}</style><path class="icon-canvas-transparent" d="M16 16h-16v-16h16v16z" id="canvas"/><path class="icon-vs-out" d="M16 2.5v10c0 .827-.673 1.5-1.5 1.5h-11.996c-.827 0-1.5-.673-1.5-1.5v-8c0-.827.673-1.5 1.5-1.5h2.886l1-2h8.11c.827 0 1.5.673 1.5 1.5z" id="outline"/><path class="icon-folder" d="M14.5 2h-7.492l-1 2h-3.504c-.277 0-.5.224-.5.5v8c0 .276.223.5.5.5h11.996c.275 0 .5-.224.5-.5v-10c0-.276-.225-.5-.5-.5zm-.496 2h-6.496l.5-1h5.996v1z" id="iconBg"/><path class="icon-vs-fg" d="M14 3v1h-6.5l.5-1h6z" id="iconFg"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
<path fill="#c5c5c5" d="M15 2H7L6 4H3L2 5v8h13V2zm-1 2H8V3h6v1z" />
</svg>

+ 3
- 1
images/light/folder.svg Ver arquivo

@ -1,2 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><style type="text/css">.icon-canvas-transparent{opacity:0;fill:#F6F6F6;} .icon-vs-out{opacity:0;fill:#F6F6F6;} .icon-vs-fg{fill:#F0EFF1;} .icon-folder{fill:#656565;}</style><path class="icon-canvas-transparent" d="M16 16h-16v-16h16v16z" id="canvas"/><path class="icon-vs-out" d="M16 2.5v10c0 .827-.673 1.5-1.5 1.5h-11.996c-.827 0-1.5-.673-1.5-1.5v-8c0-.827.673-1.5 1.5-1.5h2.886l1-2h8.11c.827 0 1.5.673 1.5 1.5z" id="outline"/><path class="icon-folder" d="M14.5 2h-7.492l-1 2h-3.504c-.277 0-.5.224-.5.5v8c0 .276.223.5.5.5h11.996c.275 0 .5-.224.5-.5v-10c0-.276-.225-.5-.5-.5zm-.496 2h-6.496l.5-1h5.996v1z" id="iconBg"/><path class="icon-vs-fg" d="M14 3v1h-6.5l.5-1h6z" id="iconFg"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
<path fill="#424242" d="M15 2H7L6 4H3L2 5v8h13V2zm-1 2H8V3h6v1z" />
</svg>

+ 3
- 4
package.json Ver arquivo

@ -399,13 +399,12 @@
},
"gitlens.gitExplorer.branches.layout": {
"type": "string",
"default": "list",
"default": "tree",
"enum": [
"list",
"tree",
"mix-tree"
"tree"
],
"description": "Specifies how the `Branches` view will display branches\n `list` - display all branches \n`tree` - organize branch as folder if branch name contains slashes \"\/\"\n `mix-tree` - display branch folders along with normal branch alphabetically",
"description": "Specifies how the `GitLens` explorer will display branches\n `list` - displays branches as a list \n`tree` - displays branches as a tree when branch names contain slashes `/`",
"scope": "window"
},
"gitlens.gitExplorer.enabled": {

+ 23
- 6
src/git/models/branch.ts Ver arquivo

@ -10,7 +10,6 @@ export class GitBranch {
ahead: number;
behind: number;
};
basename: string;
constructor(
public readonly repoPath: string,
@ -30,7 +29,6 @@ export class GitBranch {
this.current = current;
this.name = branch;
this.basename = this.name.split('/').pop() || this.name;
this.tracking = tracking === '' || tracking == null ? undefined : tracking;
this.state = {
ahead: ahead,
@ -38,6 +36,19 @@ export class GitBranch {
};
}
private _basename: string | undefined;
getBasename(): string {
if (this._basename === undefined) {
const name = this.getName();
const index = name.lastIndexOf('/');
this._basename = index !== -1
? name.substring(index + 1)
: name;
}
return this._basename;
}
private _name: string | undefined;
getName(): string {
if (this._name === undefined) {
@ -49,10 +60,6 @@ export class GitBranch {
return this._name;
}
getBasename(): string {
return this.basename;
}
getRemote(): string | undefined {
if (this.remote) return GitBranch.getRemote(this.name);
if (this.tracking !== undefined) return GitBranch.getRemote(this.tracking);
@ -60,7 +67,17 @@ export class GitBranch {
return undefined;
}
isValid(): boolean {
return GitBranch.isValid(this.name);
}
static getRemote(branch: string): string {
return branch.substring(0, branch.indexOf('/'));
}
static isValid(name: string): boolean {
// If there is whitespace in the name assume this is not a valid branch name
// Deals with detached HEAD states
return name.match(/\s/) === null;
}
}

+ 9
- 9
src/ui/config.ts Ver arquivo

@ -34,16 +34,15 @@ export enum DateStyle {
Relative = 'relative'
}
export enum ExplorerFilesLayout {
Auto = 'auto',
export enum ExplorerBranchesLayout {
List = 'list',
Tree = 'tree'
}
export enum ExplorerBranchesLayout {
export enum ExplorerFilesLayout {
Auto = 'auto',
List = 'list',
Tree = 'tree',
MixTree = 'mix-tree'
Tree = 'tree'
}
export enum FileAnnotationType {
@ -181,10 +180,6 @@ export interface ICodeLensConfig {
export interface IExplorersConfig {
avatars: boolean;
branches: {
layout: ExplorerBranchesLayout;
};
files: {
layout: ExplorerFilesLayout;
compact: boolean;
@ -208,6 +203,11 @@ export interface IExplorersFilesConfig {
export interface IGitExplorerConfig {
autoRefresh: boolean;
branches: {
layout: ExplorerBranchesLayout;
};
enabled: boolean;
files: IExplorersFilesConfig;
includeWorkingTree: boolean;

+ 12
- 4
src/ui/settings/index.html Ver arquivo

@ -63,6 +63,14 @@
</div>
<div class="settings-group__setting ml-2" data-enablement="gitExplorer.enabled" disabled>
<label for="gitExplorer.branches.layout">Layout branches</label>
<select id="gitExplorer.branches.layout" name="gitExplorer.branches.layout" disabled>
<option value="list">as a list</option>
<option value="tree">as a tree</option>
</select>
</div>
<div class="settings-group__setting ml-2" data-enablement="gitExplorer.enabled" disabled>
<label for="gitExplorer.files.layout">Layout files</label>
<select id="gitExplorer.files.layout" name="gitExplorer.files.layout" disabled>
<option value="auto">automatically</option>
@ -72,11 +80,11 @@
</div>
<p class="setting__hint hidden" data-visibility="gitExplorer.files.layout =auto">Chooses the best layout based on the number of files at each nesting level</p>
<div class="settings-group__setting nowrap ml-4" data-enablement="gitExplorer.enabled" disabled>
<div class="settings-group__setting nowrap ml-2" data-enablement="gitExplorer.enabled" disabled>
<input id="gitExplorer.files.compact" name="gitExplorer.files.compact" type="checkbox" disabled />
<label for="gitExplorer.files.compact">Use compact layout</label>
</div>
<p class="setting__hint setting__hint--indent-4">Compacts (flattens) unnecessary file nesting when using a tree layout</p>
<p class="setting__hint setting__hint--indent-1">Compacts (flattens) unnecessary nesting when using a tree layouts</p>
<div class="settings-group__setting nowrap ml-2" data-enablement="gitExplorer.enabled" disabled>
<input id="gitExplorer.avatars" name="explorers.avatars" type="checkbox" disabled />
@ -124,11 +132,11 @@
</select>
</div>
<div class="settings-group__setting nowrap ml-2">
<div class="settings-group__setting nowrap">
<input id="resultsExplorer.files.compact" name="resultsExplorer.files.compact" type="checkbox" />
<label for="resultsExplorer.files.compact">Use compact layout</label>
</div>
<p class="setting__hint setting__hint--indent-2">Compacts (flattens) unnecessary file nesting when using a tree layout</p>
<p class="setting__hint setting__hint">Compacts (flattens) unnecessary nesting when using a tree layouts</p>
<div class="settings-group__setting nowrap">
<input id="resultsExplorer.avatars" name="explorers.avatars" type="checkbox" />

+ 4
- 1
src/ui/shared/app-base.ts Ver arquivo

@ -32,7 +32,10 @@ export abstract class App {
for (const el of document.querySelectorAll<HTMLSelectElement>('select')) {
const value = getSettingValue<string>(el.name);
el.querySelector<HTMLOptionElement>(`option[value='${value}']`)!.selected = true;
const input = el.querySelector<HTMLOptionElement>(`option[value='${value}']`);
if (input != null) {
input.selected = true;
}
}
const state = flatten(config);

+ 1
- 0
src/ui/welcome/index.html Ver arquivo

@ -36,6 +36,7 @@
<ul class="changelog__list">
<li><span class="changelog__badge changelog__badge--added">NEW</span>Brand new Welcome experience &mdash; you're looking at it</li>
<li><span class="changelog__badge changelog__badge--added">NEW</span>Brand new WYSIWYG <a class="command" title="Open GitLens Settings" href="command:gitlens.showSettingsPage">GitLens Settings</a> editor &mdash; GitLens is easier than ever to customize to suit your needs</li>
<li><span class="changelog__badge changelog__badge--added">NEW</span>Adds a tree layout option to branches in the <i>GitLens</i> explorer &mdash; thanks to Yukai Huang (<a href="https://github.com/Yukaii">@Yukaii</a>)!</li>
<li><span class="changelog__badge changelog__badge--changed">IMPROVED</span>Reworked settings &mdash; clearer, simpler settings</li>
</ul>

+ 10
- 41
src/views/branchFolderNode.ts Ver arquivo

@ -1,10 +1,9 @@
'use strict';
import { Arrays, Objects } from '../system';
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { Container } from '../container';
import { Explorer, ExplorerNode, ResourceType } from './explorerNode';
import { BranchNode } from './branchNode';
import { ExplorerBranchesLayout } from '../configuration';
// import { Container } from '../container';
import { Explorer, ExplorerNode, ResourceType } from './explorerNode';
import { GitUri } from '../gitService';
export class BranchFolderNode extends ExplorerNode {
@ -15,9 +14,9 @@ export class BranchFolderNode extends ExplorerNode {
public readonly relativePath: string | undefined,
public readonly root: Arrays.IHierarchicalItem<BranchNode>,
private readonly explorer: Explorer
) {
super(GitUri.fromRepoPath(repoPath));
}
) {
super(GitUri.fromRepoPath(repoPath));
}
async getChildren(): Promise<ExplorerNode[]> {
if (this.root.descendants === undefined || this.root.children === undefined) return [];
@ -32,47 +31,17 @@ export class BranchFolderNode extends ExplorerNode {
children.push(folder.value);
}
if (this.explorer.config.branches.layout === ExplorerBranchesLayout.Tree) {
// sort strategy: current branch / current branch folder - normal branches - other folder branches (alphabetical order)
children.sort((a, b) => {
return (a.current ? -1 : 1) - (b.current ? -1 : 1) ||
((a instanceof BranchNode) ? -1 : 1) - ((b instanceof BranchNode) ? -1 : 1) ||
((a instanceof BranchNode && a.branch.current) ? -1 : 1) - ((b instanceof BranchNode && b.branch.current) ? -1 : 1) ||
a.label!.localeCompare(b.label!);
});
}
return children;
}
}
async getTreeItem(): Promise<TreeItem> {
const item = new TreeItem(this.label, this.current ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.Collapsed);
async getTreeItem(): Promise<TreeItem> {
const item = new TreeItem(this.label, TreeItemCollapsibleState.Collapsed);
item.contextValue = ResourceType.Folder;
item.iconPath = {
dark: Container.context.asAbsolutePath('images/dark/folder.svg'),
light: Container.context.asAbsolutePath('images/light/folder.svg')
};
(item as any).resourceUri = this.explorer.folderResourceUri;
return item;
}
}
get label(): string {
return this.branchFolderName;
}
get current(): boolean {
return this.findCurrent(this.root);
}
// collect whether branch folder containes the current branch recursively
findCurrent(tree: Arrays.IHierarchicalItem<BranchNode>): boolean {
if (tree.value !== undefined) { // BranchNode
return tree.value.branch.current;
} else if (tree.children !== undefined) { // BranchFolderNode
return Object.keys(tree.children).reduce((bool, key) => {
return bool || this.findCurrent(tree.children![key]);
}, false);
} else {
return false;
}
}
}

+ 8
- 10
src/views/branchNode.ts Ver arquivo

@ -2,12 +2,12 @@
import { Iterables } from '../system';
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { CommitNode } from './commitNode';
import { ExplorerBranchesLayout } from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { ExplorerNode, ExplorerRefNode, MessageNode, ResourceType, ShowAllNode } from './explorerNode';
import { GitExplorer } from './gitExplorer';
import { GitBranch, GitUri } from '../gitService';
import { ExplorerBranchesLayout } from '../configuration';
export class BranchNode extends ExplorerRefNode {
@ -21,21 +21,19 @@ export class BranchNode extends ExplorerRefNode {
super(uri);
}
get ref(): string {
return this.branch.name;
get current(): boolean {
return this.branch.current;
}
get label(): string {
const branchName = this.branch.getName();
if (this.explorer.config.branches.layout === ExplorerBranchesLayout.List) {
return branchName;
} else {
return !!branchName.match(/\s/) ? branchName : this.branch.getBasename();
}
if (this.explorer.config.branches.layout === ExplorerBranchesLayout.List) return branchName;
return GitBranch.isValid(branchName) && !this.current ? this.branch.getBasename() : branchName;
}
get current(): boolean {
return this.branch.current;
get ref(): string {
return this.branch.name;
}
async getChildren(): Promise<ExplorerNode[]> {

+ 16
- 9
src/views/branchesNode.ts Ver arquivo

@ -1,13 +1,13 @@
'use strict';
import { Arrays, Iterables } from '../system';
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { BranchFolderNode } from './branchFolderNode';
import { BranchNode } from './branchNode';
import { ExplorerBranchesLayout } from '../configuration';
import { Container } from '../container';
import { ExplorerNode, ResourceType } from './explorerNode';
import { GitExplorer } from './gitExplorer';
import { GitUri, Repository } from '../gitService';
import { BranchFolderNode } from './branchFolderNode';
import { ExplorerBranchesLayout } from '../configuration';
export class BranchesNode extends ExplorerNode {
@ -26,20 +26,27 @@ export class BranchesNode extends ExplorerNode {
branches.sort((a, b) => (a.current ? -1 : 1) - (b.current ? -1 : 1) || a.name.localeCompare(b.name));
let children = [];
// filter local branches
const branchNodes = [...Iterables.filterMap(branches, b => b.remote ? undefined : new BranchNode(b, this.uri, this.explorer))];
if (this.explorer.config.branches.layout === ExplorerBranchesLayout.List) return branchNodes;
if (this.explorer.config.branches.layout === ExplorerBranchesLayout.List) {
return branchNodes;
}
// Take out the current branch, since that should always be first and un-nested
const current = (branchNodes.length > 0 && branchNodes[0].current)
? branchNodes.splice(0, 1)[0]
: undefined;
const hierarchy = Arrays.makeHierarchical(branchNodes,
n => !!n.branch.name.match(/\s/) ? [n.branch.name] : n.branch.name.split('/'),
(...paths: string[]) => paths.join('/'), this.explorer.config.files.compact);
n => n.branch.isValid() ? n.branch.getName().split('/') : [n.branch.name],
(...paths: string[]) => paths.join('/'),
this.explorer.config.files.compact);
const root = new BranchFolderNode(this.repo.path, '', undefined, hierarchy, this.explorer);
children = await root.getChildren() as (BranchFolderNode | BranchNode)[];
const children = await root.getChildren() as (BranchFolderNode | BranchNode)[];
// If we found a current branch, insert it at the start
if (current !== undefined) {
children.splice(0, 0, current);
}
return children;
}

+ 1
- 0
src/views/folderNode.ts Ver arquivo

@ -63,6 +63,7 @@ export class FolderNode extends ExplorerNode {
// TODO: Change this to expanded once https://github.com/Microsoft/vscode/issues/30918 is fixed
const item = new TreeItem(this.label, TreeItemCollapsibleState.Collapsed);
item.contextValue = ResourceType.Folder;
(item as any).resourceUri = this.explorer.folderResourceUri;
return item;
}

+ 8
- 1
src/views/gitExplorer.ts Ver arquivo

@ -1,6 +1,6 @@
'use strict';
import { Functions } from '../system';
import { commands, ConfigurationChangeEvent, ConfigurationTarget, Disposable, Event, EventEmitter, TextDocumentShowOptions, TextEditor, TreeDataProvider, TreeItem, Uri, window } from 'vscode';
import { commands, ConfigurationChangeEvent, ConfigurationTarget, Disposable, Event, EventEmitter, TextDocumentShowOptions, TextEditor, TreeDataProvider, TreeItem, Uri, window, workspace } from 'vscode';
import { UriComparer } from '../comparers';
import { configuration, ExplorerFilesLayout, GitExplorerView, IExplorersConfig, IGitExplorerConfig } from '../configuration';
import { CommandContext, GlyphChars, setCommandContext, WorkspaceState } from '../constants';
@ -138,6 +138,13 @@ export class GitExplorer extends Disposable implements TreeDataProvider
return { ...Container.config.explorers, ...Container.config.gitExplorer };
}
get folderResourceUri(): Uri | undefined {
// Return the uri of any workspace folder -- we just need a folder so that we can use the uri has an icon resourceUri
if (workspace.workspaceFolders === undefined || workspace.workspaceFolders.length === 0) return undefined;
return workspace.workspaceFolders[0].uri;
}
private _loading: Promise<void> | undefined;
async getChildren(node?: ExplorerNode): Promise<ExplorerNode[]> {

+ 5
- 9
src/views/remoteNode.ts Ver arquivo

@ -1,13 +1,13 @@
'use strict';
import { Arrays, Iterables } from '../system';
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { BranchFolderNode } from './branchFolderNode';
import { BranchNode } from './branchNode';
import { ExplorerBranchesLayout } from '../configuration';
import { GlyphChars } from '../constants';
import { ExplorerNode, ResourceType } from './explorerNode';
import { GitExplorer } from './gitExplorer';
import { GitRemote, GitRemoteType, GitUri, Repository } from '../gitService';
import { BranchFolderNode } from './branchFolderNode';
import { ExplorerBranchesLayout } from '../configuration';
export class RemoteNode extends ExplorerNode {
@ -26,23 +26,19 @@ export class RemoteNode extends ExplorerNode {
branches.sort((a, b) => a.name.localeCompare(b.name));
let children = [];
// filter remote branches
const branchNodes = [...Iterables.filterMap(branches, b => !b.remote || !b.name.startsWith(this.remote.name) ? undefined : new BranchNode(b, this.uri, this.explorer))];
if (this.explorer.config.branches.layout === ExplorerBranchesLayout.List) {
return branchNodes;
}
if (this.explorer.config.branches.layout === ExplorerBranchesLayout.List) return branchNodes;
const hierarchy = Arrays.makeHierarchical(
branchNodes,
n => !!n.branch.name.match(/\s/) ? [n.branch.name] : n.branch.name.split('/').slice(1), // remove remote name
n => n.branch.isValid() ? n.branch.getName().split('/') : [n.branch.name],
(...paths: string[]) => paths.join('/'),
this.explorer.config.files.compact
);
const root = new BranchFolderNode(this.repo.path, '', undefined, hierarchy, this.explorer);
children = await root.getChildren() as (BranchFolderNode | BranchNode)[];
const children = await root.getChildren() as (BranchFolderNode | BranchNode)[];
return children;
}

+ 8
- 1
src/views/resultsExplorer.ts Ver arquivo

@ -1,6 +1,6 @@
'use strict';
import { Functions, Strings } from '../system';
import { commands, ConfigurationChangeEvent, ConfigurationTarget, Disposable, Event, EventEmitter, TreeDataProvider, TreeItem, window } from 'vscode';
import { commands, ConfigurationChangeEvent, ConfigurationTarget, Disposable, Event, EventEmitter, TreeDataProvider, TreeItem, Uri, window, workspace } from 'vscode';
import { configuration, ExplorerFilesLayout, IExplorersConfig, IResultsExplorerConfig } from '../configuration';
import { CommandContext, GlyphChars, setCommandContext, WorkspaceState } from '../constants';
import { Container } from '../container';
@ -70,6 +70,13 @@ export class ResultsExplorer extends Disposable implements TreeDataProvider
return { ...Container.config.explorers, ...Container.config.resultsExplorer };
}
get folderResourceUri(): Uri | undefined {
// Return the uri of any workspace folder -- we just need a folder so that we can use the uri has an icon resourceUri
if (workspace.workspaceFolders === undefined || workspace.workspaceFolders.length === 0) return undefined;
return workspace.workspaceFolders[0].uri;
}
get keepResults(): boolean {
return Container.context.workspaceState.get<boolean>(WorkspaceState.ResultsExplorerKeepResults, false);
}

Carregando…
Cancelar
Salvar