Adds clipboard default into commit search

This commit is contained in:
Eric Amodio
2017-05-14 01:48:53 -04:00
parent 361789f859
commit 33ef9687f2

View File

@@ -5,6 +5,7 @@ import { GitRepoSearchBy, GitService, GitUri } from '../gitService';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { CommandQuickPickItem, CommitsQuickPick } from '../quickPicks'; import { CommandQuickPickItem, CommitsQuickPick } from '../quickPicks';
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails'; import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
import { paste } from 'copy-paste';
const searchByRegex = /^([@:#])/; const searchByRegex = /^([@:#])/;
const searchByMap = new Map<string, GitRepoSearchBy>([ const searchByMap = new Map<string, GitRepoSearchBy>([
@@ -34,6 +35,11 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
if (gitUri.repoPath === undefined) return undefined; if (gitUri.repoPath === undefined) return undefined;
if (!args.search || args.searchBy == null) { if (!args.search || args.searchBy == null) {
if (!args.search) {
args.search = await new Promise<string>((resolve, reject) => {
paste((err: Error, content: string) => resolve(err ? '' : content));
});
}
args.search = await window.showInputBox({ args.search = await window.showInputBox({
value: args.search, value: args.search,
prompt: `Please enter a search string`, prompt: `Please enter a search string`,