Browse Source

Adds Show All Commits to commit search

Adds Show in Results to file history quick pick
Adds re-query support to GitLog
Fixes Open in File/Revision for file history quick pick
main
Eric Amodio 7 years ago
parent
commit
b9bc84f0d2
12 changed files with 157 additions and 99 deletions
  1. +5
    -6
      README.md
  2. +12
    -4
      src/commands/diffWithRevision.ts
  3. +32
    -43
      src/commands/showCommitSearch.ts
  4. +0
    -3
      src/commands/showQuickBranchHistory.ts
  5. +18
    -5
      src/commands/showQuickFileHistory.ts
  6. +2
    -0
      src/git/models/log.ts
  7. +18
    -0
      src/gitService.ts
  8. +10
    -6
      src/quickPicks/commits.ts
  9. +17
    -4
      src/quickPicks/common.ts
  10. +24
    -22
      src/quickPicks/fileHistory.ts
  11. +1
    -1
      src/views/explorerCommands.ts
  12. +18
    -5
      src/views/resultsExplorer.ts

+ 5
- 6
README.md View File

@ -241,7 +241,7 @@ While GitLens is highly customizable and provides many [configuration settings](
![File History Quick Pick Menu](https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/screenshot-file-history.png)
- Provides entries to `Show Branch History` and `Open File in <remote-service>` when available
- Provides additional entries to `Show in Results`, `Show Branch History`, and `Open File in <remote-service>` when available
- Navigate back to the previous quick pick menu via `alt+left arrow`, if available
- Navigate pages via `alt+,` and `alt+.` to go backward and forward respectively
@ -250,7 +250,7 @@ While GitLens is highly customizable and provides many [configuration settings](
![Commit Details Quick Pick Menu](https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/screenshot-commit-details.png)
- Quickly see the set of files changed in the commit, complete with status indicators for adds, changes, renames, and deletes
- Provides entries to `Copy to Clipboard`, `Compare Directory with...`, `Open Changed Files`, `Open File in <remote-service>` when available, and more
- Provides additional entries to `Open Commit in <remote-service>` when available, `Open Files`, `Open Revisions`, `Compare Directory with Previous Revision`, `Compare Directory with Working Tree`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`
- Navigate back to the previous quick pick menu via `alt+left arrow`, if available
- Use the `alt+right arrow` shortcut on an entry to execute it without closing the quick pick menu, if possible — commands that open windows outside of VS Code will still close the quick pick menu unless [`"gitlens.advanced.quickPick.closeOnFocusOut": false`](#extension-settings) is set
- Use the `alt+right arrow` shortcut on a file entry in the `Changed Files` section to preview the comparison of the current revision with the previous one
@ -259,7 +259,7 @@ While GitLens is highly customizable and provides many [configuration settings](
![Commit File Details Quick Pick Menu](https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/screenshot-commit-file-details.png)
- Provides entries to `Show Commit Details`, `Show File History`, `Compare File with...`, `Copy to Clipboard`, `Open File`, `Open File in <remote-service>` when available, and more
- Provides entries to `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in <remote-service>` when available, `Open Revision in <remote-service>` when available, an class="sb">`Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Show Commit Details`, `Show File History`, and `Show Previous File History`
- Navigate back to the previous quick pick menu via `alt+left arrow`, if available
- Use the `alt+right arrow` shortcut on an entry to execute it without closing the quick pick menu, if possible — commands that open windows outside of VS Code will still close the quick pick menu unless [`"gitlens.advanced.quickPick.closeOnFocusOut": false`](#extension-settings) is set
@ -279,7 +279,7 @@ While GitLens is highly customizable and provides many [configuration settings](
![Stashed Changes Quick Pick Menu](https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/screenshot-stash-list.png)
- Provides entries to `Stash Changes`
- Provides additional entries to `Stash Changes`
- Navigate back to the previous quick pick menu via `alt+left arrow`, if available
- Choosing a stash entry shows a **stash details quick pick menu** which is very similar to the **commit details quick pick menu** above
@ -287,8 +287,7 @@ While GitLens is highly customizable and provides many [configuration settings](
![Stash Details Quick Pick Menu](https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/screenshot-stash-details.png)
- Quickly see the set of files changed in the stash, complete with status indicators for adds, changes, renames, and deletes
- Provides entries to `Copy Message to Clipboard`, `Compare Directory with...`, and `Open Changed Files`
- Provides entries to `Apply Stashed Changes` and `Delete Stashed Changes` — both require a confirmation
- Provides additional entries to `Apply Stashed Changes` (requires confirmation), `Delete Stashed Changes` (requires confirmation), `Open Files`, `Open Revisions`, `Compare Directory with Previous Revision`, `Compare Directory with Working Tree`, `Copy Commit Message to Clipboard`
- Navigate back to the previous quick pick menu via `alt+left arrow`, if available
- Use the `alt+right arrow` shortcut on an entry to execute it without closing the quick pick menu, if possible — commands that open windows outside of VS Code will still close the quick pick menu unless [`"gitlens.advanced.quickPick.closeOnFocusOut": false`](#extension-settings) is set
- Use the `alt+right arrow` shortcut on a file entry in the `Changed Files` section to preview the comparison of the current revision with the previous one

+ 12
- 4
src/commands/diffWithRevision.ts View File

@ -1,6 +1,8 @@
'use strict';
import { Strings } from '../system';
import { commands, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
import { GlyphChars } from '../constants';
import { DiffWithCommandArgs } from './diffWith';
import { GitService, GitUri } from '../gitService';
import { Logger } from '../logger';
@ -32,9 +34,6 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand {
}
const gitUri = await GitUri.fromUri(uri, this.git);
if (args.maxCount == null) {
args.maxCount = this.git.config.advanced.maxQuickHistory;
}
const progressCancellation = FileHistoryQuickPick.showProgress(gitUri);
try {
@ -43,7 +42,16 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand {
if (progressCancellation.token.isCancellationRequested) return undefined;
const pick = await FileHistoryQuickPick.show(this.git, log, gitUri, progressCancellation, { pickerOnly: true });
const label = `${gitUri.getFormattedPath()}${gitUri.sha ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${gitUri.shortSha}` : ''}`;
const pick = await FileHistoryQuickPick.show(this.git, log, gitUri, label, progressCancellation, {
pickerOnly: true,
showAllCommand: log !== undefined && log.truncated
? new CommandQuickPickItem({
label: `$(sync) Show All Commits`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} this may take a while`
}, Commands.ShowQuickFileHistory, [uri, { ...args, maxCount: 0 }])
: undefined
});
if (pick === undefined) return undefined;
if (pick instanceof CommandQuickPickItem) return pick.execute();

+ 32
- 43
src/commands/showCommitSearch.ts View File

@ -6,7 +6,7 @@ import { GlyphChars } from '../constants';
import { GitRepoSearchBy, GitService, GitUri } from '../gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem, CommitsQuickPick, ShowCommitsInResultsQuickPickItem } from '../quickPicks';
import { CommandQuickPickItem, CommitsQuickPick, ShowCommitsSearchInResultsQuickPickItem } from '../quickPicks';
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
const searchByRegex = /^([@~=:#])/;
@ -21,6 +21,7 @@ const searchByMap = new Map([
export interface ShowCommitSearchCommandArgs {
search?: string;
searchBy?: GitRepoSearchBy;
maxCount?: number;
goBackCommand?: CommandQuickPickItem;
}
@ -42,6 +43,8 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
if (!repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to show commit search`);
args = { ...args };
const originalArgs = { ...args };
if (!args.search || args.searchBy == null) {
try {
if (!args.search) {
@ -64,6 +67,8 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
} as InputBoxOptions);
if (args.search === undefined) return args.goBackCommand === undefined ? undefined : args.goBackCommand.execute();
originalArgs.search = args.search;
const match = searchByRegex.exec(args.search);
if (match && match[1]) {
args.searchBy = searchByMap.get(match[1]);
@ -81,67 +86,54 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
args.searchBy = GitRepoSearchBy.Message;
}
let originalSearch: string | undefined = undefined;
let placeHolder: string | undefined = undefined;
let searchLabel: string | undefined = undefined;
switch (args.searchBy) {
case GitRepoSearchBy.Author:
originalSearch = `@${args.search}`;
placeHolder = `commits with an author matching '${args.search}'`;
searchLabel = `commits with an author matching '${args.search}'`;
break;
case GitRepoSearchBy.Changes:
originalSearch = `~${args.search}`;
placeHolder = `commits with changes matching '${args.search}'`;
searchLabel = `commits with changes matching '${args.search}'`;
break;
case GitRepoSearchBy.ChangesOccurrences:
originalSearch = `=${args.search}`;
placeHolder = `commits with changes (new occurrences) matching '${args.search}'`;
searchLabel = `commits with changes (new occurrences) matching '${args.search}'`;
break;
case GitRepoSearchBy.Files:
originalSearch = `:${args.search}`;
placeHolder = `commits with files matching '${args.search}'`;
searchLabel = `commits with files matching '${args.search}'`;
break;
case GitRepoSearchBy.Message:
originalSearch = args.search;
placeHolder = `commits with a message matching '${args.search}'`;
searchLabel = `commits with a message matching '${args.search}'`;
break;
case GitRepoSearchBy.Sha:
originalSearch = `#${args.search}`;
placeHolder = `commits with an id matching '${args.search}'`;
searchLabel = `commits with an id matching '${args.search}'`;
break;
}
const progressCancellation = CommitsQuickPick.showProgress(placeHolder!);
const progressCancellation = CommitsQuickPick.showProgress(searchLabel!);
try {
const queryFn = ((search: string, searchBy: GitRepoSearchBy) => (maxCount: number | undefined) => this.git.getLogForRepoSearch(repoPath, search, searchBy, { maxCount: maxCount }))(args.search, args.searchBy);
const log = await queryFn(undefined);
const log = await this.git.getLogForRepoSearch(repoPath, args.search, args.searchBy, { maxCount: args.maxCount });
if (progressCancellation.token.isCancellationRequested) return undefined;
// Create a command to get back to here
const currentCommand = new CommandQuickPickItem({
label: `go back ${GlyphChars.ArrowBack}`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to commit search`
}, Commands.ShowCommitSearch, [
uri,
{
search: originalSearch,
goBackCommand: args.goBackCommand
} as ShowCommitSearchCommandArgs
]);
const showInResultsExplorer = log !== undefined
? new ShowCommitsInResultsQuickPickItem(placeHolder!, log, queryFn, {
label: 'Show in Results',
description: `${Strings.pad(GlyphChars.Dash, 2, 2)} displays results in the GitLens Results view`
})
: undefined;
const pick = await CommitsQuickPick.show(this.git, log, placeHolder!, progressCancellation, currentCommand, showInResultsExplorer);
const pick = await CommitsQuickPick.show(this.git, log, searchLabel!, progressCancellation, {
goBackCommand: new CommandQuickPickItem({
label: `go back ${GlyphChars.ArrowBack}`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to commit search`
}, Commands.ShowCommitSearch, [uri, originalArgs]),
showAllCommand: log !== undefined && log.truncated
? new CommandQuickPickItem({
label: `$(sync) Show All Commits`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} this may take a while`
}, Commands.ShowCommitSearch, [uri, { ...args, maxCount: 0 }])
: undefined,
showInResultsExplorerCommand: log !== undefined
? new ShowCommitsSearchInResultsQuickPickItem(log, searchLabel!)
: undefined
});
if (pick === undefined) return undefined;
if (pick instanceof CommandQuickPickItem) return pick.execute();
@ -153,11 +145,8 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
commit: pick.commit,
goBackCommand: new CommandQuickPickItem({
label: `go back ${GlyphChars.ArrowBack}`,
description: `${Strings.pad(GlyphChars.Dash, 2, 2)} to search for ${placeHolder}`
}, Commands.ShowCommitSearch, [
uri,
args
])
description: `${Strings.pad(GlyphChars.Dash, 2, 2)} to search for ${searchLabel}`
}, Commands.ShowCommitSearch, [ uri, args ])
} as ShowQuickCommitDetailsCommandArgs);
}
catch (ex) {

+ 0
- 3
src/commands/showQuickBranchHistory.ts View File

@ -32,9 +32,6 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
const gitUri = uri && await GitUri.fromUri(uri, this.git);
args = { ...args };
if (args.maxCount == null) {
args.maxCount = this.git.config.advanced.maxQuickHistory;
}
let progressCancellation = args.branch === undefined ? undefined : BranchHistoryQuickPick.showProgress(args.branch);
try {

+ 18
- 5
src/commands/showQuickFileHistory.ts View File

@ -5,7 +5,7 @@ import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
import { GlyphChars } from '../constants';
import { GitLog, GitService, GitUri } from '../gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, FileHistoryQuickPick } from '../quickPicks';
import { CommandQuickPickItem, FileHistoryQuickPick, ShowCommitsInResultsQuickPickItem } from '../quickPicks';
import { ShowQuickCommitFileDetailsCommandArgs } from './showQuickCommitFileDetails';
import { Messages } from '../messages';
import * as path from 'path';
@ -34,9 +34,6 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
const gitUri = await GitUri.fromUri(uri, this.git);
args = { ...args };
if (args.maxCount == null) {
args.maxCount = this.git.config.advanced.maxQuickHistory;
}
const progressCancellation = FileHistoryQuickPick.showProgress(gitUri);
try {
@ -47,7 +44,23 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
if (progressCancellation.token.isCancellationRequested) return undefined;
const pick = await FileHistoryQuickPick.show(this.git, args.log, gitUri, progressCancellation, { goBackCommand: args.goBackCommand, nextPageCommand: args.nextPageCommand });
const label = `${gitUri.getFormattedPath()}${gitUri.sha ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${gitUri.shortSha}` : ''}`;
const pick = await FileHistoryQuickPick.show(this.git, args.log, gitUri, label, progressCancellation, {
goBackCommand: args.goBackCommand,
nextPageCommand: args.nextPageCommand,
showAllCommand: args.log !== undefined && args.log.truncated
? new CommandQuickPickItem({
label: `$(sync) Show All Commits`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} this may take a while`
}, Commands.ShowQuickFileHistory, [uri, { ...args, maxCount: 0 }])
: undefined,
showInResultsExplorerCommand: args.log !== undefined
? new ShowCommitsInResultsQuickPickItem(args.log, {
label: label,
resultsType: { singular: 'commit', plural: 'commits' }
})
: undefined
});
if (pick === undefined) return undefined;
if (pick instanceof CommandQuickPickItem) return pick.execute();

+ 2
- 0
src/git/models/log.ts View File

@ -13,4 +13,6 @@ export interface GitLog {
maxCount: number | undefined;
range: Range;
truncated: boolean;
query: (maxCount: number | undefined) => Promise<GitLog | undefined>;
}

+ 18
- 0
src/gitService.ts View File

@ -870,6 +870,12 @@ export class GitService extends Disposable {
try {
const data = await Git.log(repoPath, { maxCount: maxCount, ref: options.ref, reverse: options.reverse });
const log = GitLogParser.parse(data, GitCommitType.Branch, repoPath, undefined, options.ref, maxCount, options.reverse!, undefined);
if (log !== undefined) {
const opts = { ...options };
log.query = (maxCount: number | undefined) => this.getLogForRepo(repoPath, { ...opts, maxCount: maxCount });
}
return log;
}
catch (ex) {
@ -910,6 +916,12 @@ export class GitService extends Disposable {
try {
const data = await Git.log_search(repoPath, searchArgs, { maxCount: maxCount });
const log = GitLogParser.parse(data, GitCommitType.Branch, repoPath, undefined, undefined, maxCount, false, undefined);
if (log !== undefined) {
const opts = { ...options };
log.query = (maxCount: number | undefined) => this.getLogForRepoSearch(repoPath, search, searchBy, { ...opts, maxCount: maxCount });
}
return log;
}
catch (ex) {
@ -1000,6 +1012,12 @@ export class GitService extends Disposable {
const data = await Git.log_file(root, file, { ...opts, maxCount: maxCount, startLine: range && range.start.line + 1, endLine: range && range.end.line + 1 });
const log = GitLogParser.parse(data, GitCommitType.File, root, file, opts.ref, maxCount, opts.reverse!, range);
if (log !== undefined) {
const opts = { ...options };
log.query = (maxCount: number | undefined) => this.getLogForFile(repoPath, fileName, { ...opts, maxCount: maxCount });
}
return log;
}
catch (ex) {

+ 10
- 6
src/quickPicks/commits.ts View File

@ -16,20 +16,24 @@ export class CommitsQuickPick {
});
}
static async show(git: GitService, log: GitLog | undefined, placeHolder: string, progressCancellation: CancellationTokenSource, goBackCommand?: CommandQuickPickItem, showInResultsExplorerCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
static async show(git: GitService, log: GitLog | undefined, placeHolder: string, progressCancellation: CancellationTokenSource, options: { goBackCommand?: CommandQuickPickItem, showAllCommand?: CommandQuickPickItem, showInResultsExplorerCommand?: CommandQuickPickItem }): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
const items = ((log && [...Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))]) || [new MessageQuickPickItem('No results found')]) as (CommitQuickPickItem | CommandQuickPickItem)[];
if (showInResultsExplorerCommand !== undefined) {
items.splice(0, 0, showInResultsExplorerCommand);
if (options.showInResultsExplorerCommand !== undefined) {
items.splice(0, 0, options.showInResultsExplorerCommand);
}
if (goBackCommand !== undefined) {
items.splice(0, 0, goBackCommand);
if (options.showAllCommand !== undefined) {
items.splice(0, 0, options.showAllCommand);
}
if (options.goBackCommand !== undefined) {
items.splice(0, 0, options.goBackCommand);
}
if (progressCancellation.token.isCancellationRequested) return undefined;
const scope = await Keyboard.instance.beginScope({ left: goBackCommand });
const scope = await Keyboard.instance.beginScope({ left: options.goBackCommand });
progressCancellation.cancel();

+ 17
- 4
src/quickPicks/common.ts View File

@ -194,16 +194,29 @@ export class CommitQuickPickItem implements QuickPickItem {
export class ShowCommitsInResultsQuickPickItem extends CommandQuickPickItem {
constructor(
public readonly search: string,
public readonly results: GitLog,
public readonly queryFn: (maxCount: number | undefined) => Promise<GitLog | undefined>,
item: QuickPickItem
public readonly resultsLabel: string | { label: string, resultsType?: { singular: string, plural: string } },
item: QuickPickItem = {
label: 'Show in Results',
description: `${Strings.pad(GlyphChars.Dash, 2, 2)} displays results in the GitLens Results view`
}
) {
super(item, undefined, undefined);
}
async execute(options: TextDocumentShowOptions = { preserveFocus: false, preview: false }): Promise<{} | undefined> {
ResultsExplorer.instance.showCommitSearchResults(this.search, this.results, this.queryFn);
ResultsExplorer.instance.showCommitsInResults(this.results, this.resultsLabel);
return undefined;
}
}
export class ShowCommitsSearchInResultsQuickPickItem extends ShowCommitsInResultsQuickPickItem {
constructor(
public readonly results: GitLog,
public readonly search: string,
item?: QuickPickItem
) {
super(results, { label: search }, item);
}
}

+ 24
- 22
src/quickPicks/fileHistory.ts View File

@ -20,27 +20,24 @@ export class FileHistoryQuickPick {
});
}
static async show(git: GitService, log: GitLog, uri: GitUri, progressCancellation: CancellationTokenSource, options: { goBackCommand?: CommandQuickPickItem, nextPageCommand?: CommandQuickPickItem, pickerOnly?: boolean } = {}): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
options = { ...{ pickerOnly: false }, ...options };
static async show(git: GitService, log: GitLog, uri: GitUri, placeHolder: string, progressCancellation: CancellationTokenSource, options: { goBackCommand?: CommandQuickPickItem, nextPageCommand?: CommandQuickPickItem, pickerOnly?: boolean, showAllCommand?: CommandQuickPickItem, showInResultsExplorerCommand?: CommandQuickPickItem } = {}): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
options = { pickerOnly: false, ...options };
const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))) as (CommitQuickPickItem | CommandQuickPickItem)[];
let previousPageCommand: CommandQuickPickItem | undefined = undefined;
let index = 0;
if (options.showInResultsExplorerCommand !== undefined) {
index++;
items.splice(0, 0, options.showInResultsExplorerCommand);
}
if (log.truncated || log.sha) {
if (log.truncated) {
if (options.showAllCommand !== undefined) {
index++;
items.splice(0, 0, new CommandQuickPickItem({
label: `$(sync) Show All Commits`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} this may take a while`
}, Commands.ShowQuickFileHistory, [
Uri.file(uri.fsPath),
{
maxCount: 0,
goBackCommand: options.goBackCommand
} as ShowQuickFileHistoryCommandArgs
]));
items.splice(0, 0, options.showAllCommand);
}
else {
const workingFileName = await git.findWorkingFileName(log.repoPath, path.relative(log.repoPath, uri.fsPath));
@ -138,12 +135,19 @@ export class FileHistoryQuickPick {
const remotes = (await git.getRemotes(uri.repoPath!)).filter(r => r.provider !== undefined);
if (remotes.length) {
items.splice(index++, 0, new OpenRemotesCommandQuickPickItem(remotes, {
type: 'revision',
branch: branch!.name,
fileName: uri.getRelativePath(),
sha: uri.sha
} as RemoteResource, currentCommand));
const resource = uri.sha !== undefined
? {
type: 'revision',
branch: branch!.name,
fileName: uri.getRelativePath(),
sha: uri.sha
} as RemoteResource
: {
type: 'file',
branch: branch!.name,
fileName: uri.getRelativePath()
} as RemoteResource;
items.splice(index++, 0, new OpenRemotesCommandQuickPickItem(remotes, resource, currentCommand));
}
if (options.goBackCommand) {
@ -159,14 +163,12 @@ export class FileHistoryQuickPick {
'.': options.nextPageCommand
});
const commit = Iterables.first(log.commits.values());
progressCancellation.cancel();
const pick = await window.showQuickPick(items, {
matchOnDescription: true,
matchOnDetail: true,
placeHolder: `${commit.getFormattedPath()}${uri.sha ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${uri.shortSha}` : ''}`,
placeHolder: placeHolder,
ignoreFocusOut: getQuickPickIgnoreFocusOut()
// onDidSelectItem: (item: QuickPickItem) => {
// scope.setKeyCommand('right', item);

+ 1
- 1
src/views/explorerCommands.ts View File

@ -57,7 +57,7 @@ export class ExplorerCommands extends Disposable {
if (this._selection === undefined || !(node instanceof ExplorerRefNode)) return;
if (this._selection.repoPath !== node.repoPath) return;
ResultsExplorer.instance.showCommitComparisonResults(this._selection.repoPath, this._selection.ref, node.ref);
ResultsExplorer.instance.showComparisonInResults(this._selection.repoPath, this._selection.ref, node.ref);
}
private _selection: { ref: string, repoPath: string | undefined } | undefined;

+ 18
- 5
src/views/resultsExplorer.ts View File

@ -125,21 +125,31 @@ export class ResultsExplorer implements TreeDataProvider {
this._onDidChangeTreeData.fire();
}
async showCommitComparisonResults(repoPath: string, ref1: string, ref2: string) {
async showComparisonInResults(repoPath: string, ref1: string, ref2: string) {
this.addResults(new ComparisionResultsNode(repoPath, ref1, ref2, this));
setCommandContext(CommandContext.ResultsExplorer, true);
}
showCommitSearchResults(search: string, results: GitLog, queryFn: (maxCount: number | undefined) => Promise<GitLog | undefined>) {
showCommitsInResults(results: GitLog, resultsLabel: string | { label: string, resultsType?: { singular: string, plural: string } }) {
const query = results.query === undefined
? (maxCount: number | undefined) => Promise.resolve(results)
: results.query;
const labelFn = (log: GitLog | undefined) => {
if (typeof resultsLabel === 'string') return resultsLabel;
const count = log !== undefined ? log.count : 0;
const truncated = log !== undefined ? log.truncated : false;
if (count === 1) return `1 result for ${search}`;
return `${count === 0 ? 'No' : `${count}${truncated ? '+' : ''}`} results for ${search}`;
const resultsType = resultsLabel.resultsType === undefined
? { singular: 'result', plural: 'results' }
: resultsLabel.resultsType;
if (count === 1) return `1 ${resultsType.singular} for ${resultsLabel.label}`;
return `${count === 0 ? 'No' : `${count}${truncated ? '+' : ''}`} ${resultsType.plural} for ${resultsLabel.label}`;
};
this.addResults(new CommitsResultsNode(results.repoPath, labelFn, Functions.seeded(queryFn, results), this, ResourceType.SearchResults));
this.addResults(new CommitsResultsNode(results.repoPath, labelFn, Functions.seeded(query, results), this, ResourceType.SearchResults));
setCommandContext(CommandContext.ResultsExplorer, true);
}
@ -167,6 +177,9 @@ export class ResultsExplorer implements TreeDataProvider {
if (index === -1) return;
this._roots.splice(index, 1);
node.dispose();
this.refresh();
}

Loading…
Cancel
Save