Quellcode durchsuchen

Adds reveal in explorer to worktree quickpick

Polishes open worktree items
main
Eric Amodio vor 2 Jahren
Ursprung
Commit
630c341b36
3 geänderte Dateien mit 30 neuen und 18 gelöschten Zeilen
  1. +25
    -10
      src/commands/git/worktree.ts
  2. +1
    -1
      src/commands/quickCommand.steps.ts
  3. +4
    -7
      src/quickpicks/items/gitCommands.ts

+ 25
- 10
src/commands/git/worktree.ts Datei anzeigen

@ -67,7 +67,7 @@ interface DeleteState {
flags: DeleteFlags[];
}
type OpenFlags = '--new-window';
type OpenFlags = '--new-window' | '--reveal-explorer';
interface OpenState {
subcommand: 'open';
@ -632,9 +632,10 @@ export class WorktreeGitCommand extends QuickCommand {
}),
FlagsQuickPickItem.create<DeleteFlags>(state.flags, ['--force'], {
label: `Force ${context.title}`,
description: 'including ANY UNCOMMITTED changes',
detail: `Will forcibly delete ${pluralize('worktree', state.uris.length, {
only: state.uris.length === 1,
})} even with UNCOMMITTED changes${
})} ${
state.uris.length === 1 ? ` in $(folder) ${GitWorktree.getFriendlyPath(state.uris[0])}` : ''
}`,
}),
@ -678,11 +679,15 @@ export class WorktreeGitCommand extends QuickCommand {
QuickCommand.endSteps(state);
const worktree = context.worktrees.find(wt => wt.uri.toString() === state.uri.toString())!;
GitActions.Worktree.open(worktree, {
location: state.flags.includes('--new-window')
? OpenWorkspaceLocation.NewWindow
: OpenWorkspaceLocation.CurrentWindow,
});
if (state.flags.includes('--reveal-explorer')) {
void GitActions.Worktree.revealInFileExplorer(worktree);
} else {
GitActions.Worktree.open(worktree, {
location: state.flags.includes('--new-window')
? OpenWorkspaceLocation.NewWindow
: OpenWorkspaceLocation.CurrentWindow,
});
}
}
}
@ -692,11 +697,21 @@ export class WorktreeGitCommand extends QuickCommand {
[
FlagsQuickPickItem.create<OpenFlags>(state.flags, [], {
label: context.title,
detail: `Will open the worktree in ${GitWorktree.getFriendlyPath(state.uri)} in the current window`,
detail: `Will open, in the current window, the worktree in $(folder) ${GitWorktree.getFriendlyPath(
state.uri,
)}`,
}),
FlagsQuickPickItem.create<OpenFlags>(state.flags, ['--new-window'], {
label: `${context.title} in New Window`,
detail: `Will open the worktree in ${GitWorktree.getFriendlyPath(state.uri)} in a new window`,
label: `${context.title} in a New Window`,
detail: `Will open, in a new window, the worktree in $(folder) ${GitWorktree.getFriendlyPath(
state.uri,
)}`,
}),
FlagsQuickPickItem.create<OpenFlags>(state.flags, ['--reveal-explorer'], {
label: `Reveal in File Explorer`,
detail: `Will open, in the File Explorer, the worktree in $(folder) ${GitWorktree.getFriendlyPath(
state.uri,
)}`,
}),
],
context,

+ 1
- 1
src/commands/quickCommand.steps.ts Datei anzeigen

@ -169,7 +169,7 @@ export async function getWorktrees(
(typeof picked === 'string' ? w.uri.toString() === picked : picked.includes(w.uri.toString())),
{
buttons: buttons,
ref: true,
path: true,
status: includeStatus ? await w.getStatus() : undefined,
},
),

+ 4
- 7
src/quickpicks/items/gitCommands.ts Datei anzeigen

@ -453,7 +453,7 @@ export namespace WorktreeQuickPickItem {
buttons?: QuickInputButton[];
checked?: boolean;
message?: boolean;
ref?: boolean;
path?: boolean;
type?: boolean;
status?: GitStatus;
},
@ -465,12 +465,8 @@ export namespace WorktreeQuickPickItem {
if (options?.status != null) {
description += options.status.hasChanges
? pad(`Uncommited Changes (${options.status.getFormattedDiffStatus()})`, description ? 2 : 0, 0)
: pad('No Changes', description ? 2 : 0, 0);
}
if (options?.ref) {
description += `${description ? pad(GlyphChars.Dot, 2, 2) : ''}${worktree.friendlyPath}`;
? pad(`Uncommited changes (${options.status.getFormattedDiffStatus()})`, description ? 2 : 0, 0)
: pad('No changes', description ? 2 : 0, 0);
}
let icon;
@ -493,6 +489,7 @@ export namespace WorktreeQuickPickItem {
const item: WorktreeQuickPickItem = {
label: `${icon}${GlyphChars.Space}${label}${options?.checked ? pad('$(check)', 2) : ''}`,
description: description,
detail: options?.path ? `In $(folder) ${worktree.friendlyPath}` : undefined,
alwaysShow: options?.alwaysShow,
buttons: options?.buttons,
picked: picked,

Laden…
Abbrechen
Speichern