vscode.proposed.d.ts 90.9 KB
Newer Older
1 2 3 4 5
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

6 7 8 9 10 11
/**
 * This is the place for API experiments and proposals.
 * These API are NOT stable and subject to change. They are only available in the Insiders
 * distribution and CANNOT be used in published extensions.
 *
 * To test these API in local environment:
M
Matt Bierner 已提交
12
 * - Use Insiders release of 'VS Code'.
13 14 15
 * - Add `"enableProposedApi": true` to your package.json.
 * - Copy this file to your project.
 */
16

17 18
declare module 'vscode' {

19
	//#region auth provider: https://github.com/microsoft/vscode/issues/88309
J
Johannes Rieken 已提交
20

21
	/**
M
Matt Bierner 已提交
22
	 * An {@link Event} which fires when an {@link AuthenticationProvider} is added or removed.
23 24 25
	 */
	export interface AuthenticationProvidersChangeEvent {
		/**
M
Matt Bierner 已提交
26
		 * The ids of the {@link AuthenticationProvider}s that have been added.
27
		 */
28
		readonly added: ReadonlyArray<AuthenticationProviderInformation>;
29 30

		/**
M
Matt Bierner 已提交
31
		 * The ids of the {@link AuthenticationProvider}s that have been removed.
32
		 */
33
		readonly removed: ReadonlyArray<AuthenticationProviderInformation>;
34 35
	}

36
	export namespace authentication {
37
		/**
38
		 * @deprecated - getSession should now trigger extension activation.
39 40
		 * Fires with the provider id that was registered or unregistered.
		 */
41
		export const onDidChangeAuthenticationProviders: Event<AuthenticationProvidersChangeEvent>;
42

43
		/**
44
		 * @deprecated
45 46 47
		 * An array of the information of authentication providers that are currently registered.
		 */
		export const providers: ReadonlyArray<AuthenticationProviderInformation>;
48

49
		/**
50 51 52 53 54 55
		 * @deprecated
		 * Logout of a specific session.
		 * @param providerId The id of the provider to use
		 * @param sessionId The session id to remove
		 * provider
		 */
56
		export function logout(providerId: string, sessionId: string): Thenable<void>;
57 58
	}

J
Johannes Rieken 已提交
59 60
	//#endregion

61
	// eslint-disable-next-line vscode-dts-region-comments
A
Alex Ross 已提交
62
	//#region @alexdima - resolvers
A
Alex Dima 已提交
63

64 65 66 67 68 69 70
	export interface MessageOptions {
		/**
		 * Do not render a native message box.
		 */
		useCustom?: boolean;
	}

A
Tweaks  
Alex Dima 已提交
71 72 73 74
	export interface RemoteAuthorityResolverContext {
		resolveAttempt: number;
	}

A
Alex Dima 已提交
75 76 77
	export class ResolvedAuthority {
		readonly host: string;
		readonly port: number;
78
		readonly connectionToken: string | undefined;
A
Alex Dima 已提交
79

80
		constructor(host: string, port: number, connectionToken?: string);
A
Alex Dima 已提交
81 82
	}

83
	export interface ResolvedOptions {
R
rebornix 已提交
84
		extensionHostEnv?: { [key: string]: string | null; };
A
Alexandru Dima 已提交
85

A
Alex Dima 已提交
86
		isTrusted?: boolean;
87 88
	}

89
	export interface TunnelOptions {
R
rebornix 已提交
90
		remoteAddress: { port: number, host: string; };
A
Alex Ross 已提交
91 92 93
		// The desired local port. If this port can't be used, then another will be chosen.
		localAddressPort?: number;
		label?: string;
94
		public?: boolean;
95 96
	}

A
Alex Ross 已提交
97
	export interface TunnelDescription {
R
rebornix 已提交
98
		remoteAddress: { port: number, host: string; };
A
Alex Ross 已提交
99
		//The complete local address(ex. localhost:1234)
R
rebornix 已提交
100
		localAddress: { port: number, host: string; } | string;
101
		public?: boolean;
A
Alex Ross 已提交
102 103 104
	}

	export interface Tunnel extends TunnelDescription {
A
Alex Ross 已提交
105 106
		// Implementers of Tunnel should fire onDidDispose when dispose is called.
		onDidDispose: Event<void>;
107
		dispose(): void | Thenable<void>;
108 109 110
	}

	/**
111 112
	 * Used as part of the ResolverResult if the extension has any candidate,
	 * published, or forwarded ports.
113 114 115 116
	 */
	export interface TunnelInformation {
		/**
		 * Tunnels that are detected by the extension. The remotePort is used for display purposes.
A
Alex Ross 已提交
117
		 * The localAddress should be the complete local address (ex. localhost:1234) for connecting to the port. Tunnels provided through
118 119
		 * detected are read-only from the forwarded ports UI.
		 */
A
Alex Ross 已提交
120
		environmentTunnels?: TunnelDescription[];
A
Alex Ross 已提交
121

122 123
	}

124
	export interface TunnelCreationOptions {
125 126 127 128 129 130
		/**
		 * True when the local operating system will require elevation to use the requested local port.
		 */
		elevationRequired?: boolean;
	}

131 132 133 134 135 136
	export enum CandidatePortSource {
		None = 0,
		Process = 1,
		Output = 2
	}

137
	export type ResolverResult = ResolvedAuthority & ResolvedOptions & TunnelInformation;
138

A
Tweaks  
Alex Dima 已提交
139 140 141 142 143 144 145
	export class RemoteAuthorityResolverError extends Error {
		static NotAvailable(message?: string, handled?: boolean): RemoteAuthorityResolverError;
		static TemporarilyNotAvailable(message?: string): RemoteAuthorityResolverError;

		constructor(message?: string);
	}

A
Alex Dima 已提交
146
	export interface RemoteAuthorityResolver {
147 148 149
		/**
		 * Resolve the authority part of the current opened `vscode-remote://` URI.
		 *
M
Matt Bierner 已提交
150 151
		 * This method will be invoked once during the startup of the editor and again each time
		 * the editor detects a disconnection.
152 153 154 155
		 *
		 * @param authority The authority part of the current opened `vscode-remote://` URI.
		 * @param context A context indicating if this is the first call or a subsequent call.
		 */
156
		resolve(authority: string, context: RemoteAuthorityResolverContext): ResolverResult | Thenable<ResolverResult>;
157 158 159 160 161 162 163 164

		/**
		 * Get the canonical URI (if applicable) for a `vscode-remote://` URI.
		 *
		 * @returns The canonical URI or undefined if the uri is already canonical.
		 */
		getCanonicalURI?(uri: Uri): ProviderResult<Uri>;

165 166 167 168
		/**
		 * Can be optionally implemented if the extension can forward ports better than the core.
		 * When not implemented, the core will use its default forwarding logic.
		 * When implemented, the core will use this to forward ports.
169 170 171
		 *
		 * To enable the "Change Local Port" action on forwarded ports, make sure to set the `localAddress` of
		 * the returned `Tunnel` to a `{ port: number, host: string; }` and not a string.
172
		 */
173
		tunnelFactory?: (tunnelOptions: TunnelOptions, tunnelCreationOptions: TunnelCreationOptions) => Thenable<Tunnel> | undefined;
174

175
		/**p
176 177 178
		 * Provides filtering for candidate ports.
		 */
		showCandidatePort?: (host: string, port: number, detail: string) => Thenable<boolean>;
179 180 181 182 183 184 185

		/**
		 * Lets the resolver declare which tunnel factory features it supports.
		 * UNDER DISCUSSION! MAY CHANGE SOON.
		 */
		tunnelFeatures?: {
			elevation: boolean;
186
			public: boolean;
187
		};
188 189

		candidatePortSource?: CandidatePortSource;
190 191 192 193
	}

	export namespace workspace {
		/**
194
		 * Forwards a port. If the current resolver implements RemoteAuthorityResolver:forwardPort then that will be used to make the tunnel.
A
Alex Ross 已提交
195
		 * By default, openTunnel only support localhost; however, RemoteAuthorityResolver:tunnelFactory can be used to support other ips.
196 197 198
		 *
		 * @throws When run in an environment without a remote.
		 *
A
Alex Ross 已提交
199
		 * @param tunnelOptions The `localPort` is a suggestion only. If that port is not available another will be chosen.
200
		 */
A
Alex Ross 已提交
201
		export function openTunnel(tunnelOptions: TunnelOptions): Thenable<Tunnel>;
202 203 204 205 206 207

		/**
		 * Gets an array of the currently available tunnels. This does not include environment tunnels, only tunnels that have been created by the user.
		 * Note that these are of type TunnelDescription and cannot be disposed.
		 */
		export let tunnels: Thenable<TunnelDescription[]>;
A
Alex Ross 已提交
208

209 210 211 212
		/**
		 * Fired when the list of tunnels has changed.
		 */
		export const onDidChangeTunnels: Event<void>;
A
Alex Dima 已提交
213 214
	}

215 216 217 218 219 220 221 222
	export interface ResourceLabelFormatter {
		scheme: string;
		authority?: string;
		formatting: ResourceLabelFormatting;
	}

	export interface ResourceLabelFormatting {
		label: string; // myLabel:/${path}
I
isidor 已提交
223
		// For historic reasons we use an or string here. Once we finalize this API we should start using enums instead and adopt it in extensions.
J
Johannes Rieken 已提交
224
		// eslint-disable-next-line vscode-dts-literal-or-types
225 226 227 228
		separator: '/' | '\\' | '';
		tildify?: boolean;
		normalizeDriveLetter?: boolean;
		workspaceSuffix?: string;
229
		workspaceTooltip?: string;
230
		authorityPrefix?: string;
231
		stripPathStartingSeparator?: boolean;
232 233
	}

A
Alex Dima 已提交
234 235
	export namespace workspace {
		export function registerRemoteAuthorityResolver(authorityPrefix: string, resolver: RemoteAuthorityResolver): Disposable;
236
		export function registerResourceLabelFormatter(formatter: ResourceLabelFormatter): Disposable;
237
	}
238

239 240
	//#endregion

J
Johannes Rieken 已提交
241
	//#region editor insets: https://github.com/microsoft/vscode/issues/85682
242

243 244
	export interface WebviewEditorInset {
		readonly editor: TextEditor;
245 246
		readonly line: number;
		readonly height: number;
247 248 249
		readonly webview: Webview;
		readonly onDidDispose: Event<void>;
		dispose(): void;
250 251
	}

252
	export namespace window {
253
		export function createWebviewTextEditorInset(editor: TextEditor, line: number, height: number, options?: WebviewOptions): WebviewEditorInset;
A
Alex Dima 已提交
254 255 256 257
	}

	//#endregion

J
Johannes Rieken 已提交
258
	//#region read/write in chunks: https://github.com/microsoft/vscode/issues/84515
259 260

	export interface FileSystemProvider {
R
rebornix 已提交
261
		open?(resource: Uri, options: { create: boolean; }): number | Thenable<number>;
262 263 264 265 266 267 268
		close?(fd: number): void | Thenable<void>;
		read?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): number | Thenable<number>;
		write?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): number | Thenable<number>;
	}

	//#endregion

R
Rob Lourens 已提交
269
	//#region TextSearchProvider: https://github.com/microsoft/vscode/issues/59921
270

271 272 273
	/**
	 * The parameters of a query for text search.
	 */
274
	export interface TextSearchQuery {
275 276 277
		/**
		 * The text pattern to search for.
		 */
278
		pattern: string;
279

R
Rob Lourens 已提交
280 281 282 283 284
		/**
		 * Whether or not `pattern` should match multiple lines of text.
		 */
		isMultiline?: boolean;

285 286 287
		/**
		 * Whether or not `pattern` should be interpreted as a regular expression.
		 */
R
Rob Lourens 已提交
288
		isRegExp?: boolean;
289 290 291 292

		/**
		 * Whether or not the search should be case-sensitive.
		 */
R
Rob Lourens 已提交
293
		isCaseSensitive?: boolean;
294 295 296 297

		/**
		 * Whether or not to search for whole word matches only.
		 */
R
Rob Lourens 已提交
298
		isWordMatch?: boolean;
299 300
	}

301 302
	/**
	 * A file glob pattern to match file paths against.
303
	 * TODO@roblourens merge this with the GlobPattern docs/definition in vscode.d.ts.
M
Matt Bierner 已提交
304
	 * @see {@link GlobPattern}
305 306 307 308 309 310
	 */
	export type GlobString = string;

	/**
	 * Options common to file and text search
	 */
R
Rob Lourens 已提交
311
	export interface SearchOptions {
312 313 314
		/**
		 * The root folder to search within.
		 */
315
		folder: Uri;
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330

		/**
		 * Files that match an `includes` glob pattern should be included in the search.
		 */
		includes: GlobString[];

		/**
		 * Files that match an `excludes` glob pattern should be excluded from the search.
		 */
		excludes: GlobString[];

		/**
		 * Whether external files that exclude files, like .gitignore, should be respected.
		 * See the vscode setting `"search.useIgnoreFiles"`.
		 */
R
Rob Lourens 已提交
331
		useIgnoreFiles: boolean;
332 333 334 335 336

		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
337
		followSymlinks: boolean;
P
pkoushik 已提交
338 339 340 341 342 343

		/**
		 * Whether global files that exclude files, like .gitignore, should be respected.
		 * See the vscode setting `"search.useGlobalIgnoreFiles"`.
		 */
		useGlobalIgnoreFiles: boolean;
344
	}
345

R
Rob Lourens 已提交
346 347
	/**
	 * Options to specify the size of the result text preview.
R
Rob Lourens 已提交
348
	 * These options don't affect the size of the match itself, just the amount of preview text.
R
Rob Lourens 已提交
349
	 */
350
	export interface TextSearchPreviewOptions {
351
		/**
R
Rob Lourens 已提交
352
		 * The maximum number of lines in the preview.
R
Rob Lourens 已提交
353
		 * Only search providers that support multiline search will ever return more than one line in the match.
354
		 */
R
Rob Lourens 已提交
355
		matchLines: number;
R
Rob Lourens 已提交
356 357 358 359

		/**
		 * The maximum number of characters included per line.
		 */
R
Rob Lourens 已提交
360
		charsPerLine: number;
361 362
	}

363 364 365
	/**
	 * Options that apply to text search.
	 */
R
Rob Lourens 已提交
366
	export interface TextSearchOptions extends SearchOptions {
367
		/**
368
		 * The maximum number of results to be returned.
369
		 */
370 371
		maxResults: number;

R
Rob Lourens 已提交
372 373 374
		/**
		 * Options to specify the size of the result text preview.
		 */
375
		previewOptions?: TextSearchPreviewOptions;
376 377 378 379

		/**
		 * Exclude files larger than `maxFileSize` in bytes.
		 */
380
		maxFileSize?: number;
381 382 383 384 385

		/**
		 * Interpret files using this encoding.
		 * See the vscode setting `"files.encoding"`
		 */
386
		encoding?: string;
387 388 389 390 391 392 393 394 395 396

		/**
		 * Number of lines of context to include before each match.
		 */
		beforeContext?: number;

		/**
		 * Number of lines of context to include after each match.
		 */
		afterContext?: number;
397 398
	}

399 400 401 402 403 404 405 406
	/**
	 * Represents the severiry of a TextSearchComplete message.
	 */
	export enum TextSearchCompleteMessageType {
		Information = 1,
		Warning = 2,
	}

407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
	/**
	 * A message regarding a completed search.
	 */
	export interface TextSearchCompleteMessage {
		/**
		 * Markdown text of the message.
		 */
		text: string,
		/**
		 * Whether the source of the message is trusted, command links are disabled for untrusted message sources.
		 * Messaged are untrusted by default.
		 */
		trusted?: boolean,
		/**
		 * The message type, this affects how the message will be rendered.
		 */
		type: TextSearchCompleteMessageType,
	}

426 427 428 429 430 431
	/**
	 * Information collected when text search is complete.
	 */
	export interface TextSearchComplete {
		/**
		 * Whether the search hit the limit on the maximum number of search results.
M
Matt Bierner 已提交
432
		 * `maxResults` on {@link TextSearchOptions `TextSearchOptions`} specifies the max number of results.
433 434 435 436 437
		 * - If exactly that number of matches exist, this should be false.
		 * - If `maxResults` matches are returned and more exist, this should be true.
		 * - If search hits an internal limit which is less than `maxResults`, this should be true.
		 */
		limitHit?: boolean;
438 439 440 441

		/**
		 * Additional information regarding the state of the completed search.
		 *
M
Matt Bierner 已提交
442
		 * Messages with "Information" style support links in markdown syntax:
443 444
		 * - Click to [run a command](command:workbench.action.OpenQuickPick)
		 * - Click to [open a website](https://aka.ms)
445
		 *
M
Matt Bierner 已提交
446
		 * Commands may optionally return { triggerSearch: true } to signal to the editor that the original search should run be again.
447
		 */
448
		message?: TextSearchCompleteMessage | TextSearchCompleteMessage[];
449 450
	}

R
Rob Lourens 已提交
451 452 453
	/**
	 * A preview of the text result.
	 */
454
	export interface TextSearchMatchPreview {
455
		/**
R
Rob Lourens 已提交
456
		 * The matching lines of text, or a portion of the matching line that contains the match.
457 458 459 460 461
		 */
		text: string;

		/**
		 * The Range within `text` corresponding to the text of the match.
462
		 * The number of matches must match the TextSearchMatch's range property.
463
		 */
464
		matches: Range | Range[];
465 466 467 468 469
	}

	/**
	 * A match from a text search
	 */
470
	export interface TextSearchMatch {
471 472 473
		/**
		 * The uri for the matching document.
		 */
474
		uri: Uri;
475 476

		/**
477
		 * The range of the match within the document, or multiple ranges for multiple matches.
478
		 */
479
		ranges: Range | Range[];
R
Rob Lourens 已提交
480

481
		/**
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
		 * A preview of the text match.
		 */
		preview: TextSearchMatchPreview;
	}

	/**
	 * A line of context surrounding a TextSearchMatch.
	 */
	export interface TextSearchContext {
		/**
		 * The uri for the matching document.
		 */
		uri: Uri;

		/**
		 * One line of text.
		 * previewOptions.charsPerLine applies to this
		 */
		text: string;

		/**
		 * The line number of this line of context.
504
		 */
505
		lineNumber: number;
506 507
	}

508 509
	export type TextSearchResult = TextSearchMatch | TextSearchContext;

R
Rob Lourens 已提交
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553
	/**
	 * A TextSearchProvider provides search results for text results inside files in the workspace.
	 */
	export interface TextSearchProvider {
		/**
		 * Provide results that match the given text pattern.
		 * @param query The parameters for this query.
		 * @param options A set of options to consider while searching.
		 * @param progress A progress callback that must be invoked for all results.
		 * @param token A cancellation token.
		 */
		provideTextSearchResults(query: TextSearchQuery, options: TextSearchOptions, progress: Progress<TextSearchResult>, token: CancellationToken): ProviderResult<TextSearchComplete>;
	}

	//#endregion

	//#region FileSearchProvider: https://github.com/microsoft/vscode/issues/73524

	/**
	 * The parameters of a query for file search.
	 */
	export interface FileSearchQuery {
		/**
		 * The search pattern to match against file paths.
		 */
		pattern: string;
	}

	/**
	 * Options that apply to file search.
	 */
	export interface FileSearchOptions extends SearchOptions {
		/**
		 * The maximum number of results to be returned.
		 */
		maxResults?: number;

		/**
		 * A CancellationToken that represents the session for this search query. If the provider chooses to, this object can be used as the key for a cache,
		 * and searches with the same session object can search the same cache. When the token is cancelled, the session is complete and the cache can be cleared.
		 */
		session?: CancellationToken;
	}

554
	/**
R
Rob Lourens 已提交
555 556
	 * A FileSearchProvider provides search results for files in the given folder that match a query string. It can be invoked by quickopen or other extensions.
	 *
M
Matt Bierner 已提交
557
	 * A FileSearchProvider is the more powerful of two ways to implement file search in the editor. Use a FileSearchProvider if you wish to search within a folder for
R
Rob Lourens 已提交
558 559 560 561
	 * all files that match the user's query.
	 *
	 * The FileSearchProvider will be invoked on every keypress in quickopen. When `workspace.findFiles` is called, it will be invoked with an empty query string,
	 * and in that case, every file in the folder should be returned.
562
	 */
563
	export interface FileSearchProvider {
564 565 566 567 568 569
		/**
		 * Provide the set of files that match a certain file path pattern.
		 * @param query The parameters for this query.
		 * @param options A set of options to consider while searching files.
		 * @param token A cancellation token.
		 */
570
		provideFileSearchResults(query: FileSearchQuery, options: FileSearchOptions, token: CancellationToken): ProviderResult<Uri[]>;
571
	}
572

R
Rob Lourens 已提交
573
	export namespace workspace {
574
		/**
R
Rob Lourens 已提交
575 576 577 578 579 580
		 * Register a search provider.
		 *
		 * Only one provider can be registered per scheme.
		 *
		 * @param scheme The provider will be invoked for workspace folders that have this file scheme.
		 * @param provider The provider.
M
Matt Bierner 已提交
581
		 * @return A {@link Disposable} that unregisters this provider when being disposed.
582
		 */
R
Rob Lourens 已提交
583 584 585 586 587 588 589 590 591
		export function registerFileSearchProvider(scheme: string, provider: FileSearchProvider): Disposable;

		/**
		 * Register a text search provider.
		 *
		 * Only one provider can be registered per scheme.
		 *
		 * @param scheme The provider will be invoked for workspace folders that have this file scheme.
		 * @param provider The provider.
M
Matt Bierner 已提交
592
		 * @return A {@link Disposable} that unregisters this provider when being disposed.
R
Rob Lourens 已提交
593 594
		 */
		export function registerTextSearchProvider(scheme: string, provider: TextSearchProvider): Disposable;
595 596
	}

R
Rob Lourens 已提交
597 598 599 600
	//#endregion

	//#region findTextInFiles: https://github.com/microsoft/vscode/issues/59924

601 602 603
	/**
	 * Options that can be set on a findTextInFiles search.
	 */
R
Rob Lourens 已提交
604
	export interface FindTextInFilesOptions {
605
		/**
M
Matt Bierner 已提交
606 607 608
		 * A {@link GlobPattern glob pattern} that defines the files to search for. The glob pattern
		 * will be matched against the file paths of files relative to their workspace. Use a {@link RelativePattern relative pattern}
		 * to restrict the search results to a {@link WorkspaceFolder workspace folder}.
609
		 */
610
		include?: GlobPattern;
611 612

		/**
M
Matt Bierner 已提交
613
		 * A {@link GlobPattern glob pattern} that defines files and folders to exclude. The glob pattern
614 615
		 * will be matched against the file paths of resulting matches relative to their workspace. When `undefined`, default excludes will
		 * apply.
616
		 */
617 618 619 620
		exclude?: GlobPattern;

		/**
		 * Whether to use the default and user-configured excludes. Defaults to true.
621
		 */
622
		useDefaultExcludes?: boolean;
623 624 625 626

		/**
		 * The maximum number of results to search for
		 */
R
Rob Lourens 已提交
627
		maxResults?: number;
628 629 630 631 632

		/**
		 * Whether external files that exclude files, like .gitignore, should be respected.
		 * See the vscode setting `"search.useIgnoreFiles"`.
		 */
R
Rob Lourens 已提交
633
		useIgnoreFiles?: boolean;
634

P
pkoushik 已提交
635 636 637 638
		/**
		 * Whether global files that exclude files, like .gitignore, should be respected.
		 * See the vscode setting `"search.useGlobalIgnoreFiles"`.
		 */
639
		useGlobalIgnoreFiles?: boolean;
P
pkoushik 已提交
640

641 642 643 644
		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
645
		followSymlinks?: boolean;
646 647 648 649 650

		/**
		 * Interpret files using this encoding.
		 * See the vscode setting `"files.encoding"`
		 */
R
Rob Lourens 已提交
651
		encoding?: string;
652

R
Rob Lourens 已提交
653 654 655
		/**
		 * Options to specify the size of the result text preview.
		 */
656
		previewOptions?: TextSearchPreviewOptions;
657 658 659 660 661 662 663 664 665 666

		/**
		 * Number of lines of context to include before each match.
		 */
		beforeContext?: number;

		/**
		 * Number of lines of context to include after each match.
		 */
		afterContext?: number;
R
Rob Lourens 已提交
667 668
	}

669
	export namespace workspace {
670
		/**
M
Matt Bierner 已提交
671
		 * Search text in files across all {@link workspace.workspaceFolders workspace folders} in the workspace.
672 673 674 675 676
		 * @param query The query parameters for the search - the search string, whether it's case-sensitive, or a regex, or matches whole words.
		 * @param callback A callback, called for each result
		 * @param token A token that can be used to signal cancellation to the underlying search engine.
		 * @return A thenable that resolves when the search is complete.
		 */
677
		export function findTextInFiles(query: TextSearchQuery, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
678 679

		/**
M
Matt Bierner 已提交
680
		 * Search text in files across all {@link workspace.workspaceFolders workspace folders} in the workspace.
681 682 683 684 685 686
		 * @param query The query parameters for the search - the search string, whether it's case-sensitive, or a regex, or matches whole words.
		 * @param options An optional set of query options. Include and exclude patterns, maxResults, etc.
		 * @param callback A callback, called for each result
		 * @param token A token that can be used to signal cancellation to the underlying search engine.
		 * @return A thenable that resolves when the search is complete.
		 */
687
		export function findTextInFiles(query: TextSearchQuery, options: FindTextInFilesOptions, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
688 689
	}

J
Johannes Rieken 已提交
690
	//#endregion
691

J
Johannes Rieken 已提交
692
	//#region diff command: https://github.com/microsoft/vscode/issues/84899
P
Pine Wu 已提交
693

J
Joao Moreno 已提交
694 695 696
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
697 698 699 700 701 702 703
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

704 705 706 707 708 709
	export namespace commands {

		/**
		 * Registers a diff information command that can be invoked via a keyboard shortcut,
		 * a menu item, an action, or directly.
		 *
M
Matt Bierner 已提交
710
		 * Diff information commands are different from ordinary {@link commands.registerCommand commands} as
711 712 713 714 715
		 * they only execute when there is an active diff editor when the command is called, and the diff
		 * information has been computed. Also, the command handler of an editor command has access to
		 * the diff information.
		 *
		 * @param command A unique identifier for the command.
M
Matt Bierner 已提交
716
		 * @param callback A command handler function with access to the {@link LineChange diff information}.
717 718 719 720 721
		 * @param thisArg The `this` context used when invoking the handler function.
		 * @return Disposable which unregisters this command on disposal.
		 */
		export function registerDiffInformationCommand(command: string, callback: (diff: LineChange[], ...args: any[]) => any, thisArg?: any): Disposable;
	}
722

J
Johannes Rieken 已提交
723 724
	//#endregion

725
	// eslint-disable-next-line vscode-dts-region-comments
726
	//#region @weinand: variables view action contributions
727

728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743
	/**
	 * A DebugProtocolVariableContainer is an opaque stand-in type for the intersection of the Scope and Variable types defined in the Debug Adapter Protocol.
	 * See https://microsoft.github.io/debug-adapter-protocol/specification#Types_Scope and https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable.
	 */
	export interface DebugProtocolVariableContainer {
		// Properties: the intersection of DAP's Scope and Variable types.
	}

	/**
	 * A DebugProtocolVariable is an opaque stand-in type for the Variable type defined in the Debug Adapter Protocol.
	 * See https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable.
	 */
	export interface DebugProtocolVariable {
		// Properties: see details [here](https://microsoft.github.io/debug-adapter-protocol/specification#Base_Protocol_Variable).
	}

J
Johannes Rieken 已提交
744 745
	//#endregion

746
	// eslint-disable-next-line vscode-dts-region-comments
747
	//#region @joaomoreno: SCM validation
748

J
Joao Moreno 已提交
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787
	/**
	 * Represents the validation type of the Source Control input.
	 */
	export enum SourceControlInputBoxValidationType {

		/**
		 * Something not allowed by the rules of a language or other means.
		 */
		Error = 0,

		/**
		 * Something suspicious but allowed.
		 */
		Warning = 1,

		/**
		 * Something to inform about but not a problem.
		 */
		Information = 2
	}

	export interface SourceControlInputBoxValidation {

		/**
		 * The validation message to display.
		 */
		readonly message: string;

		/**
		 * The validation type.
		 */
		readonly type: SourceControlInputBoxValidationType;
	}

	/**
	 * Represents the input box in the Source Control viewlet.
	 */
	export interface SourceControlInputBox {

788 789 790 791 792
		/**
		 * Shows a transient contextual message on the input.
		 */
		showValidationMessage(message: string, type: SourceControlInputBoxValidationType): void;

J
Joao Moreno 已提交
793 794 795 796
		/**
		 * A validation function for the input box. It's possible to change
		 * the validation provider simply by setting this property to a different function.
		 */
797
		validateInput?(value: string, cursorPosition: number): ProviderResult<SourceControlInputBoxValidation>;
J
Joao Moreno 已提交
798
	}
M
Matt Bierner 已提交
799

J
Johannes Rieken 已提交
800 801
	//#endregion

802
	// eslint-disable-next-line vscode-dts-region-comments
803
	//#region @joaomoreno: SCM selected provider
804 805 806 807 808 809 810 811 812 813 814 815

	export interface SourceControl {

		/**
		 * Whether the source control is selected.
		 */
		readonly selected: boolean;

		/**
		 * An event signaling when the selection state changes.
		 */
		readonly onDidChangeSelection: Event<boolean>;
816 817 818 819
	}

	//#endregion

D
Daniel Imms 已提交
820
	//#region Terminal data write event https://github.com/microsoft/vscode/issues/78502
821

822 823
	export interface TerminalDataWriteEvent {
		/**
M
Matt Bierner 已提交
824
		 * The {@link Terminal} for which the data was written.
825 826 827 828 829 830 831 832
		 */
		readonly terminal: Terminal;
		/**
		 * The data being written.
		 */
		readonly data: string;
	}

D
Daniel Imms 已提交
833 834
	namespace window {
		/**
D
Daniel Imms 已提交
835 836 837
		 * An event which fires when the terminal's child pseudo-device is written to (the shell).
		 * In other words, this provides access to the raw data stream from the process running
		 * within the terminal, including VT sequences.
D
Daniel Imms 已提交
838 839 840 841 842 843 844 845 846
		 */
		export const onDidWriteTerminalData: Event<TerminalDataWriteEvent>;
	}

	//#endregion

	//#region Terminal dimensions property and change event https://github.com/microsoft/vscode/issues/55718

	/**
M
Matt Bierner 已提交
847
	 * An {@link Event} which fires when a {@link Terminal}'s dimensions change.
D
Daniel Imms 已提交
848 849 850
	 */
	export interface TerminalDimensionsChangeEvent {
		/**
M
Matt Bierner 已提交
851
		 * The {@link Terminal} for which the dimensions have changed.
D
Daniel Imms 已提交
852 853 854
		 */
		readonly terminal: Terminal;
		/**
M
Matt Bierner 已提交
855
		 * The new value for the {@link Terminal.dimensions terminal's dimensions}.
D
Daniel Imms 已提交
856 857 858
		 */
		readonly dimensions: TerminalDimensions;
	}
859

D
Daniel Imms 已提交
860
	export namespace window {
D
Daniel Imms 已提交
861
		/**
M
Matt Bierner 已提交
862
		 * An event which fires when the {@link Terminal.dimensions dimensions} of the terminal change.
D
Daniel Imms 已提交
863 864 865 866 867
		 */
		export const onDidChangeTerminalDimensions: Event<TerminalDimensionsChangeEvent>;
	}

	export interface Terminal {
868
		/**
869 870 871
		 * The current dimensions of the terminal. This will be `undefined` immediately after the
		 * terminal is created as the dimensions are not known until shortly after the terminal is
		 * created.
872
		 */
873
		readonly dimensions: TerminalDimensions | undefined;
D
Daniel Imms 已提交
874 875
	}

876 877
	//#endregion

878
	//#region Terminal name change event https://github.com/microsoft/vscode/issues/114898
D
Daniel Imms 已提交
879

880
	export interface Pseudoterminal {
D
Daniel Imms 已提交
881
		/**
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897
		 * An event that when fired allows changing the name of the terminal.
		 *
		 * **Example:** Change the terminal name to "My new terminal".
		 * ```typescript
		 * const writeEmitter = new vscode.EventEmitter<string>();
		 * const changeNameEmitter = new vscode.EventEmitter<string>();
		 * const pty: vscode.Pseudoterminal = {
		 *   onDidWrite: writeEmitter.event,
		 *   onDidChangeName: changeNameEmitter.event,
		 *   open: () => changeNameEmitter.fire('My new terminal'),
		 *   close: () => {}
		 * };
		 * vscode.window.createTerminal({ name: 'My terminal', pty });
		 * ```
		 */
		onDidChangeName?: Event<string>;
898 899 900 901
	}

	//#endregion

902
	// eslint-disable-next-line vscode-dts-region-comments
903
	//#region @jrieken -> exclusive document filters
904 905

	export interface DocumentFilter {
906
		readonly exclusive?: boolean;
907 908 909
	}

	//#endregion
C
Christof Marti 已提交
910

911
	//#region Tree View: https://github.com/microsoft/vscode/issues/61313 @alexr00
912
	export interface TreeView<T> extends Disposable {
913
		reveal(element: T | undefined, options?: { select?: boolean, focus?: boolean, expand?: boolean | number; }): Thenable<void>;
914
	}
915
	//#endregion
916

917 918
	//#region Custom Tree View Drag and Drop https://github.com/microsoft/vscode/issues/32592
	export interface TreeViewOptions<T> {
919
		dragAndDropController?: DragAndDropController<T>;
920 921
	}

922
	export interface DragAndDropController<T> extends Disposable {
923
		/**
924
		 * Extensions should fire `TreeDataProvider.onDidChangeTreeData` for any elements that need to be refreshed.
925
		 *
926 927
		 * @param source
		 * @param target
928
		 */
929
		onDrop(source: T[], target: T): Thenable<void>;
930 931 932
	}
	//#endregion

933
	//#region Task presentation group: https://github.com/microsoft/vscode/issues/47265
934 935 936 937 938 939 940
	export interface TaskPresentationOptions {
		/**
		 * Controls whether the task is executed in a specific terminal group using split panes.
		 */
		group?: string;
	}
	//#endregion
941

942
	//#region Custom editor move https://github.com/microsoft/vscode/issues/86146
943

944
	// TODO: Also for custom editor
945

946
	export interface CustomTextEditorProvider {
M
Matt Bierner 已提交
947

948 949 950 951
		/**
		 * Handle when the underlying resource for a custom editor is renamed.
		 *
		 * This allows the webview for the editor be preserved throughout the rename. If this method is not implemented,
M
Matt Bierner 已提交
952
		 * the editor will destroy the previous custom editor and create a replacement one.
953 954 955
		 *
		 * @param newDocument New text document to use for the custom editor.
		 * @param existingWebviewPanel Webview panel for the custom editor.
956
		 * @param token A cancellation token that indicates the result is no longer needed.
957 958 959
		 *
		 * @return Thenable indicating that the webview editor has been moved.
		 */
J
Johannes Rieken 已提交
960
		// eslint-disable-next-line vscode-dts-provider-naming
961
		moveCustomTextEditor?(newDocument: TextDocument, existingWebviewPanel: WebviewPanel, token: CancellationToken): Thenable<void>;
962 963 964
	}

	//#endregion
965

J
Johannes Rieken 已提交
966
	//#region allow QuickPicks to skip sorting: https://github.com/microsoft/vscode/issues/73904
P
Peter Elmers 已提交
967 968 969

	export interface QuickPick<T extends QuickPickItem> extends QuickInput {
		/**
970 971
		 * An optional flag to sort the final results by index of first query match in label. Defaults to true.
		 */
P
Peter Elmers 已提交
972 973 974 975
		sortByLabel: boolean;
	}

	//#endregion
M
Matt Bierner 已提交
976

977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011
	//#region https://github.com/microsoft/vscode/issues/124970, Cell Execution State

	/**
	 * The execution state of a notebook cell.
	 */
	export enum NotebookCellExecutionState {
		/**
		 * The cell is idle.
		 */
		Idle = 1,
		/**
		 * Execution for the cell is pending.
		 */
		Pending = 2,
		/**
		 * The cell is currently executing.
		 */
		Executing = 3,
	}

	/**
	 * An event describing a cell execution state change.
	 */
	export interface NotebookCellExecutionStateChangeEvent {
		/**
		 * The {@link NotebookCell cell} for which the execution state has changed.
		 */
		readonly cell: NotebookCell;

		/**
		 * The new execution state of the cell.
		 */
		readonly state: NotebookCellExecutionState;
	}

1012
	export namespace notebooks {
1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023

		/**
		 * An {@link Event} which fires when the execution state of a cell has changed.
		 */
		// todo@API this is an event that is fired for a property that cells don't have and that makes me wonder
		// how a correct consumer works, e.g the consumer could have been late and missed an event?
		export const onDidChangeNotebookCellExecutionState: Event<NotebookCellExecutionStateChangeEvent>;
	}

	//#endregion

1024
	//#region https://github.com/microsoft/vscode/issues/106744, Notebook, deprecated & misc
1025

1026 1027 1028
	export interface NotebookCellOutput {
		id: string;
	}
1029 1030 1031

	//#endregion

1032 1033
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookEditor

J
Johannes Rieken 已提交
1034 1035 1036
	/**
	 * Represents a notebook editor that is attached to a {@link NotebookDocument notebook}.
	 */
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059
	export enum NotebookEditorRevealType {
		/**
		 * The range will be revealed with as little scrolling as possible.
		 */
		Default = 0,

		/**
		 * The range will always be revealed in the center of the viewport.
		 */
		InCenter = 1,

		/**
		 * If the range is outside the viewport, it will be revealed in the center of the viewport.
		 * Otherwise, it will be revealed with as little scrolling as possible.
		 */
		InCenterIfOutsideViewport = 2,

		/**
		 * The range will always be revealed at the top of the viewport.
		 */
		AtTop = 3
	}

J
Johannes Rieken 已提交
1060 1061 1062
	/**
	 * Represents a notebook editor that is attached to a {@link NotebookDocument notebook}.
	 */
1063 1064 1065 1066
	export interface NotebookEditor {
		/**
		 * The document associated with this notebook editor.
		 */
J
Johannes Rieken 已提交
1067
		//todo@api rename to notebook?
1068 1069 1070 1071 1072 1073 1074
		readonly document: NotebookDocument;

		/**
		 * The selections on this notebook editor.
		 *
		 * The primary selection (or focused range) is `selections[0]`. When the document has no cells, the primary selection is empty `{ start: 0, end: 0 }`;
		 */
1075
		selections: NotebookRange[];
1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093

		/**
		 * The current visible ranges in the editor (vertically).
		 */
		readonly visibleRanges: NotebookRange[];

		/**
		 * Scroll as indicated by `revealType` in order to reveal the given range.
		 *
		 * @param range A range.
		 * @param revealType The scrolling strategy for revealing `range`.
		 */
		revealRange(range: NotebookRange, revealType?: NotebookEditorRevealType): void;

		/**
		 * The column in which this editor shows.
		 */
		readonly viewColumn?: ViewColumn;
R
rebornix 已提交
1094 1095
	}

1096
	export interface NotebookDocumentMetadataChangeEvent {
R
rebornix 已提交
1097
		/**
M
Matt Bierner 已提交
1098
		 * The {@link NotebookDocument notebook document} for which the document metadata have changed.
R
rebornix 已提交
1099
		 */
J
Johannes Rieken 已提交
1100
		//todo@API rename to notebook?
1101 1102 1103
		readonly document: NotebookDocument;
	}

1104
	export interface NotebookCellsChangeData {
R
rebornix 已提交
1105
		readonly start: number;
J
Johannes Rieken 已提交
1106
		// todo@API end? Use NotebookCellRange instead?
R
rebornix 已提交
1107
		readonly deletedCount: number;
J
Johannes Rieken 已提交
1108
		// todo@API removedCells, deletedCells?
1109
		readonly deletedItems: NotebookCell[];
J
Johannes Rieken 已提交
1110
		// todo@API addedCells, insertedCells, newCells?
R
rebornix 已提交
1111
		readonly items: NotebookCell[];
R
rebornix 已提交
1112 1113
	}

R
rebornix 已提交
1114
	export interface NotebookCellsChangeEvent {
1115
		/**
M
Matt Bierner 已提交
1116
		 * The {@link NotebookDocument notebook document} for which the cells have changed.
1117
		 */
J
Johannes Rieken 已提交
1118
		//todo@API rename to notebook?
R
rebornix 已提交
1119
		readonly document: NotebookDocument;
1120
		readonly changes: ReadonlyArray<NotebookCellsChangeData>;
R
rebornix 已提交
1121 1122
	}

1123
	export interface NotebookCellOutputsChangeEvent {
1124
		/**
M
Matt Bierner 已提交
1125
		 * The {@link NotebookDocument notebook document} for which the cell outputs have changed.
1126
		 */
J
Johannes Rieken 已提交
1127
		//todo@API remove? use cell.notebook instead?
R
rebornix 已提交
1128
		readonly document: NotebookDocument;
J
Johannes Rieken 已提交
1129
		// NotebookCellOutputsChangeEvent.cells vs NotebookCellMetadataChangeEvent.cell
1130
		readonly cells: NotebookCell[];
R
rebornix 已提交
1131
	}
1132

1133
	export interface NotebookCellMetadataChangeEvent {
1134
		/**
M
Matt Bierner 已提交
1135
		 * The {@link NotebookDocument notebook document} for which the cell metadata have changed.
1136
		 */
J
Johannes Rieken 已提交
1137
		//todo@API remove? use cell.notebook instead?
R
rebornix 已提交
1138
		readonly document: NotebookDocument;
J
Johannes Rieken 已提交
1139
		// NotebookCellOutputsChangeEvent.cells vs NotebookCellMetadataChangeEvent.cell
R
rebornix 已提交
1140
		readonly cell: NotebookCell;
R
rebornix 已提交
1141 1142
	}

1143
	export interface NotebookEditorSelectionChangeEvent {
R
rebornix 已提交
1144
		/**
M
Matt Bierner 已提交
1145
		 * The {@link NotebookEditor notebook editor} for which the selections have changed.
R
rebornix 已提交
1146
		 */
1147
		readonly notebookEditor: NotebookEditor;
1148
		readonly selections: ReadonlyArray<NotebookRange>
R
rebornix 已提交
1149 1150
	}

1151
	export interface NotebookEditorVisibleRangesChangeEvent {
R
rebornix 已提交
1152
		/**
M
Matt Bierner 已提交
1153
		 * The {@link NotebookEditor notebook editor} for which the visible ranges have changed.
R
rebornix 已提交
1154
		 */
1155
		readonly notebookEditor: NotebookEditor;
1156
		readonly visibleRanges: ReadonlyArray<NotebookRange>;
R
rebornix 已提交
1157 1158
	}

R
rebornix 已提交
1159

1160 1161 1162 1163
	export interface NotebookDocumentShowOptions {
		viewColumn?: ViewColumn;
		preserveFocus?: boolean;
		preview?: boolean;
1164
		selections?: NotebookRange[];
R
rebornix 已提交
1165 1166
	}

1167
	export namespace notebooks {
1168

1169

1170 1171

		export const onDidSaveNotebookDocument: Event<NotebookDocument>;
R
rebornix 已提交
1172

1173 1174
		export const onDidChangeNotebookDocumentMetadata: Event<NotebookDocumentMetadataChangeEvent>;
		export const onDidChangeNotebookCells: Event<NotebookCellsChangeEvent>;
J
Johannes Rieken 已提交
1175 1176

		// todo@API add onDidChangeNotebookCellOutputs
1177
		export const onDidChangeCellOutputs: Event<NotebookCellOutputsChangeEvent>;
R
rebornix 已提交
1178

J
Johannes Rieken 已提交
1179
		// todo@API add onDidChangeNotebookCellMetadata
1180
		export const onDidChangeCellMetadata: Event<NotebookCellMetadataChangeEvent>;
R
rebornix 已提交
1181 1182
	}

1183 1184 1185 1186 1187 1188 1189
	export namespace window {
		export const visibleNotebookEditors: NotebookEditor[];
		export const onDidChangeVisibleNotebookEditors: Event<NotebookEditor[]>;
		export const activeNotebookEditor: NotebookEditor | undefined;
		export const onDidChangeActiveNotebookEditor: Event<NotebookEditor | undefined>;
		export const onDidChangeNotebookEditorSelection: Event<NotebookEditorSelectionChangeEvent>;
		export const onDidChangeNotebookEditorVisibleRanges: Event<NotebookEditorVisibleRangesChangeEvent>;
1190

1191 1192 1193
		export function showNotebookDocument(uri: Uri, options?: NotebookDocumentShowOptions): Thenable<NotebookEditor>;
		export function showNotebookDocument(document: NotebookDocument, options?: NotebookDocumentShowOptions): Thenable<NotebookEditor>;
	}
1194

1195
	//#endregion
1196

1197
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookEditorEdit
1198

1199 1200 1201 1202 1203 1204 1205
	// todo@API add NotebookEdit-type which handles all these cases?
	// export class NotebookEdit {
	// 	range: NotebookRange;
	// 	newCells: NotebookCellData[];
	// 	newMetadata?: NotebookDocumentMetadata;
	// 	constructor(range: NotebookRange, newCells: NotebookCellData)
	// }
J
Johannes Rieken 已提交
1206

1207 1208 1209
	// export class NotebookCellEdit {
	// 	newMetadata?: NotebookCellMetadata;
	// }
J
Johannes Rieken 已提交
1210

1211 1212 1213
	// export interface WorkspaceEdit {
	// 	set(uri: Uri, edits: TextEdit[] | NotebookEdit[]): void
	// }
1214

1215 1216
	export interface WorkspaceEdit {
		// todo@API add NotebookEdit-type which handles all these cases?
1217
		replaceNotebookMetadata(uri: Uri, value: { [key: string]: any }): void;
1218
		replaceNotebookCells(uri: Uri, range: NotebookRange, cells: NotebookCellData[], metadata?: WorkspaceEditEntryMetadata): void;
1219
		replaceNotebookCellMetadata(uri: Uri, index: number, cellMetadata: { [key: string]: any }, metadata?: WorkspaceEditEntryMetadata): void;
1220
	}
1221

1222
	export interface NotebookEditorEdit {
1223
		replaceMetadata(value: { [key: string]: any }): void;
1224
		replaceCells(start: number, end: number, cells: NotebookCellData[]): void;
1225
		replaceCellMetadata(index: number, metadata: { [key: string]: any }): void;
1226
	}
1227

1228
	export interface NotebookEditor {
1229
		/**
1230
		 * Perform an edit on the notebook associated with this notebook editor.
1231
		 *
1232 1233 1234
		 * The given callback-function is invoked with an {@link NotebookEditorEdit edit-builder} which must
		 * be used to make edits. Note that the edit-builder is only valid while the
		 * callback executes.
1235
		 *
1236 1237
		 * @param callback A function which can create edits using an {@link NotebookEditorEdit edit-builder}.
		 * @return A promise that resolves with a value indicating if the edits could be applied.
1238
		 */
1239 1240
		// @jrieken REMOVE maybe
		edit(callback: (editBuilder: NotebookEditorEdit) => void): Thenable<boolean>;
1241 1242
	}

1243 1244
	//#endregion

J
Johannes Rieken 已提交
1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookEditorDecorationType

	export interface NotebookEditor {
		setDecorations(decorationType: NotebookEditorDecorationType, range: NotebookRange): void;
	}

	export interface NotebookDecorationRenderOptions {
		backgroundColor?: string | ThemeColor;
		borderColor?: string | ThemeColor;
		top: ThemableDecorationAttachmentRenderOptions;
	}

	export interface NotebookEditorDecorationType {
		readonly key: string;
		dispose(): void;
	}

1262
	export namespace notebooks {
J
Johannes Rieken 已提交
1263 1264 1265 1266 1267 1268 1269
		export function createNotebookEditorDecorationType(options: NotebookDecorationRenderOptions): NotebookEditorDecorationType;
	}

	//#endregion

	//#region https://github.com/microsoft/vscode/issues/106744, NotebookConcatTextDocument

1270
	export namespace notebooks {
J
Johannes Rieken 已提交
1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302
		/**
		 * Create a document that is the concatenation of all  notebook cells. By default all code-cells are included
		 * but a selector can be provided to narrow to down the set of cells.
		 *
		 * @param notebook
		 * @param selector
		 */
		// todo@API really needed? we didn't find a user here
		export function createConcatTextDocument(notebook: NotebookDocument, selector?: DocumentSelector): NotebookConcatTextDocument;
	}

	export interface NotebookConcatTextDocument {
		readonly uri: Uri;
		readonly isClosed: boolean;
		dispose(): void;
		readonly onDidChange: Event<void>;
		readonly version: number;
		getText(): string;
		getText(range: Range): string;

		offsetAt(position: Position): number;
		positionAt(offset: number): Position;
		validateRange(range: Range): Range;
		validatePosition(position: Position): Position;

		locationAt(positionOrRange: Position | Range): Location;
		positionAt(location: Location): Position;
		contains(uri: Uri): boolean;
	}

	//#endregion

1303 1304
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookContentProvider

1305

1306 1307 1308 1309
	interface NotebookDocumentBackup {
		/**
		 * Unique identifier for the backup.
		 *
R
Rob Lourens 已提交
1310
		 * This id is passed back to your extension in `openNotebook` when opening a notebook editor from a backup.
1311 1312 1313 1314 1315 1316
		 */
		readonly id: string;

		/**
		 * Delete the current backup.
		 *
M
Matt Bierner 已提交
1317
		 * This is called by the editor when it is clear the current backup is no longer needed, such as when a new backup
1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328
		 * is made or when the file is saved.
		 */
		delete(): void;
	}

	interface NotebookDocumentBackupContext {
		readonly destination: Uri;
	}

	interface NotebookDocumentOpenContext {
		readonly backupId?: string;
1329
		readonly untitledDocumentData?: Uint8Array;
1330 1331
	}

1332
	// todo@API use openNotebookDOCUMENT to align with openCustomDocument etc?
J
Johannes Rieken 已提交
1333
	// todo@API rename to NotebookDocumentContentProvider
R
rebornix 已提交
1334
	export interface NotebookContentProvider {
1335

1336 1337 1338
		readonly options?: NotebookDocumentContentOptions;
		readonly onDidChangeNotebookContentOptions?: Event<NotebookDocumentContentOptions>;

1339
		/**
M
Matt Bierner 已提交
1340
		 * Content providers should always use {@link FileSystemProvider file system providers} to
1341 1342
		 * resolve the raw content for `uri` as the resouce is not necessarily a file on disk.
		 */
1343 1344
		openNotebook(uri: Uri, openContext: NotebookDocumentOpenContext, token: CancellationToken): NotebookData | Thenable<NotebookData>;

J
Johannes Rieken 已提交
1345
		// todo@API use NotebookData instead
1346 1347
		saveNotebook(document: NotebookDocument, token: CancellationToken): Thenable<void>;

J
Johannes Rieken 已提交
1348
		// todo@API use NotebookData instead
1349
		saveNotebookAs(targetResource: Uri, document: NotebookDocument, token: CancellationToken): Thenable<void>;
J
Johannes Rieken 已提交
1350

J
Johannes Rieken 已提交
1351
		// todo@API use NotebookData instead
1352
		backupNotebook(document: NotebookDocument, context: NotebookDocumentBackupContext, token: CancellationToken): Thenable<NotebookDocumentBackup>;
R
rebornix 已提交
1353 1354
	}

1355
	export namespace workspace {
J
Johannes Rieken 已提交
1356

1357 1358
		// TODO@api use NotebookDocumentFilter instead of just notebookType:string?
		// TODO@API options duplicates the more powerful variant on NotebookContentProvider
1359
		export function registerNotebookContentProvider(notebookType: string, provider: NotebookContentProvider, options?: NotebookDocumentContentOptions): Disposable;
R
rebornix 已提交
1360 1361
	}

1362 1363
	//#endregion

J
Johannes Rieken 已提交
1364
	//#region https://github.com/microsoft/vscode/issues/106744, LiveShare
1365

J
Johannes Rieken 已提交
1366 1367 1368 1369
	export interface NotebookRegistrationData {
		displayName: string;
		filenamePattern: (GlobPattern | { include: GlobPattern; exclude: GlobPattern; })[];
		exclusive?: boolean;
1370 1371
	}

1372
	export namespace workspace {
J
Johannes Rieken 已提交
1373 1374 1375 1376
		// SPECIAL overload with NotebookRegistrationData
		export function registerNotebookContentProvider(notebookType: string, provider: NotebookContentProvider, options?: NotebookDocumentContentOptions, registrationData?: NotebookRegistrationData): Disposable;
		// SPECIAL overload with NotebookRegistrationData
		export function registerNotebookSerializer(notebookType: string, serializer: NotebookSerializer, options?: NotebookDocumentContentOptions, registration?: NotebookRegistrationData): Disposable;
1377 1378
	}

1379 1380 1381 1382
	//#endregion

	//#region https://github.com/microsoft/vscode/issues/39441

P
label2  
Pine Wu 已提交
1383 1384 1385 1386
	export interface CompletionItem {
		/**
		 * Will be merged into CompletionItem#label
		 */
P
Pine Wu 已提交
1387
		label2?: CompletionItemLabel;
P
label2  
Pine Wu 已提交
1388 1389
	}

1390 1391
	export interface CompletionItemLabel {
		/**
1392 1393 1394
		 * The name of this completion item. By default
		 * this is also the text that is inserted when selecting
		 * this completion.
1395
		 */
P
Pine Wu 已提交
1396
		name: string;
1397

P
Pine Wu 已提交
1398
		/**
1399 1400
		 * The signature of this completion item. Will be rendered right after the
		 * {@link CompletionItemLabel.name name}.
P
Pine Wu 已提交
1401
		 */
1402
		signature?: string;
P
Pine Wu 已提交
1403 1404

		/**
P
Pine Wu 已提交
1405
		 * The fully qualified name, like package name or file path. Rendered after `signature`.
P
Pine Wu 已提交
1406
		 */
J
Johannes Rieken 已提交
1407
		//todo@API find better name
P
Pine Wu 已提交
1408
		qualifier?: string;
1409

P
Pine Wu 已提交
1410
		/**
P
Pine Wu 已提交
1411
		 * The return-type of a function or type of a property/variable. Rendered rightmost.
P
Pine Wu 已提交
1412
		 */
P
Pine Wu 已提交
1413
		type?: string;
1414 1415 1416 1417
	}

	//#endregion

1418
	//#region @https://github.com/microsoft/vscode/issues/123601, notebook messaging
1419

1420
	export interface NotebookRendererMessage<T> {
1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431
		/**
		 * Editor that sent the message.
		 */
		editor: NotebookEditor;

		/**
		 * Message sent from the webview.
		 */
		message: T;
	}

1432 1433
	/**
	 * Renderer messaging is used to communicate with a single renderer. It's
C
Connor Peet 已提交
1434
	 * returned from {@link notebooks.createRendererMessaging}.
1435
	 */
1436
	export interface NotebookRendererMessaging<TSend = any, TReceive = TSend> {
1437 1438 1439
		/**
		 * Events that fires when a message is received from a renderer.
		 */
1440
		onDidReceiveMessage: Event<NotebookRendererMessage<TReceive>>;
1441 1442 1443

		/**
		 * Sends a message to the renderer.
1444
		 * @param editor Editor to target with the message
1445 1446
		 * @param message Message to send
		 */
1447
		postMessage(editor: NotebookEditor, message: TSend): void;
1448 1449
	}

1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474
	/**
	 * Represents a script that is loaded into the notebook renderer before rendering output. This allows
	 * to provide and share functionality for notebook markup and notebook output renderers.
	 */
	export class NotebookRendererScript {

		/**
		 * APIs that the preload provides to the renderer. These are matched
		 * against the `dependencies` and `optionalDependencies` arrays in the
		 * notebook renderer contribution point.
		 */
		provides: string[];

		/**
		 * URI for the file to preload
		 */
		uri: Uri;

		/**
		 * @param uri URI for the file to preload
		 * @param provides Value for the `provides` property
		 */
		constructor(uri: Uri, provides?: string | string[]);
	}

1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501
	export interface NotebookController {

		// todo@API allow add, not remove
		readonly rendererScripts: NotebookRendererScript[];

		/**
		 * An event that fires when a {@link NotebookController.rendererScripts renderer script} has send a message to
		 * the controller.
		 */
		readonly onDidReceiveMessage: Event<{ editor: NotebookEditor, message: any }>;

		/**
		 * Send a message to the renderer of notebook editors.
		 *
		 * Note that only editors showing documents that are bound to this controller
		 * are receiving the message.
		 *
		 * @param message The message to send.
		 * @param editor A specific editor to send the message to. When `undefined` all applicable editors are receiving the message.
		 * @returns A promise that resolves to a boolean indicating if the message has been send or not.
		 */
		postMessage(message: any, editor?: NotebookEditor): Thenable<boolean>;

		//todo@API validate this works
		asWebviewUri(localResource: Uri): Uri;
	}

1502
	export namespace notebooks {
1503

1504
		export function createNotebookController(id: string, viewType: string, label: string, handler?: (cells: NotebookCell[], notebook: NotebookDocument, controller: NotebookController) => void | Thenable<void>, rendererScripts?: NotebookRendererScript[]): NotebookController;
1505

1506 1507 1508
		/**
		 * Creates a new messaging instance used to communicate with a specific
		 * renderer. The renderer only has access to messaging if `requiresMessaging`
C
Connor Peet 已提交
1509
		 * is set to `always` or `optional` in its `notebookRenderer ` contribution.
1510 1511 1512
		 *
		 * @see https://github.com/microsoft/vscode/issues/123601
		 * @param rendererId The renderer ID to communicate with
1513 1514 1515
		*/
		// todo@API can ANY extension talk to renderer or is there a check that the calling extension
		// declared the renderer in its package.json?
1516
		export function createRendererMessaging<TSend = any, TReceive = TSend>(rendererId: string): NotebookRendererMessaging<TSend, TReceive>;
1517 1518 1519 1520
	}

	//#endregion

1521
	//#region @eamodio - timeline: https://github.com/microsoft/vscode/issues/84297
1522 1523 1524

	export class TimelineItem {
		/**
1525
		 * A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred.
1526
		 */
E
Eric Amodio 已提交
1527
		timestamp: number;
1528 1529

		/**
1530
		 * A human-readable string describing the timeline item.
1531 1532 1533 1534
		 */
		label: string;

		/**
1535
		 * Optional id for the timeline item. It must be unique across all the timeline items provided by this source.
1536
		 *
1537
		 * If not provided, an id is generated using the timeline item's timestamp.
1538 1539 1540 1541
		 */
		id?: string;

		/**
M
Matt Bierner 已提交
1542
		 * The icon path or {@link ThemeIcon} for the timeline item.
1543
		 */
R
rebornix 已提交
1544
		iconPath?: Uri | { light: Uri; dark: Uri; } | ThemeIcon;
1545 1546

		/**
1547
		 * A human readable string describing less prominent details of the timeline item.
1548 1549 1550 1551 1552 1553
		 */
		description?: string;

		/**
		 * The tooltip text when you hover over the timeline item.
		 */
1554
		detail?: string;
1555 1556

		/**
M
Matt Bierner 已提交
1557
		 * The {@link Command} that should be executed when the timeline item is selected.
1558 1559 1560 1561
		 */
		command?: Command;

		/**
1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577
		 * Context value of the timeline item. This can be used to contribute specific actions to the item.
		 * For example, a timeline item is given a context value as `commit`. When contributing actions to `timeline/item/context`
		 * using `menus` extension point, you can specify context value for key `timelineItem` in `when` expression like `timelineItem == commit`.
		 * ```
		 *	"contributes": {
		 *		"menus": {
		 *			"timeline/item/context": [
		 *				{
		 *					"command": "extension.copyCommitId",
		 *					"when": "timelineItem == commit"
		 *				}
		 *			]
		 *		}
		 *	}
		 * ```
		 * This will show the `extension.copyCommitId` action only for items where `contextValue` is `commit`.
1578 1579 1580
		 */
		contextValue?: string;

1581 1582 1583 1584 1585
		/**
		 * Accessibility information used when screen reader interacts with this timeline item.
		 */
		accessibilityInformation?: AccessibilityInformation;

1586 1587
		/**
		 * @param label A human-readable string describing the timeline item
E
Eric Amodio 已提交
1588
		 * @param timestamp A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred
1589
		 */
E
Eric Amodio 已提交
1590
		constructor(label: string, timestamp: number);
1591 1592
	}

1593
	export interface TimelineChangeEvent {
E
Eric Amodio 已提交
1594
		/**
M
Matt Bierner 已提交
1595
		 * The {@link Uri} of the resource for which the timeline changed.
E
Eric Amodio 已提交
1596
		 */
E
Eric Amodio 已提交
1597
		uri: Uri;
1598

E
Eric Amodio 已提交
1599
		/**
1600
		 * A flag which indicates whether the entire timeline should be reset.
E
Eric Amodio 已提交
1601
		 */
1602 1603
		reset?: boolean;
	}
E
Eric Amodio 已提交
1604

1605 1606 1607
	export interface Timeline {
		readonly paging?: {
			/**
E
Eric Amodio 已提交
1608
			 * A provider-defined cursor specifying the starting point of timeline items which are after the ones returned.
E
Eric Amodio 已提交
1609
			 * Use `undefined` to signal that there are no more items to be returned.
1610
			 */
E
Eric Amodio 已提交
1611
			readonly cursor: string | undefined;
R
rebornix 已提交
1612
		};
E
Eric Amodio 已提交
1613 1614

		/**
M
Matt Bierner 已提交
1615
		 * An array of {@link TimelineItem timeline items}.
E
Eric Amodio 已提交
1616
		 */
1617
		readonly items: readonly TimelineItem[];
E
Eric Amodio 已提交
1618 1619
	}

1620
	export interface TimelineOptions {
E
Eric Amodio 已提交
1621
		/**
E
Eric Amodio 已提交
1622
		 * A provider-defined cursor specifying the starting point of the timeline items that should be returned.
E
Eric Amodio 已提交
1623
		 */
1624
		cursor?: string;
E
Eric Amodio 已提交
1625 1626

		/**
1627 1628
		 * An optional maximum number timeline items or the all timeline items newer (inclusive) than the timestamp or id that should be returned.
		 * If `undefined` all timeline items should be returned.
E
Eric Amodio 已提交
1629
		 */
R
rebornix 已提交
1630
		limit?: number | { timestamp: number; id?: string; };
E
Eric Amodio 已提交
1631 1632
	}

1633
	export interface TimelineProvider {
1634
		/**
1635 1636
		 * An optional event to signal that the timeline for a source has changed.
		 * To signal that the timeline for all resources (uris) has changed, do not pass any argument or pass `undefined`.
1637
		 */
E
Eric Amodio 已提交
1638
		onDidChange?: Event<TimelineChangeEvent | undefined>;
1639 1640

		/**
1641
		 * An identifier of the source of the timeline items. This can be used to filter sources.
1642
		 */
1643
		readonly id: string;
1644

E
Eric Amodio 已提交
1645
		/**
1646
		 * A human-readable string describing the source of the timeline items. This can be used as the display label when filtering sources.
E
Eric Amodio 已提交
1647
		 */
1648
		readonly label: string;
1649 1650

		/**
M
Matt Bierner 已提交
1651
		 * Provide {@link TimelineItem timeline items} for a {@link Uri}.
1652
		 *
M
Matt Bierner 已提交
1653
		 * @param uri The {@link Uri} of the file to provide the timeline for.
1654
		 * @param options A set of options to determine how results should be returned.
1655
		 * @param token A cancellation token.
M
Matt Bierner 已提交
1656
		 * @return The {@link TimelineResult timeline result} or a thenable that resolves to such. The lack of a result
1657 1658
		 * can be signaled by returning `undefined`, `null`, or an empty array.
		 */
1659
		provideTimeline(uri: Uri, options: TimelineOptions, token: CancellationToken): ProviderResult<Timeline>;
1660 1661 1662 1663 1664 1665 1666 1667 1668 1669
	}

	export namespace workspace {
		/**
		 * Register a timeline provider.
		 *
		 * Multiple providers can be registered. In that case, providers are asked in
		 * parallel and the results are merged. A failing provider (rejected promise or exception) will
		 * not cause a failure of the whole operation.
		 *
1670
		 * @param scheme A scheme or schemes that defines which documents this provider is applicable to. Can be `*` to target all documents.
1671
		 * @param provider A timeline provider.
M
Matt Bierner 已提交
1672
		 * @return A {@link Disposable} that unregisters this provider when being disposed.
E
Eric Amodio 已提交
1673
		*/
1674
		export function registerTimelineProvider(scheme: string | string[], provider: TimelineProvider): Disposable;
1675 1676 1677
	}

	//#endregion
1678

1679
	//#region https://github.com/microsoft/vscode/issues/91555
1680

1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693
	export enum StandardTokenType {
		Other = 0,
		Comment = 1,
		String = 2,
		RegEx = 4
	}

	export interface TokenInformation {
		type: StandardTokenType;
		range: Range;
	}

	export namespace languages {
1694
		export function getTokenInformationAtPosition(document: TextDocument, position: Position): Thenable<TokenInformation>;
K
kingwl 已提交
1695 1696 1697 1698
	}

	//#endregion

J
Johannes Rieken 已提交
1699
	//#region https://github.com/microsoft/vscode/issues/16221
K
kingwl 已提交
1700

1701
	// todo@API Split between Inlay- and OverlayHints (InlayHint are for a position, OverlayHints for a non-empty range)
J
Johannes Rieken 已提交
1702
	// todo@API add "mini-markdown" for links and styles
1703 1704 1705
	// (done) remove description
	// (done) rename to InlayHint
	// (done)  add InlayHintKind with type, argument, etc
J
Johannes Rieken 已提交
1706

K
kingwl 已提交
1707
	export namespace languages {
K
kingwl 已提交
1708
		/**
1709
		 * Register a inlay hints provider.
K
kingwl 已提交
1710
		 *
J
Johannes Rieken 已提交
1711 1712 1713
		 * Multiple providers can be registered for a language. In that case providers are asked in
		 * parallel and the results are merged. A failing provider (rejected promise or exception) will
		 * not cause a failure of the whole operation.
K
kingwl 已提交
1714 1715
		 *
		 * @param selector A selector that defines the documents this provider is applicable to.
J
Johannes Rieken 已提交
1716
		 * @param provider An inlay hints provider.
M
Matt Bierner 已提交
1717
		 * @return A {@link Disposable} that unregisters this provider when being disposed.
K
kingwl 已提交
1718
		 */
1719
		export function registerInlayHintsProvider(selector: DocumentSelector, provider: InlayHintsProvider): Disposable;
1720 1721
	}

1722
	export enum InlayHintKind {
1723 1724 1725 1726 1727
		Other = 0,
		Type = 1,
		Parameter = 2,
	}

K
kingwl 已提交
1728
	/**
J
Johannes Rieken 已提交
1729
	 * Inlay hint information.
K
kingwl 已提交
1730
	 */
1731
	export class InlayHint {
K
kingwl 已提交
1732 1733 1734 1735 1736
		/**
		 * The text of the hint.
		 */
		text: string;
		/**
1737
		 * The position of this hint.
K
kingwl 已提交
1738
		 */
1739 1740 1741 1742 1743
		position: Position;
		/**
		 * The kind of this hint.
		 */
		kind?: InlayHintKind;
K
kingwl 已提交
1744 1745 1746 1747 1748 1749 1750 1751 1752
		/**
		 * Whitespace before the hint.
		 */
		whitespaceBefore?: boolean;
		/**
		 * Whitespace after the hint.
		 */
		whitespaceAfter?: boolean;

1753
		// todo@API make range first argument
1754
		constructor(text: string, position: Position, kind?: InlayHintKind);
K
kingwl 已提交
1755 1756 1757
	}

	/**
J
Johannes Rieken 已提交
1758 1759
	 * The inlay hints provider interface defines the contract between extensions and
	 * the inlay hints feature.
K
kingwl 已提交
1760
	 */
1761
	export interface InlayHintsProvider {
W
Wenlu Wang 已提交
1762 1763

		/**
J
Johannes Rieken 已提交
1764
		 * An optional event to signal that inlay hints have changed.
M
Matt Bierner 已提交
1765
		 * @see {@link EventEmitter}
W
Wenlu Wang 已提交
1766
		 */
1767
		onDidChangeInlayHints?: Event<void>;
J
Johannes Rieken 已提交
1768

K
kingwl 已提交
1769
		/**
J
Johannes Rieken 已提交
1770
		 *
K
kingwl 已提交
1771
		 * @param model The document in which the command was invoked.
J
Johannes Rieken 已提交
1772
		 * @param range The range for which inlay hints should be computed.
K
kingwl 已提交
1773
		 * @param token A cancellation token.
J
Johannes Rieken 已提交
1774
		 * @return A list of inlay hints or a thenable that resolves to such.
K
kingwl 已提交
1775
		 */
1776
		provideInlayHints(model: TextDocument, range: Range, token: CancellationToken): ProviderResult<InlayHint[]>;
K
kingwl 已提交
1777
	}
1778
	//#endregion
1779

1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797
	//#region https://github.com/microsoft/vscode/issues/104436

	export enum ExtensionRuntime {
		/**
		 * The extension is running in a NodeJS extension host. Runtime access to NodeJS APIs is available.
		 */
		Node = 1,
		/**
		 * The extension is running in a Webworker extension host. Runtime access is limited to Webworker APIs.
		 */
		Webworker = 2
	}

	export interface ExtensionContext {
		readonly extensionRuntime: ExtensionRuntime;
	}

	//#endregion
1798 1799 1800 1801

	//#region https://github.com/microsoft/vscode/issues/102091

	export interface TextDocument {
1802 1803

		/**
M
Matt Bierner 已提交
1804
		 * The {@link NotebookDocument notebook} that contains this document as a notebook cell or `undefined` when
1805 1806
		 * the document is not contained by a notebook (this should be the more frequent case).
		 */
1807 1808 1809
		notebook: NotebookDocument | undefined;
	}
	//#endregion
C
Connor Peet 已提交
1810 1811 1812

	//#region https://github.com/microsoft/vscode/issues/107467
	export namespace test {
C
Connor Peet 已提交
1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825
		/**
		 * Registers a controller that can discover and
		 * run tests in workspaces and documents.
		 */
		export function registerTestController<T>(testController: TestController<T>): Disposable;

		/**
		 * Requests that tests be run by their controller.
		 * @param run Run options to use
		 * @param token Cancellation token for the test run
		 */
		export function runTests<T>(run: TestRunRequest<T>, token?: CancellationToken): Thenable<void>;

C
Connor Peet 已提交
1826 1827
		/**
		 * Returns an observer that retrieves tests in the given workspace folder.
1828
		 * @stability experimental
C
Connor Peet 已提交
1829 1830 1831 1832 1833
		 */
		export function createWorkspaceTestObserver(workspaceFolder: WorkspaceFolder): TestObserver;

		/**
		 * Returns an observer that retrieves tests in the given text document.
1834
		 * @stability experimental
C
Connor Peet 已提交
1835 1836
		 */
		export function createDocumentTestObserver(document: TextDocument): TestObserver;
1837

C
Connor Peet 已提交
1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850
		/**
		 * Creates a {@link TestRun<T>}. This should be called by the
		 * {@link TestRunner} when a request is made to execute tests, and may also
		 * be called if a test run is detected externally. Once created, tests
		 * that are included in the results will be moved into the
		 * {@link TestResultState.Pending} state.
		 *
		 * @param request Test run request. Only tests inside the `include` may be
		 * modified, and tests in its `exclude` are ignored.
		 * @param name The human-readable name of the run. This can be used to
		 * disambiguate multiple sets of results in a test run. It is useful if
		 * tests are run across multiple platforms, for example.
		 * @param persist Whether the results created by the run should be
M
Matt Bierner 已提交
1851
		 * persisted in the editor. This may be false if the results are coming from
C
Connor Peet 已提交
1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868
		 * a file already saved externally, such as a coverage information file.
		 */
		export function createTestRun<T>(request: TestRunRequest<T>, name?: string, persist?: boolean): TestRun<T>;

		/**
		 * Creates a new managed {@link TestItem} instance.
		 * @param options Initial/required options for the item
		 * @param data Custom data to be stored in {@link TestItem.data}
		 */
		export function createTestItem<T, TChildren = T>(options: TestItemOptions, data: T): TestItem<T, TChildren>;

		/**
		 * Creates a new managed {@link TestItem} instance.
		 * @param options Initial/required options for the item
		 */
		export function createTestItem<T = void, TChildren = any>(options: TestItemOptions): TestItem<T, TChildren>;

1869
		/**
M
Matt Bierner 已提交
1870
		 * List of test results stored by the editor, sorted in descending
1871 1872 1873
		 * order by their `completedAt` time.
		 * @stability experimental
		 */
C
Connor Peet 已提交
1874
		export const testResults: ReadonlyArray<TestRunResult>;
1875 1876

		/**
1877 1878 1879
		 * Event that fires when the {@link testResults} array is updated.
		 * @stability experimental
		 */
1880
		export const onDidChangeTestResults: Event<void>;
C
Connor Peet 已提交
1881 1882
	}

1883 1884 1885
	/**
	 * @stability experimental
	 */
C
Connor Peet 已提交
1886 1887 1888 1889
	export interface TestObserver {
		/**
		 * List of tests returned by test provider for files in the workspace.
		 */
1890
		readonly tests: ReadonlyArray<TestItem<never>>;
C
Connor Peet 已提交
1891 1892 1893 1894 1895 1896

		/**
		 * An event that fires when an existing test in the collection changes, or
		 * null if a top-level test was added or removed. When fired, the consumer
		 * should check the test item and all its children for changes.
		 */
C
Connor Peet 已提交
1897
		readonly onDidChangeTest: Event<TestsChangeEvent>;
C
Connor Peet 已提交
1898 1899

		/**
C
Connor Peet 已提交
1900
		 * An event that fires when all test providers have signalled that the tests
C
Connor Peet 已提交
1901 1902 1903 1904 1905 1906 1907 1908 1909
		 * the observer references have been discovered. Providers may continue to
		 * watch for changes and cause {@link onDidChangeTest} to fire as files
		 * change, until the observer is disposed.
		 *
		 * @todo as below
		 */
		readonly onDidDiscoverInitialTests: Event<void>;

		/**
M
Matt Bierner 已提交
1910
		 * Dispose of the observer, allowing the editor to eventually tell test
C
Connor Peet 已提交
1911 1912 1913 1914 1915
		 * providers that they no longer need to update tests.
		 */
		dispose(): void;
	}

1916 1917 1918
	/**
	 * @stability experimental
	 */
C
Connor Peet 已提交
1919
	export interface TestsChangeEvent {
C
Connor Peet 已提交
1920 1921 1922
		/**
		 * List of all tests that are newly added.
		 */
1923
		readonly added: ReadonlyArray<TestItem<never>>;
C
Connor Peet 已提交
1924 1925 1926 1927

		/**
		 * List of existing tests that have updated.
		 */
1928
		readonly updated: ReadonlyArray<TestItem<never>>;
C
Connor Peet 已提交
1929 1930 1931 1932

		/**
		 * List of existing tests that have been removed.
		 */
1933
		readonly removed: ReadonlyArray<TestItem<never>>;
C
Connor Peet 已提交
1934 1935
	}

C
Connor Peet 已提交
1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978
	/**
	 * Interface to discover and execute tests.
	 */
	export interface TestController<T> {
		/**
		 * Requests that tests be provided for the given workspace. This will
		 * be called when tests need to be enumerated for the workspace, such as
		 * when the user opens the test explorer.
		 *
		 * It's guaranteed that this method will not be called again while
		 * there is a previous uncancelled call for the given workspace folder.
		 *
		 * @param workspace The workspace in which to observe tests
		 * @param cancellationToken Token that signals the used asked to abort the test run.
		 * @returns the root test item for the workspace
		 */
		createWorkspaceTestRoot(workspace: WorkspaceFolder, token: CancellationToken): ProviderResult<TestItem<T>>;

		/**
		 * Requests that tests be provided for the given document. This will be
		 * called when tests need to be enumerated for a single open file, for
		 * instance by code lens UI.
		 *
		 * It's suggested that the provider listen to change events for the text
		 * document to provide information for tests that might not yet be
		 * saved.
		 *
		 * If the test system is not able to provide or estimate for tests on a
		 * per-file basis, this method may not be implemented. In that case, the
		 * editor will request and use the information from the workspace tree.
		 *
		 * @param document The document in which to observe tests
		 * @param cancellationToken Token that signals the used asked to abort the test run.
		 * @returns the root test item for the document
		 */
		createDocumentTestRoot?(document: TextDocument, token: CancellationToken): ProviderResult<TestItem<T>>;

		/**
		 * Starts a test run. When called, the controller should call
		 * {@link vscode.test.createTestRun}. All tasks associated with the
		 * run should be created before the function returns or the reutrned
		 * promise is resolved.
		 *
1979 1980 1981 1982 1983
		 * @param request Request information for the test run
		 * @param cancellationToken Token that signals the used asked to abort the
		 * test run. If cancellation is requested on this token, all {@link TestRun}
		 * instances associated with the request will be
		 * automatically cancelled as well.
C
Connor Peet 已提交
1984
		 */
1985
		runTests(request: TestRunRequest<T>, token: CancellationToken): Thenable<void> | void;
C
Connor Peet 已提交
1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999
	}

	/**
	 * Options given to {@link test.runTests}.
	 */
	export interface TestRunRequest<T> {
		/**
		 * Array of specific tests to run. The controllers should run all of the
		 * given tests and all children of the given tests, excluding any tests
		 * that appear in {@link TestRunRequest.exclude}.
		 */
		tests: TestItem<T>[];

		/**
M
Matt Bierner 已提交
2000
		 * An array of tests the user has marked as excluded in the editor. May be
C
Connor Peet 已提交
2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022
		 * omitted if no exclusions were requested. Test controllers should not run
		 * excluded tests or any children of excluded tests.
		 */
		exclude?: TestItem<T>[];

		/**
		 * Whether tests in this run should be debugged.
		 */
		debug: boolean;
	}

	/**
	 * Options given to {@link TestController.runTests}
	 */
	export interface TestRun<T = void> {
		/**
		 * The human-readable name of the run. This can be used to
		 * disambiguate multiple sets of results in a test run. It is useful if
		 * tests are run across multiple platforms, for example.
		 */
		readonly name?: string;

2023 2024 2025 2026 2027 2028
		/**
		 * A cancellation token which will be triggered when the test run is
		 * canceled from the UI.
		 */
		readonly token: CancellationToken;

C
Connor Peet 已提交
2029 2030 2031 2032 2033 2034 2035
		/**
		 * Updates the state of the test in the run. Calling with method with nodes
		 * outside the {@link TestRunRequest.tests} or in the
		 * {@link TestRunRequest.exclude} array will no-op.
		 *
		 * @param test The test to update
		 * @param state The state to assign to the test
2036
		 * @param duration Optionally sets how long the test took to run, in milliseconds
C
Connor Peet 已提交
2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308
		 */
		setState(test: TestItem<T>, state: TestResultState, duration?: number): void;

		/**
		 * Appends a message, such as an assertion error, to the test item.
		 *
		 * Calling with method with nodes outside the {@link TestRunRequest.tests}
		 * or in the {@link TestRunRequest.exclude} array will no-op.
		 *
		 * @param test The test to update
		 * @param state The state to assign to the test
		 *
		 */
		appendMessage(test: TestItem<T>, message: TestMessage): void;

		/**
		 * Appends raw output from the test runner. On the user's request, the
		 * output will be displayed in a terminal. ANSI escape sequences,
		 * such as colors and text styles, are supported.
		 *
		 * @param output Output text to append
		 * @param associateTo Optionally, associate the given segment of output
		 */
		appendOutput(output: string): void;

		/**
		 * Signals that the end of the test run. Any tests whose states have not
		 * been updated will be moved into the {@link TestResultState.Unset} state.
		 */
		end(): void;
	}

	/**
	 * Indicates the the activity state of the {@link TestItem}.
	 */
	export enum TestItemStatus {
		/**
		 * All children of the test item, if any, have been discovered.
		 */
		Resolved = 1,

		/**
		 * The test item may have children who have not been discovered yet.
		 */
		Pending = 0,
	}

	/**
	 * Options initially passed into `vscode.test.createTestItem`
	 */
	export interface TestItemOptions {
		/**
		 * Unique identifier for the TestItem. This is used to correlate
		 * test results and tests in the document with those in the workspace
		 * (test explorer). This cannot change for the lifetime of the TestItem.
		 */
		id: string;

		/**
		 * URI this TestItem is associated with. May be a file or directory.
		 */
		uri?: Uri;

		/**
		 * Display name describing the test item.
		 */
		label: string;
	}

	/**
	 * A test item is an item shown in the "test explorer" view. It encompasses
	 * both a suite and a test, since they have almost or identical capabilities.
	 */
	export interface TestItem<T, TChildren = any> {
		/**
		 * Unique identifier for the TestItem. This is used to correlate
		 * test results and tests in the document with those in the workspace
		 * (test explorer). This must not change for the lifetime of the TestItem.
		 */
		readonly id: string;

		/**
		 * URI this TestItem is associated with. May be a file or directory.
		 */
		readonly uri?: Uri;

		/**
		 * A mapping of children by ID to the associated TestItem instances.
		 */
		readonly children: ReadonlyMap<string, TestItem<TChildren>>;

		/**
		 * The parent of this item, if any. Assigned automatically when calling
		 * {@link TestItem.addChild}.
		 */
		readonly parent?: TestItem<any>;

		/**
		 * Indicates the state of the test item's children. The editor will show
		 * TestItems in the `Pending` state and with a `resolveHandler` as being
		 * expandable, and will call the `resolveHandler` to request items.
		 *
		 * A TestItem in the `Resolved` state is assumed to have discovered and be
		 * watching for changes in its children if applicable. TestItems are in the
		 * `Resolved` state when initially created; if the editor should call
		 * the `resolveHandler` to discover children, set the state to `Pending`
		 * after creating the item.
		 */
		status: TestItemStatus;

		/**
		 * Display name describing the test case.
		 */
		label: string;

		/**
		 * Optional description that appears next to the label.
		 */
		description?: string;

		/**
		 * Location of the test item in its `uri`. This is only meaningful if the
		 * `uri` points to a file.
		 */
		range?: Range;

		/**
		 * May be set to an error associated with loading the test. Note that this
		 * is not a test result and should only be used to represent errors in
		 * discovery, such as syntax errors.
		 */
		error?: string | MarkdownString;

		/**
		 * Whether this test item can be run by providing it in the
		 * {@link TestRunRequest.tests} array. Defaults to `true`.
		 */
		runnable: boolean;

		/**
		 * Whether this test item can be debugged by providing it in the
		 * {@link TestRunRequest.tests} array. Defaults to `false`.
		 */
		debuggable: boolean;

		/**
		 * Custom extension data on the item. This data will never be serialized
		 * or shared outside the extenion who created the item.
		 */
		data: T;

		/**
		 * Marks the test as outdated. This can happen as a result of file changes,
		 * for example. In "auto run" mode, tests that are outdated will be
		 * automatically rerun after a short delay. Invoking this on a
		 * test with children will mark the entire subtree as outdated.
		 *
		 * Extensions should generally not override this method.
		 */
		invalidate(): void;

		/**
		 * A function provided by the extension that the editor may call to request
		 * children of the item, if the {@link TestItem.status} is `Pending`.
		 *
		 * When called, the item should discover tests and call {@link TestItem.addChild}.
		 * The items should set its {@link TestItem.status} to `Resolved` when
		 * discovery is finished.
		 *
		 * The item should continue watching for changes to the children and
		 * firing updates until the token is cancelled. The process of watching
		 * the tests may involve creating a file watcher, for example. After the
		 * token is cancelled and watching stops, the TestItem should set its
		 * {@link TestItem.status} back to `Pending`.
		 *
		 * The editor will only call this method when it's interested in refreshing
		 * the children of the item, and will not call it again while there's an
		 * existing, uncancelled discovery for an item.
		 *
		 * @param token Cancellation for the request. Cancellation will be
		 * requested if the test changes before the previous call completes.
		 */
		resolveHandler?: (token: CancellationToken) => void;

		/**
		 * Attaches a child, created from the {@link test.createTestItem} function,
		 * to this item. A `TestItem` may be a child of at most one other item.
		 */
		addChild(child: TestItem<TChildren>): void;

		/**
		 * Removes the test and its children from the tree. Any tokens passed to
		 * child `resolveHandler` methods will be cancelled.
		 */
		dispose(): void;
	}

	/**
	 * Possible states of tests in a test run.
	 */
	export enum TestResultState {
		// Initial state
		Unset = 0,
		// Test will be run, but is not currently running.
		Queued = 1,
		// Test is currently running
		Running = 2,
		// Test run has passed
		Passed = 3,
		// Test run has failed (on an assertion)
		Failed = 4,
		// Test run has been skipped
		Skipped = 5,
		// Test run failed for some other reason (compilation error, timeout, etc)
		Errored = 6
	}

	/**
	 * Represents the severity of test messages.
	 */
	export enum TestMessageSeverity {
		Error = 0,
		Warning = 1,
		Information = 2,
		Hint = 3
	}

	/**
	 * Message associated with the test state. Can be linked to a specific
	 * source range -- useful for assertion failures, for example.
	 */
	export class TestMessage {
		/**
		 * Human-readable message text to display.
		 */
		message: string | MarkdownString;

		/**
		 * Message severity. Defaults to "Error".
		 */
		severity: TestMessageSeverity;

		/**
		 * Expected test output. If given with `actualOutput`, a diff view will be shown.
		 */
		expectedOutput?: string;

		/**
		 * Actual test output. If given with `expectedOutput`, a diff view will be shown.
		 */
		actualOutput?: string;

		/**
		 * Associated file location.
		 */
		location?: Location;

		/**
		 * Creates a new TestMessage that will present as a diff in the editor.
		 * @param message Message to display to the user.
		 * @param expected Expected output.
		 * @param actual Actual output.
		 */
		static diff(message: string | MarkdownString, expected: string, actual: string): TestMessage;

		/**
		 * Creates a new TestMessage instance.
		 * @param message The message to show to the user.
		 */
		constructor(message: string | MarkdownString);
	}

2309
	/**
M
Matt Bierner 已提交
2310
	 * TestResults can be provided to the editor in {@link test.publishTestResult},
C
Connor Peet 已提交
2311
	 * or read from it in {@link test.testResults}.
2312 2313
	 *
	 * The results contain a 'snapshot' of the tests at the point when the test
C
Connor Peet 已提交
2314 2315 2316
	 * run is complete. Therefore, information such as its {@link Range} may be
	 * out of date. If the test still exists in the workspace, consumers can use
	 * its `id` to correlate the result instance with the living test.
2317
	 *
2318
	 * @todo coverage and other info may eventually be provided here
2319
	 */
C
Connor Peet 已提交
2320
	export interface TestRunResult {
2321
		/**
C
Connor Peet 已提交
2322
		 * Unix milliseconds timestamp at which the test run was completed.
2323 2324 2325
		 */
		completedAt: number;

2326 2327 2328 2329 2330
		/**
		 * Optional raw output from the test run.
		 */
		output?: string;

2331 2332 2333 2334
		/**
		 * List of test results. The items in this array are the items that
		 * were passed in the {@link test.runTests} method.
		 */
2335
		results: ReadonlyArray<Readonly<TestResultSnapshot>>;
2336 2337 2338
	}

	/**
2339 2340
	 * A {@link TestItem}-like interface with an associated result, which appear
	 * or can be provided in {@link TestResult} interfaces.
2341
	 */
2342 2343 2344 2345 2346 2347 2348 2349
	export interface TestResultSnapshot {
		/**
		 * Unique identifier that matches that of the associated TestItem.
		 * This is used to correlate test results and tests in the document with
		 * those in the workspace (test explorer).
		 */
		readonly id: string;

2350 2351 2352
		/**
		 * URI this TestItem is associated with. May be a file or file.
		 */
C
Connor Peet 已提交
2353
		readonly uri?: Uri;
2354

2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365
		/**
		 * Display name describing the test case.
		 */
		readonly label: string;

		/**
		 * Optional description that appears next to the label.
		 */
		readonly description?: string;

		/**
2366 2367
		 * Location of the test item in its `uri`. This is only meaningful if the
		 * `uri` points to a file.
2368
		 */
2369
		readonly range?: Range;
2370

2371
		/**
2372 2373
		 * State of the test in each task. In the common case, a test will only
		 * be executed in a single task and the length of this array will be 1.
2374
		 */
2375
		readonly taskStates: ReadonlyArray<TestSnapshoptTaskState>;
2376 2377 2378 2379

		/**
		 * Optional list of nested tests for this item.
		 */
2380
		readonly children: Readonly<TestResultSnapshot>[];
C
Connor Peet 已提交
2381
	}
2382

2383
	export interface TestSnapshoptTaskState {
2384 2385 2386
		/**
		 * Current result of the test.
		 */
C
Connor Peet 已提交
2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399
		readonly state: TestResultState;

		/**
		 * The number of milliseconds the test took to run. This is set once the
		 * `state` is `Passed`, `Failed`, or `Errored`.
		 */
		readonly duration?: number;

		/**
		 * Associated test run message. Can, for example, contain assertion
		 * failure information if the test fails.
		 */
		readonly messages: ReadonlyArray<TestMessage>;
2400 2401
	}

C
Connor Peet 已提交
2402
	//#endregion
2403 2404 2405

	//#region Opener service (https://github.com/microsoft/vscode/issues/109277)

2406 2407 2408
	/**
	 * Details if an `ExternalUriOpener` can open a uri.
	 *
2409 2410 2411 2412
	 * The priority is also used to rank multiple openers against each other and determine
	 * if an opener should be selected automatically or if the user should be prompted to
	 * select an opener.
	 *
M
Matt Bierner 已提交
2413
	 * The editor will try to use the best available opener, as sorted by `ExternalUriOpenerPriority`.
2414 2415
	 * If there are multiple potential "best" openers for a URI, then the user will be prompted
	 * to select an opener.
2416
	 */
M
Matt Bierner 已提交
2417
	export enum ExternalUriOpenerPriority {
2418
		/**
2419
		 * The opener is disabled and will never be shown to users.
M
Matt Bierner 已提交
2420
		 *
2421 2422
		 * Note that the opener can still be used if the user specifically
		 * configures it in their settings.
2423
		 */
M
Matt Bierner 已提交
2424
		None = 0,
2425 2426

		/**
2427
		 * The opener can open the uri but will not cause a prompt on its own
M
Matt Bierner 已提交
2428
		 * since the editor always contributes a built-in `Default` opener.
2429
		 */
M
Matt Bierner 已提交
2430
		Option = 1,
2431 2432

		/**
M
Matt Bierner 已提交
2433 2434
		 * The opener can open the uri.
		 *
M
Matt Bierner 已提交
2435
		 * The editor's built-in opener has `Default` priority. This means that any additional `Default`
2436
		 * openers will cause the user to be prompted to select from a list of all potential openers.
2437
		 */
M
Matt Bierner 已提交
2438 2439 2440
		Default = 2,

		/**
2441
		 * The opener can open the uri and should be automatically selected over any
M
Matt Bierner 已提交
2442
		 * default openers, include the built-in one from the editor.
M
Matt Bierner 已提交
2443
		 *
2444
		 * A preferred opener will be automatically selected if no other preferred openers
2445
		 * are available. If multiple preferred openers are available, then the user
2446
		 * is shown a prompt with all potential openers (not just preferred openers).
M
Matt Bierner 已提交
2447 2448
		 */
		Preferred = 3,
2449 2450
	}

2451
	/**
M
Matt Bierner 已提交
2452
	 * Handles opening uris to external resources, such as http(s) links.
2453
	 *
M
Matt Bierner 已提交
2454
	 * Extensions can implement an `ExternalUriOpener` to open `http` links to a webserver
M
Matt Bierner 已提交
2455
	 * inside of the editor instead of having the link be opened by the web browser.
2456 2457 2458 2459 2460 2461
	 *
	 * Currently openers may only be registered for `http` and `https` uris.
	 */
	export interface ExternalUriOpener {

		/**
2462
		 * Check if the opener can open a uri.
2463
		 *
M
Matt Bierner 已提交
2464 2465 2466
		 * @param uri The uri being opened. This is the uri that the user clicked on. It has
		 * not yet gone through port forwarding.
		 * @param token Cancellation token indicating that the result is no longer needed.
2467
		 *
2468
		 * @return Priority indicating if the opener can open the external uri.
M
Matt Bierner 已提交
2469
		 */
M
Matt Bierner 已提交
2470
		canOpenExternalUri(uri: Uri, token: CancellationToken): ExternalUriOpenerPriority | Thenable<ExternalUriOpenerPriority>;
M
Matt Bierner 已提交
2471 2472

		/**
2473
		 * Open a uri.
2474
		 *
M
Matt Bierner 已提交
2475
		 * This is invoked when:
2476
		 *
M
Matt Bierner 已提交
2477 2478 2479
		 * - The user clicks a link which does not have an assigned opener. In this case, first `canOpenExternalUri`
		 *   is called and if the user selects this opener, then `openExternalUri` is called.
		 * - The user sets the default opener for a link in their settings and then visits a link.
2480
		 *
M
Matt Bierner 已提交
2481 2482 2483 2484 2485 2486
		 * @param resolvedUri The uri to open. This uri may have been transformed by port forwarding, so it
		 * may not match the original uri passed to `canOpenExternalUri`. Use `ctx.originalUri` to check the
		 * original uri.
		 * @param ctx Additional information about the uri being opened.
		 * @param token Cancellation token indicating that opening has been canceled.
		 *
2487
		 * @return Thenable indicating that the opening has completed.
M
Matt Bierner 已提交
2488 2489 2490 2491 2492 2493 2494 2495 2496 2497
		 */
		openExternalUri(resolvedUri: Uri, ctx: OpenExternalUriContext, token: CancellationToken): Thenable<void> | void;
	}

	/**
	 * Additional information about the uri being opened.
	 */
	interface OpenExternalUriContext {
		/**
		 * The uri that triggered the open.
2498
		 *
2499
		 * This is the original uri that the user clicked on or that was passed to `openExternal.`
M
Matt Bierner 已提交
2500
		 * Due to port forwarding, this may not match the `resolvedUri` passed to `openExternalUri`.
2501
		 */
M
Matt Bierner 已提交
2502 2503 2504
		readonly sourceUri: Uri;
	}

M
Matt Bierner 已提交
2505
	/**
2506
	 * Additional metadata about a registered `ExternalUriOpener`.
M
Matt Bierner 已提交
2507
	 */
M
Matt Bierner 已提交
2508
	interface ExternalUriOpenerMetadata {
M
Matt Bierner 已提交
2509

M
Matt Bierner 已提交
2510 2511 2512 2513 2514 2515 2516
		/**
		 * List of uri schemes the opener is triggered for.
		 *
		 * Currently only `http` and `https` are supported.
		 */
		readonly schemes: readonly string[]

M
Matt Bierner 已提交
2517 2518
		/**
		 * Text displayed to the user that explains what the opener does.
2519
		 *
M
Matt Bierner 已提交
2520
		 * For example, 'Open in browser preview'
2521
		 */
M
Matt Bierner 已提交
2522
		readonly label: string;
2523 2524 2525 2526 2527 2528
	}

	namespace window {
		/**
		 * Register a new `ExternalUriOpener`.
		 *
2529
		 * When a uri is about to be opened, an `onOpenExternalUri:SCHEME` activation event is fired.
2530
		 *
M
Matt Bierner 已提交
2531 2532
		 * @param id Unique id of the opener, such as `myExtension.browserPreview`. This is used in settings
		 *   and commands to identify the opener.
2533
		 * @param opener Opener to register.
M
Matt Bierner 已提交
2534
		 * @param metadata Additional information about the opener.
2535 2536
		 *
		* @returns Disposable that unregisters the opener.
M
Matt Bierner 已提交
2537 2538
		*/
		export function registerExternalUriOpener(id: string, opener: ExternalUriOpener, metadata: ExternalUriOpenerMetadata): Disposable;
2539 2540
	}

2541 2542
	interface OpenExternalOptions {
		/**
2543 2544
		 * Allows using openers contributed by extensions through  `registerExternalUriOpener`
		 * when opening the resource.
2545
		 *
M
Matt Bierner 已提交
2546
		 * If `true`, the editor will check if any contributed openers can handle the
2547 2548
		 * uri, and fallback to the default opener behavior.
		 *
2549
		 * If it is string, this specifies the id of the `ExternalUriOpener`
M
Matt Bierner 已提交
2550
		 * that should be used if it is available. Use `'default'` to force the editor's
2551 2552 2553 2554 2555 2556 2557 2558 2559
		 * standard external opener to be used.
		 */
		readonly allowContributedOpeners?: boolean | string;
	}

	namespace env {
		export function openExternal(target: Uri, options?: OpenExternalOptions): Thenable<boolean>;
	}

J
Johannes Rieken 已提交
2560
	//#endregion
2561

J
João Moreno 已提交
2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578
	//#region @joaomoreno https://github.com/microsoft/vscode/issues/124263
	// This API change only affects behavior and documentation, not API surface.

	namespace env {

		/**
		 * Resolves a uri to form that is accessible externally.
		 *
		 * #### `http:` or `https:` scheme
		 *
		 * Resolves an *external* uri, such as a `http:` or `https:` link, from where the extension is running to a
		 * uri to the same resource on the client machine.
		 *
		 * This is a no-op if the extension is running on the client machine.
		 *
		 * If the extension is running remotely, this function automatically establishes a port forwarding tunnel
		 * from the local machine to `target` on the remote and returns a local uri to the tunnel. The lifetime of
M
Matt Bierner 已提交
2579
		 * the port forwarding tunnel is managed by the editor and the tunnel can be closed by the user.
J
João Moreno 已提交
2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615
		 *
		 * *Note* that uris passed through `openExternal` are automatically resolved and you should not call `asExternalUri` on them.
		 *
		 * #### `vscode.env.uriScheme`
		 *
		 * Creates a uri that - if opened in a browser (e.g. via `openExternal`) - will result in a registered {@link UriHandler}
		 * to trigger.
		 *
		 * Extensions should not make any assumptions about the resulting uri and should not alter it in anyway.
		 * Rather, extensions can e.g. use this uri in an authentication flow, by adding the uri as callback query
		 * argument to the server to authenticate to.
		 *
		 * *Note* that if the server decides to add additional query parameters to the uri (e.g. a token or secret), it
		 * will appear in the uri that is passed to the {@link UriHandler}.
		 *
		 * **Example** of an authentication flow:
		 * ```typescript
		 * vscode.window.registerUriHandler({
		 *   handleUri(uri: vscode.Uri): vscode.ProviderResult<void> {
		 *     if (uri.path === '/did-authenticate') {
		 *       console.log(uri.toString());
		 *     }
		 *   }
		 * });
		 *
		 * const callableUri = await vscode.env.asExternalUri(vscode.Uri.parse(`${vscode.env.uriScheme}://my.extension/did-authenticate`));
		 * await vscode.env.openExternal(callableUri);
		 * ```
		 *
		 * *Note* that extensions should not cache the result of `asExternalUri` as the resolved uri may become invalid due to
		 * a system or user action — for example, in remote cases, a user may close a port forwarding tunnel that was opened by
		 * `asExternalUri`.
		 *
		 * #### Any other scheme
		 *
		 * Any other scheme will be handled as if the provided URI is a workspace URI. In that case, the method will return
M
Matt Bierner 已提交
2616
		 * a URI which, when handled, will make the editor open the workspace.
J
João Moreno 已提交
2617 2618 2619 2620 2621 2622 2623 2624
		 *
		 * @return A uri that can be used on the client machine.
		 */
		export function asExternalUri(target: Uri): Thenable<Uri>;
	}

	//#endregion

2625 2626 2627 2628 2629 2630
	//#region https://github.com/Microsoft/vscode/issues/15178

	// TODO@API must be a class
	export interface OpenEditorInfo {
		name: string;
		resource: Uri;
2631
		isActive: boolean;
2632 2633 2634 2635 2636 2637 2638 2639 2640 2641
	}

	export namespace window {
		export const openEditors: ReadonlyArray<OpenEditorInfo>;

		// todo@API proper event type
		export const onDidChangeOpenEditors: Event<void>;
	}

	//#endregion
2642

2643
	//#region https://github.com/microsoft/vscode/issues/120173
L
Ladislau Szomoru 已提交
2644 2645 2646
	/**
	 * The object describing the properties of the workspace trust request
	 */
2647
	export interface WorkspaceTrustRequestOptions {
L
Ladislau Szomoru 已提交
2648
		/**
2649 2650 2651
		 * Custom message describing the user action that requires workspace
		 * trust. If omitted, a generic message will be displayed in the workspace
		 * trust request dialog.
L
Ladislau Szomoru 已提交
2652
		 */
2653
		readonly message?: string;
L
Ladislau Szomoru 已提交
2654 2655
	}

2656 2657 2658
	export namespace workspace {
		/**
		 * Prompt the user to chose whether to trust the current workspace
2659
		 * @param options Optional object describing the properties of the
2660
		 * workspace trust request.
2661
		 */
2662
		export function requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Thenable<boolean | undefined>;
2663 2664
	}

2665
	//#endregion
2666 2667 2668 2669 2670 2671 2672 2673 2674 2675

	//#region https://github.com/microsoft/vscode/issues/115616 @alexr00
	export enum PortAutoForwardAction {
		Notify = 1,
		OpenBrowser = 2,
		OpenPreview = 3,
		Silent = 4,
		Ignore = 5
	}

A
Alex Ross 已提交
2676 2677 2678 2679
	export class PortAttributes {
		/**
		 * The port number associated with this this set of attributes.
		 */
2680
		port: number;
A
Alex Ross 已提交
2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692

		/**
		 * The action to be taken when this port is detected for auto forwarding.
		 */
		autoForwardAction: PortAutoForwardAction;

		/**
		 * Creates a new PortAttributes object
		 * @param port the port number
		 * @param autoForwardAction the action to take when this port is detected
		 */
		constructor(port: number, autoForwardAction: PortAutoForwardAction);
2693 2694 2695
	}

	export interface PortAttributesProvider {
2696
		/**
2697 2698 2699
		 * Provides attributes for the given port. For ports that your extension doesn't know about, simply
		 * return undefined. For example, if `providePortAttributes` is called with ports 3000 but your
		 * extension doesn't know anything about 3000 you should return undefined.
2700
		 */
2701
		providePortAttributes(port: number, pid: number | undefined, commandLine: string | undefined, token: CancellationToken): ProviderResult<PortAttributes>;
2702 2703 2704 2705 2706 2707
	}

	export namespace workspace {
		/**
		 * If your extension listens on ports, consider registering a PortAttributesProvider to provide information
		 * about the ports. For example, a debug extension may know about debug ports in it's debuggee. By providing
M
Matt Bierner 已提交
2708
		 * this information with a PortAttributesProvider the extension can tell the editor that these ports should be
2709 2710 2711
		 * ignored, since they don't need to be user facing.
		 *
		 * @param portSelector If registerPortAttributesProvider is called after you start your process then you may already
2712 2713
		 * know the range of ports or the pid of your process. All properties of a the portSelector must be true for your
		 * provider to get called.
2714
		 * The `portRange` is start inclusive and end exclusive.
2715 2716
		 * @param provider The PortAttributesProvider
		 */
2717
		export function registerPortAttributesProvider(portSelector: { pid?: number, portRange?: [number, number], commandMatcher?: RegExp }, provider: PortAttributesProvider): Disposable;
2718 2719
	}
	//#endregion
2720

J
Johannes Rieken 已提交
2721
	//#region https://github.com/microsoft/vscode/issues/119904 @eamodio
2722 2723 2724 2725 2726 2727 2728 2729 2730 2731

	export interface SourceControlInputBox {

		/**
		 * Sets focus to the input.
		 */
		focus(): void;
	}

	//#endregion
2732

A
Alex Dima 已提交
2733 2734
	//#region https://github.com/microsoft/vscode/issues/124024 @hediet @alexdima

2735
	export namespace languages {
2736 2737 2738
		/**
		 * Registers an inline completion provider.
		 */
2739
		export function registerInlineCompletionItemProvider(selector: DocumentSelector, provider: InlineCompletionItemProvider): Disposable;
A
Alex Dima 已提交
2740 2741
	}

2742
	export interface InlineCompletionItemProvider<T extends InlineCompletionItem = InlineCompletionItem> {
2743 2744 2745 2746 2747 2748
		/**
		 * Provides inline completion items for the given position and document.
		 * If inline completions are enabled, this method will be called whenever the user stopped typing.
		 * It will also be called when the user explicitly triggers inline completions or asks for the next or previous inline completion.
		 * Use `context.triggerKind` to distinguish between these scenarios.
		*/
2749
		provideInlineCompletionItems(document: TextDocument, position: Position, context: InlineCompletionContext, token: CancellationToken): ProviderResult<InlineCompletionList<T> | T[]>;
2750
	}
H
wip  
Henning Dieterichs 已提交
2751

2752 2753 2754 2755 2756
	export interface InlineCompletionContext {
		/**
		 * How the completion was triggered.
		 */
		readonly triggerKind: InlineCompletionTriggerKind;
H
wip  
Henning Dieterichs 已提交
2757 2758
	}

2759 2760 2761 2762 2763 2764 2765 2766 2767 2768
	/**
	 * How an {@link InlineCompletionItemProvider inline completion provider} was triggered.
	 */
	export enum InlineCompletionTriggerKind {
		/**
		 * Completion was triggered automatically while editing.
		 * It is sufficient to return a single completion item in this case.
		 */
		Automatic = 0,

H
wip  
Henning Dieterichs 已提交
2769
		/**
2770 2771 2772 2773 2774
		 * Completion was triggered explicitly by a user gesture.
		 * Return multiple completion items to enable cycling through them.
		 */
		Explicit = 1,
	}
2775 2776 2777 2778 2779 2780 2781 2782

	export class InlineCompletionList<T extends InlineCompletionItem = InlineCompletionItem> {
		items: T[];

		constructor(items: T[]);
	}

	export class InlineCompletionItem {
2783
		/**
2784 2785 2786 2787 2788 2789 2790 2791 2792
		 * The text to insert.
		 * If the text contains a line break, the range must end at the end of a line.
		 * If existing text should be replaced, the existing text must be a prefix of the text to insert.
		*/
		text: string;

		/**
		 * The range to replace.
		 * Must begin and end on the same line.
2793 2794 2795 2796
		 *
		 * Prefer replacements over insertions to avoid cache invalidation.
		 * Instead of reporting a completion that extends a word,
		 * the whole word should be replaced with the extended word.
2797 2798 2799 2800 2801
		*/
		range?: Range;

		/**
		 * An optional {@link Command} that is executed *after* inserting this completion.
2802
		 */
2803 2804 2805
		command?: Command;

		constructor(text: string, range?: Range, command?: Command);
H
wip  
Henning Dieterichs 已提交
2806 2807
	}

2808 2809 2810 2811 2812 2813

	/**
	 * Be aware that this API will not ever be finalized.
	 */
	export namespace window {
		export function getInlineCompletionItemController<T extends InlineCompletionItem>(provider: InlineCompletionItemProvider<T>): InlineCompletionController<T>;
A
Alex Dima 已提交
2814 2815
	}

2816 2817 2818 2819
	/**
	 * Be aware that this API will not ever be finalized.
	 */
	export interface InlineCompletionController<T extends InlineCompletionItem> {
2820 2821 2822
		/**
		 * Is fired when an inline completion item is shown to the user.
		 */
2823 2824 2825 2826 2827 2828 2829 2830 2831
		// eslint-disable-next-line vscode-dts-event-naming
		readonly onDidShowCompletionItem: Event<InlineCompletionItemDidShowEvent<T>>;
	}

	/**
	 * Be aware that this API will not ever be finalized.
	 */
	export interface InlineCompletionItemDidShowEvent<T extends InlineCompletionItem> {
		completionItem: T;
A
Alex Dima 已提交
2832 2833 2834 2835
	}

	//#endregion

2836 2837 2838 2839 2840
	//#region FileSystemProvider stat readonly - https://github.com/microsoft/vscode/issues/73122

	export enum FilePermission {
		/**
		 * The file is readonly.
2841 2842 2843 2844 2845
		 *
		 * *Note:* All `FileStat` from a `FileSystemProvider` that is registered  with
		 * the option `isReadonly: true` will be implicitly handled as if `FilePermission.Readonly`
		 * is set. As a consequence, it is not possible to have a readonly file system provider
		 * registered where some `FileStat` are not readonly.
2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863
		 */
		Readonly = 1
	}

	/**
	 * The `FileStat`-type represents metadata about a file
	 */
	export interface FileStat {

		/**
		 * The permissions of the file, e.g. whether the file is readonly.
		 *
		 * *Note:* This value might be a bitmask, e.g. `FilePermission.Readonly | FilePermission.Other`.
		 */
		permissions?: FilePermission;
	}

	//#endregion
2864

E
Eric Amodio 已提交
2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875
	//#region https://github.com/microsoft/vscode/issues/87110 @eamodio

	export interface Memento {

		/**
		 * The stored keys.
		 */
		readonly keys: readonly string[];
	}

	//#endregion
2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887

	//#region https://github.com/microsoft/vscode/issues/126258 @aeschli

	export interface StatusBarItem {

		/**
		 * Will be merged into StatusBarItem#tooltip
		 */
		tooltip2: string | MarkdownString | undefined;

	}

2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916
	//#endregion

	//#region https://github.com/microsoft/vscode/issues/126280 @mjbvz

	export interface NotebookCellData {
		/**
		 * Mime type determines how the cell's `value` is interpreted.
		 *
		 * The mime selects which notebook renders is used to render the cell.
		 *
		 * If not set, internally the cell is treated as having a mime type of `text/plain`.
		 * Cells that set `language` to `markdown` instead are treated as `text/markdown`.
		 */
		mime?: string;
	}

	export interface NotebookCell {
		/**
		 * Mime type determines how the markup cell's `value` is interpreted.
		 *
		 * The mime selects which notebook renders is used to render the cell.
		 *
		 * If not set, internally the cell is treated as having a mime type of `text/plain`.
		 * Cells that set `language` to `markdown` instead are treated as `text/markdown`.
		 */
		mime: string | undefined;
	}

	//#endregion
J
Johannes Rieken 已提交
2917
}