|
@ -1,15 +1,27 @@ |
|
|
'use strict'; |
|
|
'use strict'; |
|
|
import { Iterables } from '../system'; |
|
|
import { Iterables } from '../system'; |
|
|
import { QuickPickOptions, window } from 'vscode'; |
|
|
import { QuickPickOptions, window } from 'vscode'; |
|
|
import { Keyboard } from '../commands'; |
|
|
|
|
|
import { IGitStash } from '../gitService'; |
|
|
|
|
|
|
|
|
import { Commands, Keyboard } from '../commands'; |
|
|
|
|
|
import { GitService, IGitStash } from '../gitService'; |
|
|
import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut } from '../quickPicks'; |
|
|
import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut } from '../quickPicks'; |
|
|
|
|
|
|
|
|
export class StashListQuickPick { |
|
|
export class StashListQuickPick { |
|
|
|
|
|
|
|
|
static async show(stash: IGitStash, placeHolder?: string, goBackCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> { |
|
|
|
|
|
|
|
|
static async show(git: GitService, stash: IGitStash, mode: 'list' | 'apply', goBackCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> { |
|
|
const items = ((stash && Array.from(Iterables.map(stash.commits.values(), c => new CommitQuickPickItem(c)))) || []) as (CommitQuickPickItem | CommandQuickPickItem)[]; |
|
|
const items = ((stash && Array.from(Iterables.map(stash.commits.values(), c => new CommitQuickPickItem(c)))) || []) as (CommitQuickPickItem | CommandQuickPickItem)[]; |
|
|
|
|
|
|
|
|
|
|
|
if (mode === 'list' && git.config.insiders) { |
|
|
|
|
|
items.splice(0, 0, new CommandQuickPickItem({ |
|
|
|
|
|
label: `$(repo-push) Stash Unstaged Changes`, |
|
|
|
|
|
description: `\u00a0 \u2014 \u00a0\u00a0 stashes only unstaged changes` |
|
|
|
|
|
}, Commands.StashSave, [undefined, true])); |
|
|
|
|
|
|
|
|
|
|
|
items.splice(0, 0, new CommandQuickPickItem({ |
|
|
|
|
|
label: `$(repo-push) Stash Changes`, |
|
|
|
|
|
description: `\u00a0 \u2014 \u00a0\u00a0 stashes all changes` |
|
|
|
|
|
}, Commands.StashSave)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (goBackCommand) { |
|
|
if (goBackCommand) { |
|
|
items.splice(0, 0, goBackCommand); |
|
|
items.splice(0, 0, goBackCommand); |
|
|
} |
|
|
} |
|
@ -18,7 +30,9 @@ export class StashListQuickPick { |
|
|
|
|
|
|
|
|
const pick = await window.showQuickPick(items, { |
|
|
const pick = await window.showQuickPick(items, { |
|
|
matchOnDescription: true, |
|
|
matchOnDescription: true, |
|
|
placeHolder: placeHolder || `stashed changes \u2014 search by message, filename, or sha`, |
|
|
|
|
|
|
|
|
placeHolder: mode === 'apply' |
|
|
|
|
|
? `Apply stashed changes to your working tree\u2026` |
|
|
|
|
|
: `stashed changes \u2014 search by message, filename, or sha`, |
|
|
ignoreFocusOut: getQuickPickIgnoreFocusOut() |
|
|
ignoreFocusOut: getQuickPickIgnoreFocusOut() |
|
|
// onDidSelectItem: (item: QuickPickItem) => {
|
|
|
// onDidSelectItem: (item: QuickPickItem) => {
|
|
|
// scope.setKeyCommand('right', item);
|
|
|
// scope.setKeyCommand('right', item);
|
|
|