Ver código fonte

Defaults stashes format to ${filePath}

Adds message when there are no stashes
Cleans up the stash explorer
main
Eric Amodio 7 anos atrás
pai
commit
ef41176ea7
6 arquivos alterados com 30 adições e 36 exclusões
  1. +1
    -1
      README.md
  2. +5
    -4
      package.json
  3. +8
    -2
      src/commands/openFileInRemote.ts
  4. +0
    -2
      src/configuration.ts
  5. +14
    -25
      src/views/stashExplorer.ts
  6. +2
    -2
      src/views/stashNode.ts

+ 1
- 1
README.md Ver arquivo

@ -294,7 +294,7 @@ GitLens is highly customizable and provides many configuration settings to allow
|Name | Description
|-----|------------
|`gitlens.stashExplorer.stashFormat`|Specifies the format of stashed changes in the `Git Stashes` explorer <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.stashExplorer.stashFileFormat`|Specifies the format of a stashed file in the `Git Stashes` explorer <br />Available tokens<br /> ${file} - file name<br /> ${path} - file path
|`gitlens.stashExplorer.stashFileFormat`|Specifies the format of a stashed file in the `Git Stashes` explorer <br />Available tokens<br /> ${file} - file name<br /> ${filePath} - file name and path<br /> ${path} - file path
### Status Bar Settings

+ 5
- 4
package.json Ver arquivo

@ -420,8 +420,8 @@
},
"gitlens.stashExplorer.stashFileFormat": {
"type": "string",
"default": "${file} \u00a0\u2022\u00a0 ${path}",
"description": "Specifies the format of a stashed file in the `Git Stashes` explorer\nAvailable tokens\n ${file} - file name\n ${path} - file path"
"default": "${filePath}",
"description": "Specifies the format of a stashed file in the `Git Stashes` explorer\nAvailable tokens\n ${file} - file name\n ${filePath} - file name and path\n ${path} - file path"
},
"gitlens.statusBar.enabled": {
"type": "boolean",
@ -1161,11 +1161,12 @@
},
{
"command": "gitlens.gitExplorer.refresh",
"when": "gitlens:enabled"
"when": "false"
},
},
{
"command": "gitlens.stashExplorer.refresh",
"when": "gitlens:enabled"
"when": "false"
},
{
"command": "gitlens.stashExplorer.openChanges",

+ 8
- 2
src/commands/openFileInRemote.ts Ver arquivo

@ -6,13 +6,17 @@ import { GitService, GitUri } from '../gitService';
import { Logger } from '../logger';
import { OpenInRemoteCommandArgs } from './openInRemote';
export interface OpenFileInRemoteCommandArgs {
range?: boolean;
}
export class OpenFileInRemoteCommand extends ActiveEditorCommand {
constructor(private git: GitService) {
super(Commands.OpenFileInRemote);
}
async execute(editor?: TextEditor, uri?: Uri) {
async execute(editor?: TextEditor, uri?: Uri, args: OpenFileInRemoteCommandArgs = { range: true }) {
uri = getCommandUri(uri, editor);
if (uri === undefined) return undefined;
@ -23,7 +27,9 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
try {
const remotes = Arrays.uniqueBy(await this.git.getRemotes(gitUri.repoPath), _ => _.url, _ => !!_.provider);
const range = editor === undefined ? undefined : new Range(editor.selection.start.with({ line: editor.selection.start.line + 1 }), editor.selection.end.with({ line: editor.selection.end.line + 1 }));
const range = (args.range && editor !== undefined)
? new Range(editor.selection.start.with({ line: editor.selection.start.line + 1 }), editor.selection.end.with({ line: editor.selection.end.line + 1 }))
: undefined;
return commands.executeCommand(Commands.OpenInRemote, uri, {
resource: {

+ 0
- 2
src/configuration.ts Ver arquivo

@ -297,14 +297,12 @@ export interface IConfig {
defaultDateFormat: string | null;
gitExplorer: {
enabled: boolean;
commitFormat: string;
commitFileFormat: string;
// dateFormat: string | null;
};
stashExplorer: {
enabled: boolean;
stashFormat: string;
stashFileFormat: string;
// dateFormat: string | null;

+ 14
- 25
src/views/stashExplorer.ts Ver arquivo

@ -1,7 +1,7 @@
'use strict';
// import { Functions } from '../system';
import { commands, Event, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem, Uri } from 'vscode';
import { Commands, DiffWithPreviousCommandArgs, openEditor } from '../commands';
import { Commands, DiffWithPreviousCommandArgs, openEditor, OpenFileInRemoteCommandArgs } from '../commands';
import { ExplorerNode, StashCommitNode, StashNode } from './explorerNodes';
import { GitService, GitUri } from '../gitService';
@ -10,7 +10,6 @@ export * from './explorerNodes';
export class StashExplorer implements TreeDataProvider<ExplorerNode> {
private _node: ExplorerNode;
// private _refreshDebounced: () => void;
private _onDidChangeTreeData = new EventEmitter<ExplorerNode>();
public get onDidChangeTreeData(): Event<ExplorerNode> {
@ -24,28 +23,12 @@ export class StashExplorer implements TreeDataProvider {
commands.registerCommand('gitlens.stashExplorer.openStashedFile', this.openStashedFile, this);
commands.registerCommand('gitlens.stashExplorer.openFileInRemote', this.openFileInRemote, this);
context.subscriptions.push(this.git.onDidChangeRepo(reasons => {
if (!reasons.includes('stash')) return;
context.subscriptions.push(this.git.onDidChangeRepo(this.onRepoChanged, this));
this.refresh();
}, this));
// this._refreshDebounced = Functions.debounce(this.refresh.bind(this), 250);
// const editor = window.activeTextEditor;
// const uri = (editor !== undefined && editor.document !== undefined)
// ? new GitUri(editor.document.uri, { repoPath: git.repoPath, fileName: editor.document.uri.fsPath })
// : new GitUri(Uri.file(git.repoPath), { repoPath: git.repoPath, fileName: git.repoPath });
const uri = new GitUri(Uri.file(git.repoPath), { repoPath: git.repoPath, fileName: git.repoPath });
this._node = new StashNode(uri, this.context, this.git);
this._node = this.getRootNode();
}
async getTreeItem(node: ExplorerNode): Promise<TreeItem> {
// if (node.onDidChangeTreeData !== undefined) {
// node.onDidChangeTreeData(() => setTimeout(this._refreshDebounced, 1));
// }
return node.getTreeItem();
}
@ -54,10 +37,16 @@ export class StashExplorer implements TreeDataProvider {
return node.getChildren();
}
// update(uri: GitUri) {
// this._node = new StashNode(uri, this.context, this.git);
// this.refresh();
// }
private getRootNode(): ExplorerNode {
const uri = new GitUri(Uri.file(this.git.repoPath), { repoPath: this.git.repoPath, fileName: this.git.repoPath });
return new StashNode(uri, this.context, this.git);
}
private onRepoChanged(reasons: ('stash' | 'unknown')[]) {
if (!reasons.includes('stash')) return;
this.refresh();
}
refresh() {
this._onDidChangeTreeData.fire();
@ -81,6 +70,6 @@ export class StashExplorer implements TreeDataProvider {
}
private openFileInRemote(node: StashCommitNode) {
return commands.executeCommand(Commands.OpenFileInRemote, node.commit.previousUri);
return commands.executeCommand(Commands.OpenFileInRemote, node.commit.uri, { range: false } as OpenFileInRemoteCommandArgs);
}
}

+ 2
- 2
src/views/stashNode.ts Ver arquivo

@ -14,9 +14,9 @@ export class StashNode extends ExplorerNode {
super(uri);
}
async getChildren(): Promise<StashCommitNode[]> {
async getChildren(): Promise<ExplorerNode[]> {
const stash = await this.git.getStashList(this.uri.repoPath!);
if (stash === undefined) return [];
if (stash === undefined) return [new TextExplorerNode('No stashed changes')];
return [...Iterables.map(stash.commits.values(), c => new StashCommitNode(c, this.context, this.git))];
}

Carregando…
Cancelar
Salvar