Ver código fonte

Fixes #970 - Stashes doesn't honor files layout

main
Eric Amodio 4 anos atrás
pai
commit
506bb456fa
2 arquivos alterados com 26 adições e 9 exclusões
  1. +23
    -6
      src/views/nodes/stashNode.ts
  2. +3
    -3
      src/views/nodes/stashesNode.ts

+ 23
- 6
src/views/nodes/stashNode.ts Ver arquivo

@ -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 Ver arquivo

@ -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);
}

Carregando…
Cancelar
Salvar