Ver a proveniência

Adds reveal in repos view to search

Fixes issue stash reveal button
Updates reveal|open in view icons
Adds gating to reveal methods
main
Eric Amodio há 5 anos
ascendente
cometimento
f726420ef2
14 ficheiros alterados com 122 adições e 74 eliminações
  1. +2
    -2
      images/dark/icon-eye-selected.svg
  2. +2
    -2
      images/dark/icon-eye.svg
  3. +4
    -0
      images/dark/icon-open.svg
  4. +2
    -2
      images/light/icon-eye-selected.svg
  5. +2
    -2
      images/light/icon-eye.svg
  6. +4
    -0
      images/light/icon-open.svg
  7. +2
    -2
      package.json
  8. +53
    -23
      src/commands/git/search.ts
  9. +21
    -24
      src/commands/git/stash.ts
  10. +2
    -2
      src/commands/showQuickFileHistory.ts
  11. +5
    -6
      src/quickpicks/commitQuickPick.ts
  12. +4
    -4
      src/quickpicks/commonQuickPicks.ts
  13. +12
    -4
      src/views/repositoriesView.ts
  14. +7
    -1
      src/views/viewBase.ts

+ 2
- 2
images/dark/icon-eye-selected.svg Ver ficheiro

@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16">
<path fill="#fff" fill-opacity=".1" stroke="#C5C5C5" stroke-width=".5" d="M.25.25h15.5v15.5H.25z"/>
<path fill="#C5C5C5" fill-rule="evenodd" d="M8 10.75c2.59 0 4.1-1.218 5.233-2.75C12.1 6.468 10.59 5.25 8 5.25S3.9 6.468 2.767 8C3.9 9.532 5.41 10.75 8 10.75zM14.75 8c-1.294 2-3.177 4-6.75 4s-5.456-2-6.75-4C2.544 6 4.427 4 8 4s5.456 2 6.75 4zM8 9.75a1.75 1.75 0 1 0 0-3.5 1.75 1.75 0 0 0 0 3.5z" clip-rule="evenodd"/>
</svg>
<path stroke="#C5C5C5" d="M8 3.5a6.453 6.453 0 0 0-6.482 6h.001c.257-3.345 3.073-6 6.481-6zm0 0a6.453 6.453 0 0 1 6.482 6h-.001c-.258-3.345-3.073-6-6.481-6zm0 4c-1.424 0-2.5 1.076-2.5 2.5M8 7.5c1.424 0 2.5 1.076 2.5 2.5M8 7.5c1.376 0 2.5 1.124 2.5 2.5M8 7.5A2.506 2.506 0 0 0 5.5 10m0 0c0 1.424 1.076 2.5 2.5 2.5M5.5 10c0 1.376 1.124 2.5 2.5 2.5m2.5-2.5c0 1.424-1.076 2.5-2.5 2.5m2.5-2.5c0 1.376-1.124 2.5-2.5 2.5"/>
</svg>

+ 2
- 2
images/dark/icon-eye.svg Ver ficheiro

@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16">
<path fill="#C5C5C5" fill-rule="evenodd" d="M8 10.75c2.59 0 4.1-1.218 5.233-2.75C12.1 6.468 10.59 5.25 8 5.25S3.9 6.468 2.767 8C3.9 9.532 5.41 10.75 8 10.75zM14.75 8c-1.294 2-3.177 4-6.75 4s-5.456-2-6.75-4C2.544 6 4.427 4 8 4s5.456 2 6.75 4zM8 9.75a1.75 1.75 0 1 0 0-3.5 1.75 1.75 0 0 0 0 3.5z" clip-rule="evenodd"/>
</svg>
<path stroke="#C5C5C5" d="M8 3.5a6.453 6.453 0 0 0-6.482 6h.001c.257-3.345 3.073-6 6.481-6zm0 0a6.453 6.453 0 0 1 6.482 6h-.001c-.258-3.345-3.073-6-6.481-6zm0 4c-1.424 0-2.5 1.076-2.5 2.5M8 7.5c1.424 0 2.5 1.076 2.5 2.5M8 7.5c1.376 0 2.5 1.124 2.5 2.5M8 7.5A2.506 2.506 0 0 0 5.5 10m0 0c0 1.424 1.076 2.5 2.5 2.5M5.5 10c0 1.376 1.124 2.5 2.5 2.5m2.5-2.5c0 1.424-1.076 2.5-2.5 2.5m2.5-2.5c0 1.376-1.124 2.5-2.5 2.5"/>
</svg>

+ 4
- 0
images/dark/icon-open.svg Ver ficheiro

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16">
<path stroke="#C5C5C5" stroke-linejoin="bevel" d="M2 8.5h5.5m0 0V14m0-5.5l-5.75 5.75"/>
<path fill="#C5C5C5" fill-rule="evenodd" d="M2.5 2l-.5.5V6h1V3h10v10h-3v1h3.5l.5-.5v-11l-.5-.5h-11z" clip-rule="evenodd"/>
</svg>

+ 2
- 2
images/light/icon-eye-selected.svg Ver ficheiro

@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16">
<path fill="#000" fill-opacity=".1" stroke="#424242" stroke-width=".5" d="M.25.25h15.5v15.5H.25z"/>
<path fill="#424242" fill-rule="evenodd" d="M8 10.75c2.59 0 4.1-1.218 5.233-2.75C12.1 6.468 10.59 5.25 8 5.25S3.9 6.468 2.767 8C3.9 9.532 5.41 10.75 8 10.75zM14.75 8c-1.294 2-3.177 4-6.75 4s-5.456-2-6.75-4C2.544 6 4.427 4 8 4s5.456 2 6.75 4zM8 9.75a1.75 1.75 0 1 0 0-3.5 1.75 1.75 0 0 0 0 3.5z" clip-rule="evenodd"/>
</svg>
<path stroke="#424242" d="M8 3.5a6.453 6.453 0 0 0-6.482 6h.001c.257-3.345 3.073-6 6.481-6zm0 0a6.453 6.453 0 0 1 6.482 6h-.001c-.258-3.345-3.073-6-6.481-6zm0 4c-1.424 0-2.5 1.076-2.5 2.5M8 7.5c1.424 0 2.5 1.076 2.5 2.5M8 7.5c1.376 0 2.5 1.124 2.5 2.5M8 7.5A2.506 2.506 0 0 0 5.5 10m0 0c0 1.424 1.076 2.5 2.5 2.5M5.5 10c0 1.376 1.124 2.5 2.5 2.5m2.5-2.5c0 1.424-1.076 2.5-2.5 2.5m2.5-2.5c0 1.376-1.124 2.5-2.5 2.5"/>
</svg>

+ 2
- 2
images/light/icon-eye.svg Ver ficheiro

@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16">
<path fill="#424242" fill-rule="evenodd" d="M8 10.75c2.59 0 4.1-1.218 5.233-2.75C12.1 6.468 10.59 5.25 8 5.25S3.9 6.468 2.767 8C3.9 9.532 5.41 10.75 8 10.75zM14.75 8c-1.294 2-3.177 4-6.75 4s-5.456-2-6.75-4C2.544 6 4.427 4 8 4s5.456 2 6.75 4zM8 9.75a1.75 1.75 0 1 0 0-3.5 1.75 1.75 0 0 0 0 3.5z" clip-rule="evenodd"/>
</svg>
<path stroke="#424242" d="M8 3.5a6.453 6.453 0 0 0-6.482 6h.001c.257-3.345 3.073-6 6.481-6zm0 0a6.453 6.453 0 0 1 6.482 6h-.001c-.258-3.345-3.073-6-6.481-6zm0 4c-1.424 0-2.5 1.076-2.5 2.5M8 7.5c1.424 0 2.5 1.076 2.5 2.5M8 7.5c1.376 0 2.5 1.124 2.5 2.5M8 7.5A2.506 2.506 0 0 0 5.5 10m0 0c0 1.424 1.076 2.5 2.5 2.5M5.5 10c0 1.376 1.124 2.5 2.5 2.5m2.5-2.5c0 1.424-1.076 2.5-2.5 2.5m2.5-2.5c0 1.376-1.124 2.5-2.5 2.5"/>
</svg>

+ 4
- 0
images/light/icon-open.svg Ver ficheiro

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16">
<path stroke="#424242" stroke-linejoin="bevel" d="M2 8.5h5.5m0 0V14m0-5.5l-5.75 5.75"/>
<path fill="#424242" fill-rule="evenodd" d="M2.5 2l-.5.5V6h1V3h10v10h-3v1h3.5l.5-.5v-11l-.5-.5h-11z" clip-rule="evenodd"/>
</svg>

+ 2
- 2
package.json Ver ficheiro

@ -2228,12 +2228,12 @@
},
{
"command": "gitlens.showCommitInView",
"title": "Show Commit in View",
"title": "Open in Search Commits View",
"category": "GitLens"
},
{
"command": "gitlens.showFileHistoryInView",
"title": "Show File History in View",
"title": "Open in File History View",
"category": "GitLens"
},
{

+ 53
- 23
src/commands/git/search.ts Ver ficheiro

@ -102,10 +102,18 @@ export class SearchGitCommand extends QuickCommandBase {
static readonly OpenInView: QuickInputButton = {
iconPath: {
dark: Container.context.asAbsolutePath('images/dark/icon-link.svg') as any,
light: Container.context.asAbsolutePath('images/light/icon-link.svg') as any
dark: Container.context.asAbsolutePath('images/dark/icon-open.svg') as any,
light: Container.context.asAbsolutePath('images/light/icon-open.svg') as any
},
tooltip: 'Open in View'
tooltip: 'Open in Search Commits View'
};
static readonly RevealInView: QuickInputButton = {
iconPath: {
dark: Container.context.asAbsolutePath('images/dark/icon-eye.svg') as any,
light: Container.context.asAbsolutePath('images/light/icon-eye.svg') as any
},
tooltip: 'Reveal in Repositories View'
};
static readonly ShowInView: QuickInputButton = {
@ -403,18 +411,30 @@ export class SearchGitCommand extends QuickCommandBase {
)
)
],
additionalButtons: [this.Buttons.OpenInView],
additionalButtons: [this.Buttons.RevealInView, this.Buttons.OpenInView],
onDidClickButton: (quickpick, button) => {
if (button !== this.Buttons.OpenInView) return;
void Container.searchView.search(
state.repo!.path,
search,
{
label: { label: `for ${state.pattern}` }
},
results
);
if (button === this.Buttons.OpenInView) {
void Container.searchView.search(
state.repo!.path,
search,
{
label: { label: `for ${state.pattern}` }
},
results
);
return;
}
if (button === this.Buttons.RevealInView) {
if (quickpick.activeItems.length !== 0) {
void Container.repositoriesView.revealCommit(quickpick.activeItems[0].item, {
select: true,
focus: false,
expand: true
});
}
}
},
keys: ['right', 'alt+right', 'ctrl+right'],
onDidPressKey: async (quickpick, key) => {
@ -461,17 +481,27 @@ export class SearchGitCommand extends QuickCommandBase {
items: await CommitQuickPick.getItems(pickedCommit, pickedCommit.toGitUri(), {
showChanges: false
}),
additionalButtons: [this.Buttons.OpenInView],
additionalButtons: [this.Buttons.RevealInView, this.Buttons.OpenInView],
onDidClickButton: (quickpick, button) => {
if (button !== this.Buttons.OpenInView) return;
if (button === this.Buttons.OpenInView) {
void Container.searchView.search(
pickedCommit!.repoPath,
{ pattern: SearchPattern.fromCommit(pickedCommit!) },
{
label: { label: `for commit id ${pickedCommit!.shortSha}` }
}
);
void Container.searchView.search(
pickedCommit!.repoPath,
{ pattern: SearchPattern.fromCommit(pickedCommit!) },
{
label: { label: `for commit id ${pickedCommit!.shortSha}` }
}
);
return;
}
if (button === this.Buttons.RevealInView) {
void Container.repositoriesView.revealCommit(pickedCommit!, {
select: true,
focus: false,
expand: true
});
}
}
});
const selection: StepSelection<typeof step> = yield step;

+ 21
- 24
src/commands/git/stash.ts Ver ficheiro

@ -2,7 +2,7 @@
/* eslint-disable no-loop-func */
import { QuickInputButton, QuickInputButtons, QuickPickItem, Uri, window } from 'vscode';
import { Container } from '../../container';
import { GitStashCommit, GitUri, Repository, SearchPattern } from '../../git/gitService';
import { GitStashCommit, GitUri, Repository } from '../../git/gitService';
import {
BreakQuickCommand,
QuickCommandBase,
@ -82,12 +82,12 @@ export interface StashGitCommandArgs {
export class StashGitCommand extends QuickCommandBase<State> {
private readonly Buttons = class {
static readonly OpenInView: QuickInputButton = {
static readonly RevealInView: QuickInputButton = {
iconPath: {
dark: Container.context.asAbsolutePath('images/dark/icon-link.svg') as any,
light: Container.context.asAbsolutePath('images/light/icon-link.svg') as any
dark: Container.context.asAbsolutePath('images/dark/icon-eye.svg') as any,
light: Container.context.asAbsolutePath('images/light/icon-eye.svg') as any
},
tooltip: 'Open in View'
tooltip: 'Reveal in Repositories View'
};
};
@ -345,9 +345,9 @@ export class StashGitCommand extends QuickCommandBase {
)
)
],
additionalButtons: [this.Buttons.OpenInView],
additionalButtons: [this.Buttons.RevealInView],
onDidClickButton: (quickpick, button) => {
if (button === this.Buttons.OpenInView) {
if (button === this.Buttons.RevealInView) {
if (quickpick.activeItems.length !== 0) {
void Container.repositoriesView.revealStash(quickpick.activeItems[0].item, {
select: true,
@ -415,9 +415,9 @@ export class StashGitCommand extends QuickCommandBase {
undefined,
{
placeholder: `Confirm ${this.title} ${getSubtitle(state.subcommand)}`,
additionalButtons: [this.Buttons.OpenInView],
additionalButtons: [this.Buttons.RevealInView],
onDidClickButton: (quickpick, button) => {
if (button === this.Buttons.OpenInView) {
if (button === this.Buttons.RevealInView) {
void Container.repositoriesView.revealStash(state.stash!, {
select: true,
expand: true
@ -472,9 +472,9 @@ export class StashGitCommand extends QuickCommandBase {
)
)
],
additionalButtons: [this.Buttons.OpenInView],
additionalButtons: [this.Buttons.RevealInView],
onDidClickButton: (quickpick, button) => {
if (button === this.Buttons.OpenInView) {
if (button === this.Buttons.RevealInView) {
if (quickpick.activeItems.length !== 0) {
void Container.repositoriesView.revealStash(quickpick.activeItems[0].item, {
select: true,
@ -519,9 +519,9 @@ export class StashGitCommand extends QuickCommandBase {
undefined,
{
placeholder: `Confirm ${this.title} ${getSubtitle(state.subcommand)}`,
additionalButtons: [this.Buttons.OpenInView],
additionalButtons: [this.Buttons.RevealInView],
onDidClickButton: (quickpick, button) => {
if (button === this.Buttons.OpenInView) {
if (button === this.Buttons.RevealInView) {
void Container.repositoriesView.revealStash(state.stash!, {
select: true,
expand: true
@ -569,9 +569,9 @@ export class StashGitCommand extends QuickCommandBase {
})
)
],
additionalButtons: [this.Buttons.OpenInView],
additionalButtons: [this.Buttons.RevealInView],
onDidClickButton: (quickpick, button) => {
if (button === this.Buttons.OpenInView) {
if (button === this.Buttons.RevealInView) {
if (quickpick.activeItems.length !== 0) {
void Container.repositoriesView.revealStash(quickpick.activeItems[0].item, {
select: true,
@ -616,17 +616,14 @@ export class StashGitCommand extends QuickCommandBase {
pickedStash.number === undefined ? '' : `${pickedStash.number}: `
}${pickedStash.getShortMessage()}`,
items: await CommitQuickPick.getItems(pickedStash, pickedStash.toGitUri(), { showChanges: false }),
additionalButtons: [this.Buttons.OpenInView],
additionalButtons: [this.Buttons.RevealInView],
onDidClickButton: (quickpick, button) => {
if (button !== this.Buttons.OpenInView) return;
if (button !== this.Buttons.RevealInView) return;
void Container.searchView.search(
pickedStash!.repoPath,
{ pattern: SearchPattern.fromCommit(pickedStash!) },
{
label: { label: `for commit id ${pickedStash!.shortSha}` }
}
);
void Container.repositoriesView.revealStash(pickedStash!, {
select: true,
expand: true
});
}
});
const selection: StepSelection<typeof step> = yield step;

+ 2
- 2
src/commands/showQuickFileHistory.ts Ver ficheiro

@ -8,7 +8,7 @@ import { Messages } from '../messages';
import {
CommandQuickPickItem,
FileHistoryQuickPick,
OpenFileHistoryInViewQuickPickItem,
OpenInFileHistoryViewQuickPickItem,
ShowFileHistoryFromQuickPickItem
} from '../quickpicks';
import { Iterables, Strings } from '../system';
@ -148,7 +148,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
: undefined,
showInViewCommand:
args.log !== undefined
? new OpenFileHistoryInViewQuickPickItem(
? new OpenInFileHistoryViewQuickPickItem(
gitUri,
(args.reference && args.reference.ref) || gitUri.sha
)

+ 5
- 6
src/quickpicks/commitQuickPick.ts Ver ficheiro

@ -31,9 +31,9 @@ import {
CommandQuickPickItem,
getQuickPickIgnoreFocusOut,
KeyCommandQuickPickItem,
OpenCommitInViewQuickPickItem,
OpenInSearchCommitsViewQuickPickItem,
QuickPickItem,
RevealCommitInViewQuickPickItem
RevealInRepositoriesViewQuickPickItem
} from './commonQuickPicks';
import { OpenRemotesCommandQuickPickItem } from './remotesQuickPick';
@ -284,11 +284,10 @@ export class CommitQuickPick {
)
);
items.push(new OpenCommitInViewQuickPickItem(commit));
items.push(new RevealCommitInViewQuickPickItem(commit));
items.push(new RevealInRepositoriesViewQuickPickItem(commit));
} else {
items.push(new OpenCommitInViewQuickPickItem(commit));
items.push(new RevealCommitInViewQuickPickItem(commit));
items.push(new OpenInSearchCommitsViewQuickPickItem(commit));
items.push(new RevealInRepositoriesViewQuickPickItem(commit));
items.push(new OpenCommitFilesCommandQuickPickItem(commit));
items.push(new OpenCommitFileRevisionsCommandQuickPickItem(commit));

+ 4
- 4
src/quickpicks/commonQuickPicks.ts Ver ficheiro

@ -98,11 +98,11 @@ export class MessageQuickPickItem extends CommandQuickPickItem {
}
}
export class OpenCommitInViewQuickPickItem extends CommandQuickPickItem {
export class OpenInSearchCommitsViewQuickPickItem extends CommandQuickPickItem {
constructor(
public readonly commit: GitLogCommit,
item: QuickPickItem = {
label: '$(eye) Open in Search Commits View',
label: '$(link-external) Open in Search Commits View',
description: ''
}
) {
@ -124,7 +124,7 @@ export class OpenCommitInViewQuickPickItem extends CommandQuickPickItem {
}
}
export class OpenFileHistoryInViewQuickPickItem extends CommandQuickPickItem {
export class OpenInFileHistoryViewQuickPickItem extends CommandQuickPickItem {
constructor(
public readonly uri: GitUri,
public readonly baseRef: string | undefined,
@ -141,7 +141,7 @@ export class OpenFileHistoryInViewQuickPickItem extends CommandQuickPickItem {
}
}
export class RevealCommitInViewQuickPickItem extends CommandQuickPickItem {
export class RevealInRepositoriesViewQuickPickItem extends CommandQuickPickItem {
constructor(
public readonly commit: GitLogCommit | GitStashCommit,
item: QuickPickItem = {

+ 12
- 4
src/views/repositoriesView.ts Ver ficheiro

@ -8,9 +8,16 @@ import {
ProgressLocation,
window
} from 'vscode';
import { configuration, RepositoriesViewConfig, ViewFilesLayout, ViewsConfig } from '../configuration';
import {
configuration,
RepositoriesViewConfig,
ViewFilesLayout,
ViewsConfig,
ViewShowBranchComparison
} from '../configuration';
import { CommandContext, setCommandContext, WorkspaceState } from '../constants';
import { Container } from '../container';
import { GitLogCommit, GitService, GitStashCommit } from '../git/gitService';
import {
BranchesNode,
BranchNode,
@ -22,10 +29,8 @@ import {
StashNode,
ViewNode
} from './nodes';
import { gate } from '../system';
import { ViewBase } from './viewBase';
import { ViewShowBranchComparison } from '../config';
import { GitLogCommit, GitStashCommit } from '../git/git';
import { GitService } from '../git/gitService';
export class RepositoriesView extends ViewBase<RepositoriesNode> {
constructor() {
@ -175,6 +180,7 @@ export class RepositoriesView extends ViewBase {
});
}
@gate<RepositoriesView['revealCommit']>(() => '')
revealCommit(
commit: GitLogCommit | { repoPath: string; ref: string },
options?: {
@ -214,6 +220,7 @@ export class RepositoriesView extends ViewBase {
);
}
@gate<RepositoriesView['revealStash']>(() => '')
async revealStash(
stash: GitStashCommit | { repoPath: string; ref: string; stashName: string },
options?: {
@ -239,6 +246,7 @@ export class RepositoriesView extends ViewBase {
);
}
@gate<RepositoriesView['revealStashes']>(() => '')
async revealStashes(
repoPath: string,
options?: {

+ 7
- 1
src/views/viewBase.ts Ver ficheiro

@ -175,7 +175,13 @@ export abstract class ViewBase> implements TreeData
@log({
args: {
0: (predicate: string | ((node: ViewNode) => boolean)) =>
typeof predicate === 'string' ? predicate : false
typeof predicate === 'string' ? predicate : 'function',
1: (opts: {
allowPaging?: boolean;
canTraverse?: (node: ViewNode) => boolean;
maxDepth?: number;
token?: CancellationToken;
}) => `options=${JSON.stringify({ ...opts, canTraverse: undefined, token: undefined })}`
}
})
async findNode(

Carregando…
Cancelar
Guardar