瀏覽代碼

Fixes #970 - Stashes doesn't honor files layout

main
Eric Amodio 4 年之前
父節點
當前提交
506bb456fa
共有 2 個檔案被更改,包括 26 行新增9 行删除
  1. +23
    -6
      src/views/nodes/stashNode.ts
  2. +3
    -3
      src/views/nodes/stashesNode.ts

+ 23
- 6
src/views/nodes/stashNode.ts 查看文件

@ -1,20 +1,23 @@
'use strict';
import * as paths from 'path';
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { Container } from '../../container';
import { CommitFormatter, GitStashCommit } from '../../git/gitService';
import { Iterables } from '../../system';
import { View } from '../viewBase';
import { Arrays, Iterables, Strings } from '../../system';
import { ViewWithFiles } from '../viewBase';
import { StashFileNode } from './stashFileNode';
import { ResourceType, ViewNode, ViewRefNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
import { FileNode, FolderNode } from '../nodes';
import { ViewFilesLayout } from '../../config';
export class StashNode extends ViewRefNode {
export class StashNode extends ViewRefNode<ViewWithFiles> {
static key = ':stash';
static getId(repoPath: string, ref: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${ref})`;
}
constructor(view: View, parent: ViewNode, public readonly commit: GitStashCommit) {
constructor(view: ViewWithFiles, parent: ViewNode, public readonly commit: GitStashCommit) {
super(commit.toGitUri(), view, parent);
}
@ -48,8 +51,22 @@ export class StashNode extends ViewRefNode {
}
}
const children = files.map(s => new StashFileNode(this.view, this, s, this.commit.toFileCommit(s)));
children.sort((a, b) => a.label.localeCompare(b.label, undefined, { numeric: true, sensitivity: 'base' }));
let children: FileNode[] = files.map(s => new StashFileNode(this.view, this, s, this.commit.toFileCommit(s)));
if (this.view.config.files.layout !== ViewFilesLayout.List) {
const hierarchy = Arrays.makeHierarchical(
children,
n => n.uri.relativePath.split('/'),
(...parts: string[]) => Strings.normalizePath(paths.join(...parts)),
this.view.config.files.compact
);
const root = new FolderNode(this.view, this, this.repoPath, '', hierarchy);
children = root.getChildren() as FileNode[];
} else {
children.sort((a, b) =>
a.label!.localeCompare(b.label!, undefined, { numeric: true, sensitivity: 'base' })
);
}
return children;
}

+ 3
- 3
src/views/nodes/stashesNode.ts 查看文件

@ -3,19 +3,19 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { Container } from '../../container';
import { GitUri, Repository } from '../../git/gitService';
import { Iterables } from '../../system';
import { View } from '../viewBase';
import { ViewWithFiles } from '../viewBase';
import { MessageNode } from './common';
import { StashNode } from './stashNode';
import { ResourceType, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
export class StashesNode extends ViewNode {
export class StashesNode extends ViewNode<ViewWithFiles> {
static key = ':stashes';
static getId(repoPath: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}`;
}
constructor(uri: GitUri, view: View, parent: ViewNode, public readonly repo: Repository) {
constructor(uri: GitUri, view: ViewWithFiles, parent: ViewNode, public readonly repo: Repository) {
super(uri, view, parent);
}

Loading…
取消
儲存