Skip to content

Commit 32fad7f

Browse files
committed
Improves quick pick buttons -- moves many to items
Uses new quick pick buttons api
1 parent c00fe93 commit 32fad7f

15 files changed

+451
-331
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1818
- Adds commit message autolinking of merged pull requests for Azure Repos — closes [#1486](https://github.com/eamodio/vscode-gitlens/issues/1486) thanks to [PR #1487](https://github.com/eamodio/vscode-gitlens/pull/1487) by Mark Molinaro ([@markjm](https://github.com/markjm))
1919
- Adds a new `AzureDevOps` type to `gitlens.remotes` to better support Azure DevOps remote matching — thanks to [PR #1487](https://github.com/eamodio/vscode-gitlens/pull/1487) by Dmitry Gurovich ([@yrtimiD](https://github.com/yrtimiD))
2020
- Adds functional groupings to all GitLens settings when using the VS Code settings UI. Groups will be displayed in the table of contents in the settings UI — thanks to @rzhao271 for adding grouping support to VS Code settings UI
21+
- Adds new action buttons on many quick pick menu options, including in the _Git Command Palette_ — thanks to @tylerLeonhardt for the VS Code API support
2122

2223
### Changed
2324

src/@types/timeline.d.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.
File renamed without changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
declare module 'vscode' {
2+
export interface GitTimelineItem extends TimelineItem {
3+
readonly ref: string;
4+
readonly previousRef: string;
5+
readonly message: string;
6+
}
7+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
// https://github.com/microsoft/vscode/issues/88716
7+
8+
declare module 'vscode' {
9+
export interface QuickPickItem {
10+
buttons?: QuickInputButton[];
11+
}
12+
13+
export interface QuickPick<T extends QuickPickItem> extends QuickInput {
14+
readonly onDidTriggerItemButton: Event<QuickPickItemButtonEvent<T>>;
15+
}
16+
17+
export interface QuickPickItemButtonEvent<T extends QuickPickItem> {
18+
button: QuickInputButton;
19+
item: T;
20+
}
21+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
// https://github.com/microsoft/vscode/issues/132068
7+
8+
declare module 'vscode' {
9+
export interface QuickPick<T extends QuickPickItem> extends QuickInput {
10+
/*
11+
* An optional flag to maintain the scroll position of the quick pick when the quick pick items are updated. Defaults to false.
12+
*/
13+
keepScrollPosition?: boolean;
14+
}
15+
}
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
declare module 'vscode' {
7+
// https://github.com/microsoft/vscode/issues/84297
8+
9+
export class TimelineItem {
10+
/**
11+
* A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred.
12+
*/
13+
timestamp: number;
14+
15+
/**
16+
* A human-readable string describing the timeline item.
17+
*/
18+
label: string;
19+
20+
/**
21+
* Optional id for the timeline item. It must be unique across all the timeline items provided by this source.
22+
*
23+
* If not provided, an id is generated using the timeline item's timestamp.
24+
*/
25+
id?: string;
26+
27+
/**
28+
* The icon path or {@link ThemeIcon} for the timeline item.
29+
*/
30+
iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
31+
32+
/**
33+
* A human readable string describing less prominent details of the timeline item.
34+
*/
35+
description?: string;
36+
37+
/**
38+
* The tooltip text when you hover over the timeline item.
39+
*/
40+
detail?: string;
41+
42+
/**
43+
* The {@link Command} that should be executed when the timeline item is selected.
44+
*/
45+
command?: Command;
46+
47+
/**
48+
* Context value of the timeline item. This can be used to contribute specific actions to the item.
49+
* For example, a timeline item is given a context value as `commit`. When contributing actions to `timeline/item/context`
50+
* using `menus` extension point, you can specify context value for key `timelineItem` in `when` expression like `timelineItem == commit`.
51+
* ```
52+
* "contributes": {
53+
* "menus": {
54+
* "timeline/item/context": [
55+
* {
56+
* "command": "extension.copyCommitId",
57+
* "when": "timelineItem == commit"
58+
* }
59+
* ]
60+
* }
61+
* }
62+
* ```
63+
* This will show the `extension.copyCommitId` action only for items where `contextValue` is `commit`.
64+
*/
65+
contextValue?: string;
66+
67+
/**
68+
* Accessibility information used when screen reader interacts with this timeline item.
69+
*/
70+
accessibilityInformation?: AccessibilityInformation;
71+
72+
/**
73+
* @param label A human-readable string describing the timeline item
74+
* @param timestamp A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred
75+
*/
76+
constructor(label: string, timestamp: number);
77+
}
78+
79+
export interface TimelineChangeEvent {
80+
/**
81+
* The {@link Uri} of the resource for which the timeline changed.
82+
*/
83+
uri: Uri;
84+
85+
/**
86+
* A flag which indicates whether the entire timeline should be reset.
87+
*/
88+
reset?: boolean;
89+
}
90+
91+
export interface Timeline {
92+
readonly paging?: {
93+
/**
94+
* A provider-defined cursor specifying the starting point of timeline items which are after the ones returned.
95+
* Use `undefined` to signal that there are no more items to be returned.
96+
*/
97+
readonly cursor: string | undefined;
98+
};
99+
100+
/**
101+
* An array of {@link TimelineItem timeline items}.
102+
*/
103+
readonly items: readonly TimelineItem[];
104+
}
105+
106+
export interface TimelineOptions {
107+
/**
108+
* A provider-defined cursor specifying the starting point of the timeline items that should be returned.
109+
*/
110+
cursor?: string;
111+
112+
/**
113+
* An optional maximum number timeline items or the all timeline items newer (inclusive) than the timestamp or id that should be returned.
114+
* If `undefined` all timeline items should be returned.
115+
*/
116+
limit?: number | { timestamp: number; id?: string };
117+
}
118+
119+
export interface TimelineProvider {
120+
/**
121+
* An optional event to signal that the timeline for a source has changed.
122+
* To signal that the timeline for all resources (uris) has changed, do not pass any argument or pass `undefined`.
123+
*/
124+
onDidChange?: Event<TimelineChangeEvent | undefined>;
125+
126+
/**
127+
* An identifier of the source of the timeline items. This can be used to filter sources.
128+
*/
129+
readonly id: string;
130+
131+
/**
132+
* A human-readable string describing the source of the timeline items. This can be used as the display label when filtering sources.
133+
*/
134+
readonly label: string;
135+
136+
/**
137+
* Provide {@link TimelineItem timeline items} for a {@link Uri}.
138+
*
139+
* @param uri The {@link Uri} of the file to provide the timeline for.
140+
* @param options A set of options to determine how results should be returned.
141+
* @param token A cancellation token.
142+
* @return The {@link TimelineResult timeline result} or a thenable that resolves to such. The lack of a result
143+
* can be signaled by returning `undefined`, `null`, or an empty array.
144+
*/
145+
provideTimeline(uri: Uri, options: TimelineOptions, token: CancellationToken): ProviderResult<Timeline>;
146+
}
147+
148+
export namespace workspace {
149+
/**
150+
* Register a timeline provider.
151+
*
152+
* Multiple providers can be registered. In that case, providers are asked in
153+
* parallel and the results are merged. A failing provider (rejected promise or exception) will
154+
* not cause a failure of the whole operation.
155+
*
156+
* @param scheme A scheme or schemes that defines which documents this provider is applicable to. Can be `*` to target all documents.
157+
* @param provider A timeline provider.
158+
* @return A {@link Disposable} that unregisters this provider when being disposed.
159+
*/
160+
export function registerTimelineProvider(scheme: string | string[], provider: TimelineProvider): Disposable;
161+
}
162+
}

src/commands/gitCommands.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ export class GitCommandsCommand extends Command {
403403
const originalStepIgnoreFocusOut = step.ignoreFocusOut;
404404

405405
const quickpick = window.createQuickPick();
406+
(quickpick as any).enableProposedApi = true;
406407
quickpick.ignoreFocusOut = originalIgnoreFocusOut;
407408

408409
const disposables: Disposable[] = [];
@@ -467,7 +468,9 @@ export class GitCommandsCommand extends Command {
467468
disposables.push(
468469
scope,
469470
quickpick.onDidHide(() => resolve(undefined)),
470-
471+
quickpick.onDidTriggerItemButton(async e =>
472+
step.onDidClickItemButton?.(quickpick, e.button, e.item),
473+
),
471474
quickpick.onDidTriggerButton(async e => {
472475
if (e === QuickInputButtons.Back) {
473476
void goBack();

src/commands/openOnRemote.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ import { Container } from '../container';
44
import { GitRemote, GitRevision, RemoteProvider, RemoteResource, RemoteResourceType } from '../git/git';
55
import { Logger } from '../logger';
66
import { Messages } from '../messages';
7-
import {
8-
CopyOrOpenRemoteCommandQuickPickItem,
9-
RemoteProviderPicker,
10-
SetADefaultRemoteCommandQuickPickItem,
11-
} from '../quickpicks';
7+
import { RemoteProviderPicker } from '../quickpicks';
128
import { Strings } from '../system';
139
import { Command, command, Commands } from './common';
1410

@@ -157,20 +153,6 @@ export class OpenOnRemoteCommand extends Command {
157153
}
158154

159155
const pick = await RemoteProviderPicker.show(title, placeHolder, args.resource, remotes, options);
160-
161-
if (pick instanceof SetADefaultRemoteCommandQuickPickItem) {
162-
const remote = await pick.execute();
163-
if (remote != null) {
164-
void (await new CopyOrOpenRemoteCommandQuickPickItem(
165-
remote,
166-
args.resource,
167-
args.clipboard,
168-
).execute());
169-
}
170-
171-
return;
172-
}
173-
174156
void (await pick?.execute());
175157
} catch (ex) {
176158
Logger.error(ex, 'OpenOnRemoteCommand');

0 commit comments

Comments
 (0)