vscode.proposed.d.ts 94.6 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 12 13 14 15
/**
 * 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:
 * - Use Insiders release of VS Code.
 * - 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 22 23 24 25 26 27
	/**
	 * An [event](#Event) which fires when an [AuthenticationProvider](#AuthenticationProvider) is added or removed.
	 */
	export interface AuthenticationProvidersChangeEvent {
		/**
		 * The ids of the [authenticationProvider](#AuthenticationProvider)s that have been added.
		 */
28
		readonly added: ReadonlyArray<AuthenticationProviderInformation>;
29 30

		/**
31
		 * The ids of the [authenticationProvider](#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
	}

A
Alexandru Dima 已提交
83 84 85
	export enum RemoteTrustOption {
		Unknown = 0,
		DisableTrust = 1,
86
		MachineTrusted = 2
A
Alexandru Dima 已提交
87 88
	}

89
	export interface ResolvedOptions {
R
rebornix 已提交
90
		extensionHostEnv?: { [key: string]: string | null; };
A
Alexandru Dima 已提交
91 92

		trust?: RemoteTrustOption;
93 94
	}

95
	export interface TunnelOptions {
R
rebornix 已提交
96
		remoteAddress: { port: number, host: string; };
A
Alex Ross 已提交
97 98 99
		// The desired local port. If this port can't be used, then another will be chosen.
		localAddressPort?: number;
		label?: string;
100
		public?: boolean;
101 102
	}

A
Alex Ross 已提交
103
	export interface TunnelDescription {
R
rebornix 已提交
104
		remoteAddress: { port: number, host: string; };
A
Alex Ross 已提交
105
		//The complete local address(ex. localhost:1234)
R
rebornix 已提交
106
		localAddress: { port: number, host: string; } | string;
107
		public?: boolean;
A
Alex Ross 已提交
108 109 110
	}

	export interface Tunnel extends TunnelDescription {
A
Alex Ross 已提交
111 112
		// Implementers of Tunnel should fire onDidDispose when dispose is called.
		onDidDispose: Event<void>;
113
		dispose(): void | Thenable<void>;
114 115 116
	}

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

128 129
	}

130
	export interface TunnelCreationOptions {
131 132 133 134 135 136
		/**
		 * True when the local operating system will require elevation to use the requested local port.
		 */
		elevationRequired?: boolean;
	}

137 138 139 140 141 142
	export enum CandidatePortSource {
		None = 0,
		Process = 1,
		Output = 2
	}

143
	export type ResolverResult = ResolvedAuthority & ResolvedOptions & TunnelInformation;
144

A
Tweaks  
Alex Dima 已提交
145 146 147 148 149 150 151
	export class RemoteAuthorityResolverError extends Error {
		static NotAvailable(message?: string, handled?: boolean): RemoteAuthorityResolverError;
		static TemporarilyNotAvailable(message?: string): RemoteAuthorityResolverError;

		constructor(message?: string);
	}

A
Alex Dima 已提交
152
	export interface RemoteAuthorityResolver {
153
		resolve(authority: string, context: RemoteAuthorityResolverContext): ResolverResult | Thenable<ResolverResult>;
154 155 156 157
		/**
		 * 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.
158 159 160
		 *
		 * 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.
161
		 */
162
		tunnelFactory?: (tunnelOptions: TunnelOptions, tunnelCreationOptions: TunnelCreationOptions) => Thenable<Tunnel> | undefined;
163

164
		/**p
165 166 167
		 * Provides filtering for candidate ports.
		 */
		showCandidatePort?: (host: string, port: number, detail: string) => Thenable<boolean>;
168 169 170 171 172 173 174

		/**
		 * Lets the resolver declare which tunnel factory features it supports.
		 * UNDER DISCUSSION! MAY CHANGE SOON.
		 */
		tunnelFeatures?: {
			elevation: boolean;
175
			public: boolean;
176
		};
177 178

		candidatePortSource?: CandidatePortSource;
179 180 181 182
	}

	export namespace workspace {
		/**
183
		 * Forwards a port. If the current resolver implements RemoteAuthorityResolver:forwardPort then that will be used to make the tunnel.
A
Alex Ross 已提交
184
		 * By default, openTunnel only support localhost; however, RemoteAuthorityResolver:tunnelFactory can be used to support other ips.
185 186 187
		 *
		 * @throws When run in an environment without a remote.
		 *
A
Alex Ross 已提交
188
		 * @param tunnelOptions The `localPort` is a suggestion only. If that port is not available another will be chosen.
189
		 */
A
Alex Ross 已提交
190
		export function openTunnel(tunnelOptions: TunnelOptions): Thenable<Tunnel>;
191 192 193 194 195 196

		/**
		 * 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 已提交
197

198 199 200 201
		/**
		 * Fired when the list of tunnels has changed.
		 */
		export const onDidChangeTunnels: Event<void>;
A
Alex Dima 已提交
202 203
	}

204 205 206 207 208 209 210 211
	export interface ResourceLabelFormatter {
		scheme: string;
		authority?: string;
		formatting: ResourceLabelFormatting;
	}

	export interface ResourceLabelFormatting {
		label: string; // myLabel:/${path}
I
isidor 已提交
212
		// 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 已提交
213
		// eslint-disable-next-line vscode-dts-literal-or-types
214 215 216 217 218
		separator: '/' | '\\' | '';
		tildify?: boolean;
		normalizeDriveLetter?: boolean;
		workspaceSuffix?: string;
		authorityPrefix?: string;
219
		stripPathStartingSeparator?: boolean;
220 221
	}

A
Alex Dima 已提交
222 223
	export namespace workspace {
		export function registerRemoteAuthorityResolver(authorityPrefix: string, resolver: RemoteAuthorityResolver): Disposable;
224
		export function registerResourceLabelFormatter(formatter: ResourceLabelFormatter): Disposable;
225
	}
226

227 228
	//#endregion

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

231 232
	export interface WebviewEditorInset {
		readonly editor: TextEditor;
233 234
		readonly line: number;
		readonly height: number;
235 236 237
		readonly webview: Webview;
		readonly onDidDispose: Event<void>;
		dispose(): void;
238 239
	}

240
	export namespace window {
241
		export function createWebviewTextEditorInset(editor: TextEditor, line: number, height: number, options?: WebviewOptions): WebviewEditorInset;
A
Alex Dima 已提交
242 243 244 245
	}

	//#endregion

J
Johannes Rieken 已提交
246
	//#region read/write in chunks: https://github.com/microsoft/vscode/issues/84515
247 248

	export interface FileSystemProvider {
R
rebornix 已提交
249
		open?(resource: Uri, options: { create: boolean; }): number | Thenable<number>;
250 251 252 253 254 255 256
		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 已提交
257
	//#region TextSearchProvider: https://github.com/microsoft/vscode/issues/59921
258

259 260 261
	/**
	 * The parameters of a query for text search.
	 */
262
	export interface TextSearchQuery {
263 264 265
		/**
		 * The text pattern to search for.
		 */
266
		pattern: string;
267

R
Rob Lourens 已提交
268 269 270 271 272
		/**
		 * Whether or not `pattern` should match multiple lines of text.
		 */
		isMultiline?: boolean;

273 274 275
		/**
		 * Whether or not `pattern` should be interpreted as a regular expression.
		 */
R
Rob Lourens 已提交
276
		isRegExp?: boolean;
277 278 279 280

		/**
		 * Whether or not the search should be case-sensitive.
		 */
R
Rob Lourens 已提交
281
		isCaseSensitive?: boolean;
282 283 284 285

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

289 290
	/**
	 * A file glob pattern to match file paths against.
291
	 * TODO@roblourens merge this with the GlobPattern docs/definition in vscode.d.ts.
292 293 294 295 296 297 298
	 * @see [GlobPattern](#GlobPattern)
	 */
	export type GlobString = string;

	/**
	 * Options common to file and text search
	 */
R
Rob Lourens 已提交
299
	export interface SearchOptions {
300 301 302
		/**
		 * The root folder to search within.
		 */
303
		folder: Uri;
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318

		/**
		 * 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 已提交
319
		useIgnoreFiles: boolean;
320 321 322 323 324

		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
325
		followSymlinks: boolean;
P
pkoushik 已提交
326 327 328 329 330 331

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

R
Rob Lourens 已提交
334 335
	/**
	 * Options to specify the size of the result text preview.
R
Rob Lourens 已提交
336
	 * These options don't affect the size of the match itself, just the amount of preview text.
R
Rob Lourens 已提交
337
	 */
338
	export interface TextSearchPreviewOptions {
339
		/**
R
Rob Lourens 已提交
340
		 * The maximum number of lines in the preview.
R
Rob Lourens 已提交
341
		 * Only search providers that support multiline search will ever return more than one line in the match.
342
		 */
R
Rob Lourens 已提交
343
		matchLines: number;
R
Rob Lourens 已提交
344 345 346 347

		/**
		 * The maximum number of characters included per line.
		 */
R
Rob Lourens 已提交
348
		charsPerLine: number;
349 350
	}

351 352 353
	/**
	 * Options that apply to text search.
	 */
R
Rob Lourens 已提交
354
	export interface TextSearchOptions extends SearchOptions {
355
		/**
356
		 * The maximum number of results to be returned.
357
		 */
358 359
		maxResults: number;

R
Rob Lourens 已提交
360 361 362
		/**
		 * Options to specify the size of the result text preview.
		 */
363
		previewOptions?: TextSearchPreviewOptions;
364 365 366 367

		/**
		 * Exclude files larger than `maxFileSize` in bytes.
		 */
368
		maxFileSize?: number;
369 370 371 372 373

		/**
		 * Interpret files using this encoding.
		 * See the vscode setting `"files.encoding"`
		 */
374
		encoding?: string;
375 376 377 378 379 380 381 382 383 384

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

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

387 388 389 390 391 392 393 394 395 396 397 398 399 400
	/**
	 * Information collected when text search is complete.
	 */
	export interface TextSearchComplete {
		/**
		 * Whether the search hit the limit on the maximum number of search results.
		 * `maxResults` on [`TextSearchOptions`](#TextSearchOptions) specifies the max number of results.
		 * - 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;
	}

R
Rob Lourens 已提交
401 402 403
	/**
	 * A preview of the text result.
	 */
404
	export interface TextSearchMatchPreview {
405
		/**
R
Rob Lourens 已提交
406
		 * The matching lines of text, or a portion of the matching line that contains the match.
407 408 409 410 411
		 */
		text: string;

		/**
		 * The Range within `text` corresponding to the text of the match.
412
		 * The number of matches must match the TextSearchMatch's range property.
413
		 */
414
		matches: Range | Range[];
415 416 417 418 419
	}

	/**
	 * A match from a text search
	 */
420
	export interface TextSearchMatch {
421 422 423
		/**
		 * The uri for the matching document.
		 */
424
		uri: Uri;
425 426

		/**
427
		 * The range of the match within the document, or multiple ranges for multiple matches.
428
		 */
429
		ranges: Range | Range[];
R
Rob Lourens 已提交
430

431
		/**
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
		 * 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.
454
		 */
455
		lineNumber: number;
456 457
	}

458 459
	export type TextSearchResult = TextSearchMatch | TextSearchContext;

R
Rob Lourens 已提交
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 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 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;
	}

504
	/**
R
Rob Lourens 已提交
505 506 507 508 509 510 511
	 * 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.
	 *
	 * A FileSearchProvider is the more powerful of two ways to implement file search in VS Code. Use a FileSearchProvider if you wish to search within a folder for
	 * 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.
512
	 */
513
	export interface FileSearchProvider {
514 515 516 517 518 519
		/**
		 * 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.
		 */
520
		provideFileSearchResults(query: FileSearchQuery, options: FileSearchOptions, token: CancellationToken): ProviderResult<Uri[]>;
521
	}
522

R
Rob Lourens 已提交
523
	export namespace workspace {
524
		/**
R
Rob Lourens 已提交
525 526 527 528 529 530 531
		 * 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.
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
532
		 */
R
Rob Lourens 已提交
533 534 535 536 537 538 539 540 541 542 543 544
		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.
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
		 */
		export function registerTextSearchProvider(scheme: string, provider: TextSearchProvider): Disposable;
545 546
	}

R
Rob Lourens 已提交
547 548 549 550
	//#endregion

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

551 552 553
	/**
	 * Options that can be set on a findTextInFiles search.
	 */
R
Rob Lourens 已提交
554
	export interface FindTextInFilesOptions {
555 556 557 558 559
		/**
		 * A [glob pattern](#GlobPattern) 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 [relative pattern](#RelativePattern)
		 * to restrict the search results to a [workspace folder](#WorkspaceFolder).
		 */
560
		include?: GlobPattern;
561 562 563

		/**
		 * A [glob pattern](#GlobPattern) that defines files and folders to exclude. The glob pattern
564 565
		 * will be matched against the file paths of resulting matches relative to their workspace. When `undefined`, default excludes will
		 * apply.
566
		 */
567 568 569 570
		exclude?: GlobPattern;

		/**
		 * Whether to use the default and user-configured excludes. Defaults to true.
571
		 */
572
		useDefaultExcludes?: boolean;
573 574 575 576

		/**
		 * The maximum number of results to search for
		 */
R
Rob Lourens 已提交
577
		maxResults?: number;
578 579 580 581 582

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

P
pkoushik 已提交
585 586 587 588
		/**
		 * Whether global files that exclude files, like .gitignore, should be respected.
		 * See the vscode setting `"search.useGlobalIgnoreFiles"`.
		 */
589
		useGlobalIgnoreFiles?: boolean;
P
pkoushik 已提交
590

591 592 593 594
		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
595
		followSymlinks?: boolean;
596 597 598 599 600

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

R
Rob Lourens 已提交
603 604 605
		/**
		 * Options to specify the size of the result text preview.
		 */
606
		previewOptions?: TextSearchPreviewOptions;
607 608 609 610 611 612 613 614 615 616

		/**
		 * 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 已提交
617 618
	}

619
	export namespace workspace {
620 621 622 623 624 625 626
		/**
		 * Search text in files across all [workspace folders](#workspace.workspaceFolders) in the workspace.
		 * @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.
		 */
627
		export function findTextInFiles(query: TextSearchQuery, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
628 629 630 631 632 633 634 635 636

		/**
		 * Search text in files across all [workspace folders](#workspace.workspaceFolders) in the workspace.
		 * @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.
		 */
637
		export function findTextInFiles(query: TextSearchQuery, options: FindTextInFilesOptions, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
638 639
	}

J
Johannes Rieken 已提交
640
	//#endregion
641

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

J
Joao Moreno 已提交
644 645 646
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
647 648 649 650 651 652 653
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
	export namespace commands {

		/**
		 * Registers a diff information command that can be invoked via a keyboard shortcut,
		 * a menu item, an action, or directly.
		 *
		 * Diff information commands are different from ordinary [commands](#commands.registerCommand) as
		 * 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.
		 * @param callback A command handler function with access to the [diff information](#LineChange).
		 * @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;
	}
672

J
Johannes Rieken 已提交
673 674
	//#endregion

675
	// eslint-disable-next-line vscode-dts-region-comments
676
	//#region @weinand: variables view action contributions
677

678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693
	/**
	 * 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 已提交
694 695
	//#endregion

696
	// eslint-disable-next-line vscode-dts-region-comments
697
	//#region @joaomoreno: SCM validation
698

J
Joao Moreno 已提交
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737
	/**
	 * 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 {

738 739 740 741 742
		/**
		 * Shows a transient contextual message on the input.
		 */
		showValidationMessage(message: string, type: SourceControlInputBoxValidationType): void;

J
Joao Moreno 已提交
743 744 745 746
		/**
		 * A validation function for the input box. It's possible to change
		 * the validation provider simply by setting this property to a different function.
		 */
747
		validateInput?(value: string, cursorPosition: number): ProviderResult<SourceControlInputBoxValidation>;
J
Joao Moreno 已提交
748
	}
M
Matt Bierner 已提交
749

J
Johannes Rieken 已提交
750 751
	//#endregion

752
	// eslint-disable-next-line vscode-dts-region-comments
753
	//#region @joaomoreno: SCM selected provider
754 755 756 757 758 759 760 761 762 763 764 765

	export interface SourceControl {

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

		/**
		 * An event signaling when the selection state changes.
		 */
		readonly onDidChangeSelection: Event<boolean>;
766 767 768 769
	}

	//#endregion

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

772 773 774 775 776 777 778 779 780 781 782
	export interface TerminalDataWriteEvent {
		/**
		 * The [terminal](#Terminal) for which the data was written.
		 */
		readonly terminal: Terminal;
		/**
		 * The data being written.
		 */
		readonly data: string;
	}

D
Daniel Imms 已提交
783 784
	namespace window {
		/**
D
Daniel Imms 已提交
785 786 787
		 * 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 已提交
788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808
		 */
		export const onDidWriteTerminalData: Event<TerminalDataWriteEvent>;
	}

	//#endregion

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

	/**
	 * An [event](#Event) which fires when a [Terminal](#Terminal)'s dimensions change.
	 */
	export interface TerminalDimensionsChangeEvent {
		/**
		 * The [terminal](#Terminal) for which the dimensions have changed.
		 */
		readonly terminal: Terminal;
		/**
		 * The new value for the [terminal's dimensions](#Terminal.dimensions).
		 */
		readonly dimensions: TerminalDimensions;
	}
809

D
Daniel Imms 已提交
810
	export namespace window {
D
Daniel Imms 已提交
811 812 813 814 815 816 817
		/**
		 * An event which fires when the [dimensions](#Terminal.dimensions) of the terminal change.
		 */
		export const onDidChangeTerminalDimensions: Event<TerminalDimensionsChangeEvent>;
	}

	export interface Terminal {
818
		/**
819 820 821
		 * 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.
822
		 */
823
		readonly dimensions: TerminalDimensions | undefined;
D
Daniel Imms 已提交
824 825
	}

826 827
	//#endregion

D
Daniel Imms 已提交
828 829 830 831
	//#region Terminal initial text https://github.com/microsoft/vscode/issues/120368

	export interface TerminalOptions {
		/**
D
Daniel Imms 已提交
832 833 834
		 * A message to write to the terminal on first launch, note that this is not sent to the
		 * process but, rather written directly to the terminal. This supports escape sequences such
		 * a setting text style.
D
Daniel Imms 已提交
835
		 */
D
Daniel Imms 已提交
836
		readonly message?: string;
D
Daniel Imms 已提交
837 838 839 840
	}

	//#endregion

D
Daniel Imms 已提交
841 842 843 844 845 846 847 848 849 850 851
	//#region Terminal icon https://github.com/microsoft/vscode/issues/120538

	export interface TerminalOptions {
		/**
		 * A codicon ID to associate with this terminal.
		 */
		readonly icon?: string;
	}

	//#endregion

852
	// eslint-disable-next-line vscode-dts-region-comments
853
	//#region @jrieken -> exclusive document filters
854 855

	export interface DocumentFilter {
856
		readonly exclusive?: boolean;
857 858 859
	}

	//#endregion
C
Christof Marti 已提交
860

861
	//#region Tree View: https://github.com/microsoft/vscode/issues/61313 @alexr00
862
	export interface TreeView<T> extends Disposable {
863
		reveal(element: T | undefined, options?: { select?: boolean, focus?: boolean, expand?: boolean | number; }): Thenable<void>;
864
	}
865
	//#endregion
866

867
	//#region Task presentation group: https://github.com/microsoft/vscode/issues/47265
868 869 870 871 872 873 874
	export interface TaskPresentationOptions {
		/**
		 * Controls whether the task is executed in a specific terminal group using split panes.
		 */
		group?: string;
	}
	//#endregion
875

876
	//#region Status bar item with ID and Name: https://github.com/microsoft/vscode/issues/74972
877

B
Benjamin Pasero 已提交
878 879 880 881 882 883 884 885 886 887 888
	/**
	 * Options to configure the status bar item.
	 */
	export interface StatusBarItemOptions {

		/**
		 * A unique identifier of the status bar item. The identifier
		 * is for example used to allow a user to show or hide the
		 * status bar item in the UI.
		 */
		id: string;
889 890

		/**
B
Benjamin Pasero 已提交
891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914
		 * A human readable name of the status bar item. The name is
		 * for example used as a label in the UI to show or hide the
		 * status bar item.
		 */
		name: string;

		/**
		 * Accessibility information used when screen reader interacts with this status bar item.
		 */
		accessibilityInformation?: AccessibilityInformation;

		/**
		 * The alignment of the status bar item.
		 */
		alignment?: StatusBarAlignment;

		/**
		 * The priority of the status bar item. Higher value means the item should
		 * be shown more to the left.
		 */
		priority?: number;
	}

	export namespace window {
915 916 917 918 919 920 921 922 923 924 925 926 927

		/**
		 * Creates a status bar [item](#StatusBarItem).
		 *
		 * @param options The options of the item. If not provided, some default values
		 * will be assumed. For example, the `StatusBarItemOptions.id` will be the id
		 * of the extension and the `StatusBarItemOptions.name` will be the extension name.
		 * @return A new status bar item.
		 */
		export function createStatusBarItem(options?: StatusBarItemOptions): StatusBarItem;
	}

	//#endregion
928

929
	//#region Custom editor move https://github.com/microsoft/vscode/issues/86146
930

931
	// TODO: Also for custom editor
932

933
	export interface CustomTextEditorProvider {
M
Matt Bierner 已提交
934

935 936 937 938 939 940 941 942
		/**
		 * 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,
		 * VS Code will destory the previous custom editor and create a replacement one.
		 *
		 * @param newDocument New text document to use for the custom editor.
		 * @param existingWebviewPanel Webview panel for the custom editor.
943
		 * @param token A cancellation token that indicates the result is no longer needed.
944 945 946
		 *
		 * @return Thenable indicating that the webview editor has been moved.
		 */
J
Johannes Rieken 已提交
947
		// eslint-disable-next-line vscode-dts-provider-naming
948
		moveCustomTextEditor?(newDocument: TextDocument, existingWebviewPanel: WebviewPanel, token: CancellationToken): Thenable<void>;
949 950 951
	}

	//#endregion
952

J
Johannes Rieken 已提交
953
	//#region allow QuickPicks to skip sorting: https://github.com/microsoft/vscode/issues/73904
P
Peter Elmers 已提交
954 955 956

	export interface QuickPick<T extends QuickPickItem> extends QuickInput {
		/**
957 958
		 * An optional flag to sort the final results by index of first query match in label. Defaults to true.
		 */
P
Peter Elmers 已提交
959 960 961 962
		sortByLabel: boolean;
	}

	//#endregion
M
Matt Bierner 已提交
963

964
	//#region https://github.com/microsoft/vscode/issues/106744, Notebooks (misc)
R
rebornix 已提交
965

966
	export enum NotebookCellKind {
R
rebornix 已提交
967 968 969 970
		Markdown = 1,
		Code = 2
	}

971
	export class NotebookCellMetadata {
972
		/**
R
rebornix 已提交
973
		 * Whether a code cell's editor is collapsed
974
		 */
975
		readonly inputCollapsed?: boolean;
R
rebornix 已提交
976 977

		/**
R
rebornix 已提交
978
		 * Whether a code cell's outputs are collapsed
R
rebornix 已提交
979 980 981
		 */
		readonly outputCollapsed?: boolean;

R
rebornix 已提交
982
		/**
R
rebornix 已提交
983
		 * @deprecated
R
rebornix 已提交
984 985
		 * Additional attributes of a cell metadata.
		 */
986 987
		readonly custom?: Record<string, any>;

R
rebornix 已提交
988 989 990 991 992
		/**
		 * Additional attributes of a cell metadata.
		 */
		readonly [key: string]: any;

R
rebornix 已提交
993
		constructor(inputCollapsed?: boolean, outputCollapsed?: boolean, custom?: Record<string, any>);
994

R
rebornix 已提交
995
		with(change: { inputCollapsed?: boolean | null, outputCollapsed?: boolean | null, custom?: Record<string, any> | null, [key: string]: any }): NotebookCellMetadata;
R
Rob Lourens 已提交
996
	}
997

R
Rob Lourens 已提交
998
	export interface NotebookCellExecutionSummary {
999 1000 1001 1002
		readonly executionOrder?: number;
		readonly success?: boolean;
		readonly startTime?: number;
		readonly endTime?: number;
R
rebornix 已提交
1003 1004
	}

1005
	// todo@API support ids https://github.com/jupyter/enhancement-proposals/blob/master/62-cell-id/cell-id.md
R
rebornix 已提交
1006
	export interface NotebookCell {
1007
		readonly index: number;
1008
		readonly notebook: NotebookDocument;
J
Johannes Rieken 已提交
1009
		readonly kind: NotebookCellKind;
J
Johannes Rieken 已提交
1010
		readonly document: TextDocument;
1011
		readonly metadata: NotebookCellMetadata
J
Johannes Rieken 已提交
1012
		readonly outputs: ReadonlyArray<NotebookCellOutput>;
R
Rob Lourens 已提交
1013
		readonly latestExecutionSummary: NotebookCellExecutionSummary | undefined;
R
rebornix 已提交
1014 1015
	}

1016
	export class NotebookDocumentMetadata {
R
rebornix 已提交
1017
		/**
R
rebornix 已提交
1018
		 * @deprecated
1019
		 * Additional attributes of the document metadata.
R
rebornix 已提交
1020
		 */
1021
		readonly custom: { [key: string]: any; };
R
rebornix 已提交
1022 1023 1024 1025
		/**
		 * Whether the document is trusted, default to true
		 * When false, insecure outputs like HTML, JavaScript, SVG will not be rendered.
		 */
1026 1027
		readonly trusted: boolean;

R
rebornix 已提交
1028 1029 1030 1031 1032 1033
		/**
		 * Additional attributes of the document metadata.
		 */
		readonly [key: string]: any;

		constructor(trusted?: boolean, custom?: { [key: string]: any; });
1034

R
rebornix 已提交
1035
		with(change: { trusted?: boolean | null, custom?: { [key: string]: any; } | null, [key: string]: any }): NotebookDocumentMetadata
R
rebornix 已提交
1036 1037
	}

R
rebornix 已提交
1038 1039 1040 1041 1042
	export interface NotebookDocumentContentOptions {
		/**
		 * Controls if outputs change will trigger notebook document content change and if it will be used in the diff editor
		 * Default to false. If the content provider doesn't persisit the outputs in the file document, this should be set to true.
		 */
1043
		transientOutputs?: boolean;
R
rebornix 已提交
1044 1045

		/**
1046
		 * @deprecated use transientCellMetadata instead
R
rebornix 已提交
1047
		 */
1048
		transientMetadata?: { [K in keyof NotebookCellMetadata]?: boolean };
1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060

		/**
		 * Controls if a cell metadata property change will trigger notebook document content change and if it will be used in the diff editor
		 * Default to false. If the content provider doesn't persisit a metadata property in the file document, it should be set to true.
		 */
		transientCellMetadata?: { [K in keyof NotebookCellMetadata]?: boolean };

		/**
		* Controls if a document metadata property change will trigger notebook document content change and if it will be used in the diff editor
		* Default to false. If the content provider doesn't persisit a metadata property in the file document, it should be set to true.
		*/
		transientDocumentMetadata?: { [K in keyof NotebookDocumentMetadata]?: boolean };
R
rebornix 已提交
1061 1062
	}

1063 1064 1065 1066 1067 1068 1069 1070 1071
	export interface NotebookDocumentContentOptions {
		/**
		 * Not ready for production or development use yet.
		 */
		viewOptions?: {
			displayName: string;
			filenamePattern: NotebookFilenamePattern[];
			exclusive?: boolean;
		};
R
rebornix 已提交
1072 1073
	}

1074 1075 1076
	/**
	 * Represents a notebook. Notebooks are composed of cells and metadata.
	 */
R
rebornix 已提交
1077
	export interface NotebookDocument {
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087

		/**
		 * The associated uri for this notebook.
		 *
		 * *Note* that most notebooks use the `file`-scheme, which means they are files on disk. However, **not** all notebooks are
		 * saved on disk and therefore the `scheme` must be checked before trying to access the underlying file or siblings on disk.
		 *
		 * @see [FileSystemProvider](#FileSystemProvider)
		 * @see [TextDocumentContentProvider](#TextDocumentContentProvider)
		 */
R
rebornix 已提交
1088
		readonly uri: Uri;
1089 1090 1091 1092 1093 1094 1095 1096

		// todo@API should we really expose this?
		readonly viewType: string;

		/**
		 * The version number of this notebook (it will strictly increase after each
		 * change, including undo/redo).
		 */
1097
		readonly version: number;
1098

1099 1100 1101
		/**
		 * `true` if there are unpersisted changes.
		 */
R
rebornix 已提交
1102
		readonly isDirty: boolean;
1103 1104 1105 1106

		/**
		 * Is this notebook representing an untitled file which has not been saved yet.
		 */
R
rebornix 已提交
1107
		readonly isUntitled: boolean;
1108

1109 1110 1111 1112 1113
		/**
		 * `true` if the notebook has been closed. A closed notebook isn't synchronized anymore
		 * and won't be re-used when the same resource is opened again.
		 */
		readonly isClosed: boolean;
1114

1115 1116 1117
		/**
		 * The [metadata](#NotebookDocumentMetadata) for this notebook.
		 */
R
rebornix 已提交
1118
		readonly metadata: NotebookDocumentMetadata;
R
rebornix 已提交
1119

1120
		/**
1121
		 * The number of cells in the notebook.
1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132
		 */
		readonly cellCount: number;

		/**
		 * Return the cell at the specified index. The index will be adjusted to the notebook.
		 *
		 * @param index - The index of the cell to retrieve.
		 * @return A [cell](#NotebookCell).
		 */
		cellAt(index: number): NotebookCell;

1133 1134 1135 1136 1137 1138 1139
		/**
		 * Get the cells of this notebook. A subset can be retrieved by providing
		 * a range. The range will be adjuset to the notebook.
		 *
		 * @param range A notebook range.
		 * @returns The cells contained by the range or all cells.
		 */
1140
		getCells(range?: NotebookRange): NotebookCell[];
1141

R
rebornix 已提交
1142 1143 1144 1145 1146 1147 1148 1149
		/**
		 * Save the document. The saving will be handled by the corresponding content provider
		 *
		 * @return A promise that will resolve to true when the document
		 * has been saved. If the file was not dirty or the save failed,
		 * will return false.
		 */
		save(): Thenable<boolean>;
R
rebornix 已提交
1150 1151
	}

1152 1153 1154 1155
	/**
	 * A notebook range represents on ordered pair of two cell indicies.
	 * It is guaranteed that start is less than or equal to end.
	 */
1156
	export class NotebookRange {
1157 1158 1159 1160

		/**
		 * The zero-based start index of this range.
		 */
1161
		readonly start: number;
1162

R
rebornix 已提交
1163
		/**
1164
		 * The exclusive end index of this range (zero-based).
R
rebornix 已提交
1165
		 */
1166
		readonly end: number;
1167

1168 1169 1170
		/**
		 * `true` if `start` and `end` are equals
		 */
J
Johannes Rieken 已提交
1171
		readonly isEmpty: boolean;
1172

1173 1174 1175 1176 1177 1178 1179
		/**
		 * Create a new notebook range. If `start` is not
		 * before or equal to `end`, the values will be swapped.
		 *
		 * @param start start index
		 * @param end end index.
		 */
1180
		constructor(start: number, end: number);
1181

1182 1183 1184 1185 1186 1187 1188
		/**
		 * Derive a new range for this range.
		 *
		 * @param change An object that describes a change to this range.
		 * @return A range that reflects the given change. Will return `this` range if the change
		 * is not changing anything.
		 */
1189
		with(change: { start?: number, end?: number }): NotebookRange;
1190 1191
	}

R
rebornix 已提交
1192 1193 1194 1195 1196 1197 1198 1199 1200
	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,
R
rebornix 已提交
1201

R
rebornix 已提交
1202 1203 1204 1205 1206
		/**
		 * 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,
R
rebornix 已提交
1207 1208 1209 1210 1211

		/**
		 * The range will always be revealed at the top of the viewport.
		 */
		AtTop = 3
R
rebornix 已提交
1212 1213
	}

R
rebornix 已提交
1214
	export interface NotebookEditor {
R
rebornix 已提交
1215 1216 1217
		/**
		 * The document associated with this notebook editor.
		 */
R
rebornix 已提交
1218
		readonly document: NotebookDocument;
R
rebornix 已提交
1219 1220

		/**
R
rebornix 已提交
1221 1222 1223 1224
		 * 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 }`;
		 */
1225
		readonly selections: NotebookRange[];
J
Johannes Rieken 已提交
1226

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

R
rebornix 已提交
1232 1233 1234 1235 1236 1237
		/**
		 * Scroll as indicated by `revealType` in order to reveal the given range.
		 *
		 * @param range A range.
		 * @param revealType The scrolling strategy for revealing `range`.
		 */
1238
		revealRange(range: NotebookRange, revealType?: NotebookEditorRevealType): void;
1239

R
rebornix 已提交
1240 1241 1242
		/**
		 * The column in which this editor shows.
		 */
J
Johannes Rieken 已提交
1243
		readonly viewColumn?: ViewColumn;
R
rebornix 已提交
1244 1245
	}

1246
	export interface NotebookDocumentMetadataChangeEvent {
R
rebornix 已提交
1247 1248 1249
		/**
		 * The [notebook document](#NotebookDocument) for which the document metadata have changed.
		 */
1250 1251 1252
		readonly document: NotebookDocument;
	}

1253
	export interface NotebookCellsChangeData {
R
rebornix 已提交
1254
		readonly start: number;
J
Johannes Rieken 已提交
1255
		// todo@API end? Use NotebookCellRange instead?
R
rebornix 已提交
1256
		readonly deletedCount: number;
J
Johannes Rieken 已提交
1257
		// todo@API removedCells, deletedCells?
1258
		readonly deletedItems: NotebookCell[];
J
Johannes Rieken 已提交
1259
		// todo@API addedCells, insertedCells, newCells?
R
rebornix 已提交
1260
		readonly items: NotebookCell[];
R
rebornix 已提交
1261 1262
	}

R
rebornix 已提交
1263
	export interface NotebookCellsChangeEvent {
R
rebornix 已提交
1264
		/**
R
rebornix 已提交
1265
		 * The [notebook document](#NotebookDocument) for which the cells have changed.
R
rebornix 已提交
1266 1267
		 */
		readonly document: NotebookDocument;
1268
		readonly changes: ReadonlyArray<NotebookCellsChangeData>;
R
rebornix 已提交
1269 1270
	}

1271
	export interface NotebookCellOutputsChangeEvent {
R
rebornix 已提交
1272
		/**
R
rebornix 已提交
1273
		 * The [notebook document](#NotebookDocument) for which the cell outputs have changed.
R
rebornix 已提交
1274 1275
		 */
		readonly document: NotebookDocument;
1276
		readonly cells: NotebookCell[];
R
rebornix 已提交
1277 1278
	}

1279
	export interface NotebookCellMetadataChangeEvent {
R
rebornix 已提交
1280 1281 1282
		/**
		 * The [notebook document](#NotebookDocument) for which the cell metadata have changed.
		 */
1283 1284
		readonly document: NotebookDocument;
		readonly cell: NotebookCell;
R
rebornix 已提交
1285 1286
	}

1287
	export interface NotebookEditorSelectionChangeEvent {
R
rebornix 已提交
1288 1289 1290
		/**
		 * The [notebook editor](#NotebookEditor) for which the selections have changed.
		 */
1291
		readonly notebookEditor: NotebookEditor;
1292
		readonly selections: ReadonlyArray<NotebookRange>
1293 1294
	}

1295
	export interface NotebookEditorVisibleRangesChangeEvent {
R
rebornix 已提交
1296 1297 1298
		/**
		 * The [notebook editor](#NotebookEditor) for which the visible ranges have changed.
		 */
1299
		readonly notebookEditor: NotebookEditor;
1300
		readonly visibleRanges: ReadonlyArray<NotebookRange>;
1301 1302
	}

R
Rob Lourens 已提交
1303
	export interface NotebookCellExecutionStateChangeEvent {
R
rebornix 已提交
1304 1305 1306
		/**
		 * The [notebook document](#NotebookDocument) for which the cell execution state has changed.
		 */
R
Rob Lourens 已提交
1307 1308 1309 1310 1311
		readonly document: NotebookDocument;
		readonly cell: NotebookCell;
		readonly executionState: NotebookCellExecutionState;
	}

1312
	// todo@API support ids https://github.com/jupyter/enhancement-proposals/blob/master/62-cell-id/cell-id.md
1313 1314 1315 1316 1317 1318 1319 1320
	export class NotebookCellData {
		kind: NotebookCellKind;
		// todo@API better names: value? text?
		source: string;
		// todo@API how does language and MD relate?
		language: string;
		outputs?: NotebookCellOutput[];
		metadata?: NotebookCellMetadata;
R
Rob Lourens 已提交
1321 1322
		latestExecutionSummary?: NotebookCellExecutionSummary;
		constructor(kind: NotebookCellKind, source: string, language: string, outputs?: NotebookCellOutput[], metadata?: NotebookCellMetadata, latestExecutionSummary?: NotebookCellExecutionSummary);
1323 1324 1325 1326
	}

	export class NotebookData {
		cells: NotebookCellData[];
1327
		metadata: NotebookDocumentMetadata;
1328
		constructor(cells: NotebookCellData[], metadata?: NotebookDocumentMetadata);
R
rebornix 已提交
1329 1330
	}

1331 1332 1333 1334
	export interface NotebookDocumentShowOptions {
		viewColumn?: ViewColumn;
		preserveFocus?: boolean;
		preview?: boolean;
1335
		selections?: NotebookRange[];
1336 1337 1338 1339
	}

	export namespace notebook {

1340 1341
		export function openNotebookDocument(uri: Uri): Thenable<NotebookDocument>;

1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353
		export const onDidOpenNotebookDocument: Event<NotebookDocument>;
		export const onDidCloseNotebookDocument: Event<NotebookDocument>;

		export const onDidSaveNotebookDocument: Event<NotebookDocument>;

		/**
		 * All currently known notebook documents.
		 */
		export const notebookDocuments: ReadonlyArray<NotebookDocument>;
		export const onDidChangeNotebookDocumentMetadata: Event<NotebookDocumentMetadataChangeEvent>;
		export const onDidChangeNotebookCells: Event<NotebookCellsChangeEvent>;
		export const onDidChangeCellOutputs: Event<NotebookCellOutputsChangeEvent>;
J
Johannes Rieken 已提交
1354

1355 1356 1357 1358 1359 1360 1361 1362 1363 1364
		export const onDidChangeCellMetadata: Event<NotebookCellMetadataChangeEvent>;
	}

	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>;
1365 1366

		export function showNotebookDocument(uri: Uri, options?: NotebookDocumentShowOptions): Thenable<NotebookEditor>;
1367 1368 1369 1370 1371 1372 1373
		export function showNotebookDocument(document: NotebookDocument, options?: NotebookDocumentShowOptions): Thenable<NotebookEditor>;
	}

	//#endregion

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

1374 1375
	// code specific mime types
	// application/x.notebook.error-traceback
1376 1377
	// application/x.notebook.stdout
	// application/x.notebook.stderr
1378
	// application/x.notebook.stream
1379 1380
	export class NotebookCellOutputItem {

1381 1382 1383 1384 1385
		// todo@API
		// add factory functions for common mime types
		// static textplain(value:string): NotebookCellOutputItem;
		// static errortrace(value:any): NotebookCellOutputItem;

1386 1387
		readonly mime: string;
		readonly value: unknown;
1388
		readonly metadata?: Record<string, any>;
1389

1390
		constructor(mime: string, value: unknown, metadata?: Record<string, any>);
1391 1392
	}

1393
	// @jrieken
J
Johannes Rieken 已提交
1394
	// todo@API think about readonly...
1395
	//TODO@API add execution count to cell output?
1396
	export class NotebookCellOutput {
1397
		readonly id: string;
1398
		readonly outputs: NotebookCellOutputItem[];
1399 1400 1401 1402 1403
		readonly metadata?: Record<string, any>;

		constructor(outputs: NotebookCellOutputItem[], metadata?: Record<string, any>);

		constructor(outputs: NotebookCellOutputItem[], id: string, metadata?: Record<string, any>);
1404 1405 1406 1407 1408 1409 1410 1411
	}

	//#endregion

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

	export interface WorkspaceEdit {
		replaceNotebookMetadata(uri: Uri, value: NotebookDocumentMetadata): void;
R
rebornix 已提交
1412
		replaceNotebookCells(uri: Uri, range: NotebookRange, cells: NotebookCellData[], metadata?: WorkspaceEditEntryMetadata): void;
1413
		replaceNotebookCellMetadata(uri: Uri, index: number, cellMetadata: NotebookCellMetadata, metadata?: WorkspaceEditEntryMetadata): void;
R
rebornix 已提交
1414 1415
		replaceNotebookCellOutput(uri: Uri, index: number, outputs: NotebookCellOutput[], metadata?: WorkspaceEditEntryMetadata): void;
		appendNotebookCellOutput(uri: Uri, index: number, outputs: NotebookCellOutput[], metadata?: WorkspaceEditEntryMetadata): void;
1416 1417 1418

		// TODO@api
		// https://jupyter-protocol.readthedocs.io/en/latest/messaging.html#update-display-data
R
rebornix 已提交
1419 1420
		replaceNotebookCellOutputItems(uri: Uri, index: number, outputId: string, items: NotebookCellOutputItem[], metadata?: WorkspaceEditEntryMetadata): void;
		appendNotebookCellOutputItems(uri: Uri, index: number, outputId: string, items: NotebookCellOutputItem[], metadata?: WorkspaceEditEntryMetadata): void;
1421 1422 1423 1424 1425
	}

	export interface NotebookEditorEdit {
		replaceMetadata(value: NotebookDocumentMetadata): void;
		replaceCells(start: number, end: number, cells: NotebookCellData[]): void;
R
rebornix 已提交
1426
		replaceCellOutput(index: number, outputs: NotebookCellOutput[]): void;
1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446
		replaceCellMetadata(index: number, metadata: NotebookCellMetadata): void;
	}

	export interface NotebookEditor {
		/**
		 * Perform an edit on the notebook associated with this notebook editor.
		 *
		 * The given callback-function is invoked with an [edit-builder](#NotebookEditorEdit) which must
		 * be used to make edits. Note that the edit-builder is only valid while the
		 * callback executes.
		 *
		 * @param callback A function which can create edits using an [edit-builder](#NotebookEditorEdit).
		 * @return A promise that resolves with a value indicating if the edits could be applied.
		 */
		// @jrieken REMOVE maybe
		edit(callback: (editBuilder: NotebookEditorEdit) => void): Thenable<boolean>;
	}

	//#endregion

1447 1448 1449
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookSerializer

	export interface NotebookSerializer {
1450 1451
		deserializeNotebook(data: Uint8Array, token: CancellationToken): NotebookData | Thenable<NotebookData>;
		serializeNotebook(data: NotebookData, token: CancellationToken): Uint8Array | Thenable<Uint8Array>;
1452 1453 1454 1455
	}

	export namespace notebook {

J
Johannes Rieken 已提交
1456
		// todo@API remove output when notebook marks that as transient, same for metadata
1457 1458 1459 1460 1461
		export function registerNotebookSerializer(notebookType: string, provider: NotebookSerializer, options?: NotebookDocumentContentOptions): Disposable;
	}

	//#endregion

1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472
	//#region https://github.com/microsoft/vscode/issues/119949


	export interface NotebookFilter {
		readonly viewType?: string;
		readonly scheme?: string;
		readonly pattern?: GlobPattern;
	}

	export type NotebookSelector = NotebookFilter | string | ReadonlyArray<NotebookFilter | string>;

1473 1474 1475 1476 1477
	export interface NotebookExecutionHandler {
		/**
		 * @param cells The notebook cells to execute
		 * @param controller The controller that the handler is attached to
		 */
1478
		(this: NotebookController, cells: NotebookCell[], controller: NotebookController): void | Thenable<void>
1479 1480 1481
	}

	export interface NotebookInterruptHandler {
1482
		(this: NotebookController): void | Thenable<void>;
1483 1484
	}

1485
	export interface NotebookController {
1486 1487 1488 1489 1490 1491

		readonly id: string;

		// select notebook of a type and/or by file-pattern
		readonly selector: NotebookSelector;

1492 1493 1494 1495 1496 1497
		/**
		 * A kernel can apply to one or many notebook documents but a notebook has only one active
		 * kernel. This event fires whenever a notebook has been associated to a kernel or when
		 * that association has been removed.
		 */
		readonly onDidChangeNotebookAssociation: Event<{ notebook: NotebookDocument, selected: boolean }>;
1498

1499 1500
		// UI properties (get/set)
		label: string;
J
Johannes Rieken 已提交
1501
		detail?: string;
1502
		description?: string;
1503 1504 1505
		isPreferred?: boolean;

		supportedLanguages: string[];
1506
		hasExecutionOrder?: boolean;
1507

J
Johannes Rieken 已提交
1508 1509 1510 1511
		/**
		 * The execute handler is invoked when the run gestures in the UI are selected, e.g Run Cell, Run All,
		 * Run Selection etc.
		 */
1512
		executeHandler: NotebookExecutionHandler;
1513 1514

		// optional kernel interrupt command
1515
		interruptHandler?: NotebookInterruptHandler
1516
		dispose(): void;
J
Johannes Rieken 已提交
1517 1518 1519 1520 1521 1522 1523 1524 1525 1526

		/**
		 * Manually create an execution task. This should only be used when cell execution
		 * has started before creating the kernel instance or when execution can be triggered
		 * from another source.
		 *
		 * @param cell The notebook cell for which to create the execution
		 * @returns A notebook cell execution.
		 */
		createNotebookCellExecutionTask(cell: NotebookCell): NotebookCellExecutionTask;
1527 1528

		// ipc
1529
		readonly preloads: NotebookKernelPreload[];
1530 1531
		readonly onDidReceiveMessage: Event<{ editor: NotebookEditor, message: any }>;
		postMessage(message: any, editor?: NotebookEditor): Thenable<boolean>;
1532
		asWebviewUri(localResource: Uri): Uri;
1533 1534
	}

1535
	export namespace notebook {
1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546

		/**
		 * Creates a new notebook controller.
		 *
		 * @param id Unique identifier of the controller
		 * @param selector A notebook selector to narrow down notebook type or path
		 * @param label The label of the controller
		 * @param handler
		 * @param preloads
		 */
		export function createNotebookController(id: string, selector: NotebookSelector, label: string, handler?: NotebookExecutionHandler, preloads?: NotebookKernelPreload[]): NotebookController;
1547 1548 1549 1550
	}

	//#endregion

1551 1552
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookContentProvider

1553

1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576
	interface NotebookDocumentBackup {
		/**
		 * Unique identifier for the backup.
		 *
		 * This id is passed back to your extension in `openNotebook` when opening a notebook editor from a backup.
		 */
		readonly id: string;

		/**
		 * Delete the current backup.
		 *
		 * This is called by VS Code when it is clear the current backup is no longer needed, such as when a new backup
		 * is made or when the file is saved.
		 */
		delete(): void;
	}

	interface NotebookDocumentBackupContext {
		readonly destination: Uri;
	}

	interface NotebookDocumentOpenContext {
		readonly backupId?: string;
1577
		readonly untitledDocumentData?: Uint8Array;
1578 1579
	}

1580
	// todo@API use openNotebookDOCUMENT to align with openCustomDocument etc?
J
Johannes Rieken 已提交
1581
	// todo@API rename to NotebookDocumentContentProvider
R
rebornix 已提交
1582
	export interface NotebookContentProvider {
1583

1584 1585
		readonly options?: NotebookDocumentContentOptions;
		readonly onDidChangeNotebookContentOptions?: Event<NotebookDocumentContentOptions>;
1586

1587 1588 1589 1590
		/**
		 * Content providers should always use [file system providers](#FileSystemProvider) to
		 * resolve the raw content for `uri` as the resouce is not necessarily a file on disk.
		 */
1591 1592
		openNotebook(uri: Uri, openContext: NotebookDocumentOpenContext, token: CancellationToken): NotebookData | Thenable<NotebookData>;

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

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

J
Johannes Rieken 已提交
1599
		// todo@API use NotebookData instead
1600
		backupNotebook(document: NotebookDocument, context: NotebookDocumentBackupContext, token: CancellationToken): Thenable<NotebookDocumentBackup>;
1601 1602 1603
	}

	export namespace notebook {
J
Johannes Rieken 已提交
1604

1605 1606
		// TODO@api use NotebookDocumentFilter instead of just notebookType:string?
		// TODO@API options duplicates the more powerful variant on NotebookContentProvider
1607
		export function registerNotebookContentProvider(notebookType: string, provider: NotebookContentProvider, options?: NotebookDocumentContentOptions): Disposable;
R
rebornix 已提交
1608 1609
	}

1610 1611 1612 1613
	//#endregion

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

1614 1615 1616 1617 1618
	export interface NotebookKernelPreload {
		provides?: string | string[];
		uri: Uri;
	}

J
Johannes Rieken 已提交
1619
	/** @deprecated used NotebookController */
R
rebornix 已提交
1620
	export interface NotebookKernel {
1621 1622

		// todo@API make this mandatory?
R
rebornix 已提交
1623
		readonly id?: string;
1624

R
rebornix 已提交
1625
		label: string;
R
rebornix 已提交
1626
		description?: string;
R
rebornix 已提交
1627
		detail?: string;
R
rebornix 已提交
1628
		isPreferred?: boolean;
1629

1630 1631
		// todo@API do we need an preload change event?
		preloads?: NotebookKernelPreload[];
J
Johannes Rieken 已提交
1632

J
Johannes Rieken 已提交
1633 1634 1635 1636 1637
		/**
		 * languages supported by kernel
		 * - first is preferred
		 * - `undefined` means all languages available in the editor
		 */
1638
		supportedLanguages?: string[];
J
Johannes Rieken 已提交
1639

1640 1641 1642 1643
		// todo@API kernel updating itself
		// fired when properties like the supported languages etc change
		// onDidChangeProperties?: Event<void>

R
Rob Lourens 已提交
1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654
		/**
		 * A kernel can optionally implement this which will be called when any "cancel" button is clicked in the document.
		 */
		interrupt?(document: NotebookDocument): void;

		/**
		 * Called when the user triggers execution of a cell by clicking the run button for a cell, multiple cells,
		 * or full notebook. The cell will be put into the Pending state when this method is called. If
		 * createNotebookCellExecutionTask has not been called by the time the promise returned by this method is
		 * resolved, the cell will be put back into the Idle state.
		 */
1655
		executeCellsRequest(document: NotebookDocument, ranges: NotebookRange[]): Thenable<void>;
R
Rob Lourens 已提交
1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673
	}

	export interface NotebookCellExecuteStartContext {
		/**
		 * The time that execution began, in milliseconds in the Unix epoch. Used to drive the clock
		 * that shows for how long a cell has been running. If not given, the clock won't be shown.
		 */
		startTime?: number;
	}

	export interface NotebookCellExecuteEndContext {
		/**
		 * If true, a green check is shown on the cell status bar.
		 * If false, a red X is shown.
		 */
		success?: boolean;

		/**
1674
		 * The time that execution finished, in milliseconds in the Unix epoch.
R
Rob Lourens 已提交
1675
		 */
1676
		endTime?: number;
R
Rob Lourens 已提交
1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700
	}

	/**
	 * A NotebookCellExecutionTask is how the kernel modifies a notebook cell as it is executing. When
	 * [`createNotebookCellExecutionTask`](#notebook.createNotebookCellExecutionTask) is called, the cell
	 * enters the Pending state. When `start()` is called on the execution task, it enters the Executing state. When
	 * `end()` is called, it enters the Idle state. While in the Executing state, cell outputs can be
	 * modified with the methods on the run task.
	 *
	 * All outputs methods operate on this NotebookCellExecutionTask's cell by default. They optionally take
	 * a cellIndex parameter that allows them to modify the outputs of other cells. `appendOutputItems` and
	 * `replaceOutputItems` operate on the output with the given ID, which can be an output on any cell. They
	 * all resolve once the output edit has been applied.
	 */
	export interface NotebookCellExecutionTask {
		readonly document: NotebookDocument;
		readonly cell: NotebookCell;

		start(context?: NotebookCellExecuteStartContext): void;
		executionOrder: number | undefined;
		end(result?: NotebookCellExecuteEndContext): void;
		readonly token: CancellationToken;

		clearOutput(cellIndex?: number): Thenable<void>;
1701 1702
		appendOutput(out: NotebookCellOutput | NotebookCellOutput[], cellIndex?: number): Thenable<void>;
		replaceOutput(out: NotebookCellOutput | NotebookCellOutput[], cellIndex?: number): Thenable<void>;
1703 1704
		appendOutputItems(items: NotebookCellOutputItem | NotebookCellOutputItem[], outputId: string): Thenable<void>;
		replaceOutputItems(items: NotebookCellOutputItem | NotebookCellOutputItem[], outputId: string): Thenable<void>;
R
Rob Lourens 已提交
1705 1706 1707 1708 1709 1710 1711 1712 1713
	}

	export enum NotebookCellExecutionState {
		Idle = 1,
		Pending = 2,
		Executing = 3,
	}

	export namespace notebook {
1714
		/** @deprecated use NotebookController */
R
Rob Lourens 已提交
1715 1716 1717
		export function createNotebookCellExecutionTask(uri: Uri, index: number, kernelId: string): NotebookCellExecutionTask | undefined;

		export const onDidChangeCellExecutionState: Event<NotebookCellExecutionStateChangeEvent>;
R
rebornix 已提交
1718 1719
	}

1720
	export type NotebookFilenamePattern = GlobPattern | { include: GlobPattern; exclude: GlobPattern; };
R
rebornix 已提交
1721

J
Johannes Rieken 已提交
1722
	// todo@API why not for NotebookContentProvider?
1723
	/** @deprecated use NotebookSelector */
R
rebornix 已提交
1724
	export interface NotebookDocumentFilter {
R
rebornix 已提交
1725
		viewType?: string | string[];
R
rebornix 已提交
1726
		filenamePattern?: NotebookFilenamePattern;
R
rebornix 已提交
1727 1728
	}

1729 1730 1731 1732 1733
	//#endregion

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

	export interface NotebookEditor {
1734
		setDecorations(decorationType: NotebookEditorDecorationType, range: NotebookRange): void;
1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754
	}

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

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

	export namespace notebook {
		export function createNotebookEditorDecorationType(options: NotebookDecorationRenderOptions): NotebookEditorDecorationType;
	}

	//#endregion

	//#region https://github.com/microsoft/vscode/issues/106744, NotebookCellStatusBarItem
J
Johannes Rieken 已提交
1755

1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771
	/**
	 * Represents the alignment of status bar items.
	 */
	export enum NotebookCellStatusBarAlignment {

		/**
		 * Aligned to the left side.
		 */
		Left = 1,

		/**
		 * Aligned to the right side.
		 */
		Right = 2
	}

R
Rob Lourens 已提交
1772 1773
	export class NotebookCellStatusBarItem {
		readonly text: string;
1774
		readonly alignment: NotebookCellStatusBarAlignment;
R
Rob Lourens 已提交
1775 1776
		readonly command?: string | Command;
		readonly tooltip?: string;
1777
		readonly priority?: number;
R
Rob Lourens 已提交
1778 1779 1780 1781 1782 1783
		readonly accessibilityInformation?: AccessibilityInformation;

		constructor(text: string, alignment: NotebookCellStatusBarAlignment, command?: string | Command, tooltip?: string, priority?: number, accessibilityInformation?: AccessibilityInformation);
	}

	interface NotebookCellStatusBarItemProvider {
1784 1785 1786
		/**
		 * Implement and fire this event to signal that statusbar items have changed. The provide method will be called again.
		 */
R
Rob Lourens 已提交
1787
		onDidChangeCellStatusBarItems?: Event<void>;
1788 1789 1790 1791

		/**
		 * The provider will be called when the cell scrolls into view, when its content, outputs, language, or metadata change, and when it changes execution state.
		 */
R
Rob Lourens 已提交
1792
		provideCellStatusBarItems(cell: NotebookCell, token: CancellationToken): ProviderResult<NotebookCellStatusBarItem[]>;
1793 1794
	}

1795
	export namespace notebook {
1796
		export function registerNotebookCellStatusBarItemProvider(selector: NotebookSelector, provider: NotebookCellStatusBarItemProvider): Disposable;
R
rebornix 已提交
1797 1798
	}

1799
	//#endregion
R
rebornix 已提交
1800

1801
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookConcatTextDocument
R
rebornix 已提交
1802

R
rebornix 已提交
1803
	export namespace notebook {
1804
		/**
J
Johannes Rieken 已提交
1805 1806
		 * 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.
1807 1808 1809 1810
		 *
		 * @param notebook
		 * @param selector
		 */
J
Johannes Rieken 已提交
1811
		// @jrieken REMOVE. p_never
J
Johannes Rieken 已提交
1812
		// todo@API really needed? we didn't find a user here
1813
		export function createConcatTextDocument(notebook: NotebookDocument, selector?: DocumentSelector): NotebookConcatTextDocument;
1814
	}
M
Martin Aeschlimann 已提交
1815

1816 1817 1818 1819 1820 1821 1822 1823
	export interface NotebookConcatTextDocument {
		uri: Uri;
		isClosed: boolean;
		dispose(): void;
		onDidChange: Event<void>;
		version: number;
		getText(): string;
		getText(range: Range): string;
1824

1825 1826 1827 1828
		offsetAt(position: Position): number;
		positionAt(offset: number): Position;
		validateRange(range: Range): Range;
		validatePosition(position: Position): Position;
M
Martin Aeschlimann 已提交
1829

1830 1831 1832
		locationAt(positionOrRange: Position | Range): Location;
		positionAt(location: Location): Position;
		contains(uri: Uri): boolean;
1833 1834
	}

1835 1836 1837 1838
	//#endregion

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

P
label2  
Pine Wu 已提交
1839 1840 1841 1842
	export interface CompletionItem {
		/**
		 * Will be merged into CompletionItem#label
		 */
P
Pine Wu 已提交
1843
		label2?: CompletionItemLabel;
P
label2  
Pine Wu 已提交
1844 1845
	}

1846 1847
	export interface CompletionItemLabel {
		/**
P
Pine Wu 已提交
1848
		 * The function or variable. Rendered leftmost.
1849
		 */
P
Pine Wu 已提交
1850
		name: string;
1851

P
Pine Wu 已提交
1852
		/**
1853
		 * The parameters without the return type. Render after `name`.
P
Pine Wu 已提交
1854
		 */
1855
		parameters?: string;
P
Pine Wu 已提交
1856 1857

		/**
P
Pine Wu 已提交
1858
		 * The fully qualified name, like package name or file path. Rendered after `signature`.
P
Pine Wu 已提交
1859 1860
		 */
		qualifier?: string;
1861

P
Pine Wu 已提交
1862
		/**
P
Pine Wu 已提交
1863
		 * The return-type of a function or type of a property/variable. Rendered rightmost.
P
Pine Wu 已提交
1864
		 */
P
Pine Wu 已提交
1865
		type?: string;
1866 1867 1868 1869
	}

	//#endregion

1870
	//#region @eamodio - timeline: https://github.com/microsoft/vscode/issues/84297
1871 1872 1873

	export class TimelineItem {
		/**
1874
		 * A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred.
1875
		 */
E
Eric Amodio 已提交
1876
		timestamp: number;
1877 1878

		/**
1879
		 * A human-readable string describing the timeline item.
1880 1881 1882 1883
		 */
		label: string;

		/**
1884
		 * Optional id for the timeline item. It must be unique across all the timeline items provided by this source.
1885
		 *
1886
		 * If not provided, an id is generated using the timeline item's timestamp.
1887 1888 1889 1890
		 */
		id?: string;

		/**
1891
		 * The icon path or [ThemeIcon](#ThemeIcon) for the timeline item.
1892
		 */
R
rebornix 已提交
1893
		iconPath?: Uri | { light: Uri; dark: Uri; } | ThemeIcon;
1894 1895

		/**
1896
		 * A human readable string describing less prominent details of the timeline item.
1897 1898 1899 1900 1901 1902
		 */
		description?: string;

		/**
		 * The tooltip text when you hover over the timeline item.
		 */
1903
		detail?: string;
1904 1905 1906 1907 1908 1909 1910

		/**
		 * The [command](#Command) that should be executed when the timeline item is selected.
		 */
		command?: Command;

		/**
1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926
		 * 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`.
1927 1928 1929
		 */
		contextValue?: string;

1930 1931 1932 1933 1934
		/**
		 * Accessibility information used when screen reader interacts with this timeline item.
		 */
		accessibilityInformation?: AccessibilityInformation;

1935 1936
		/**
		 * @param label A human-readable string describing the timeline item
E
Eric Amodio 已提交
1937
		 * @param timestamp A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred
1938
		 */
E
Eric Amodio 已提交
1939
		constructor(label: string, timestamp: number);
1940 1941
	}

1942
	export interface TimelineChangeEvent {
E
Eric Amodio 已提交
1943
		/**
1944
		 * The [uri](#Uri) of the resource for which the timeline changed.
E
Eric Amodio 已提交
1945
		 */
E
Eric Amodio 已提交
1946
		uri: Uri;
1947

E
Eric Amodio 已提交
1948
		/**
1949
		 * A flag which indicates whether the entire timeline should be reset.
E
Eric Amodio 已提交
1950
		 */
1951 1952
		reset?: boolean;
	}
E
Eric Amodio 已提交
1953

1954 1955 1956
	export interface Timeline {
		readonly paging?: {
			/**
E
Eric Amodio 已提交
1957
			 * A provider-defined cursor specifying the starting point of timeline items which are after the ones returned.
E
Eric Amodio 已提交
1958
			 * Use `undefined` to signal that there are no more items to be returned.
1959
			 */
E
Eric Amodio 已提交
1960
			readonly cursor: string | undefined;
R
rebornix 已提交
1961
		};
E
Eric Amodio 已提交
1962 1963

		/**
1964
		 * An array of [timeline items](#TimelineItem).
E
Eric Amodio 已提交
1965
		 */
1966
		readonly items: readonly TimelineItem[];
E
Eric Amodio 已提交
1967 1968
	}

1969
	export interface TimelineOptions {
E
Eric Amodio 已提交
1970
		/**
E
Eric Amodio 已提交
1971
		 * A provider-defined cursor specifying the starting point of the timeline items that should be returned.
E
Eric Amodio 已提交
1972
		 */
1973
		cursor?: string;
E
Eric Amodio 已提交
1974 1975

		/**
1976 1977
		 * 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 已提交
1978
		 */
R
rebornix 已提交
1979
		limit?: number | { timestamp: number; id?: string; };
E
Eric Amodio 已提交
1980 1981
	}

1982
	export interface TimelineProvider {
1983
		/**
1984 1985
		 * 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`.
1986
		 */
E
Eric Amodio 已提交
1987
		onDidChange?: Event<TimelineChangeEvent | undefined>;
1988 1989

		/**
1990
		 * An identifier of the source of the timeline items. This can be used to filter sources.
1991
		 */
1992
		readonly id: string;
1993

E
Eric Amodio 已提交
1994
		/**
1995
		 * 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 已提交
1996
		 */
1997
		readonly label: string;
1998 1999

		/**
E
Eric Amodio 已提交
2000
		 * Provide [timeline items](#TimelineItem) for a [Uri](#Uri).
2001
		 *
2002
		 * @param uri The [uri](#Uri) of the file to provide the timeline for.
2003
		 * @param options A set of options to determine how results should be returned.
2004
		 * @param token A cancellation token.
E
Eric Amodio 已提交
2005
		 * @return The [timeline result](#TimelineResult) or a thenable that resolves to such. The lack of a result
2006 2007
		 * can be signaled by returning `undefined`, `null`, or an empty array.
		 */
2008
		provideTimeline(uri: Uri, options: TimelineOptions, token: CancellationToken): ProviderResult<Timeline>;
2009 2010 2011 2012 2013 2014 2015 2016 2017 2018
	}

	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.
		 *
2019
		 * @param scheme A scheme or schemes that defines which documents this provider is applicable to. Can be `*` to target all documents.
2020 2021
		 * @param provider A timeline provider.
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
E
Eric Amodio 已提交
2022
		*/
2023
		export function registerTimelineProvider(scheme: string | string[], provider: TimelineProvider): Disposable;
2024 2025 2026
	}

	//#endregion
2027

2028
	//#region https://github.com/microsoft/vscode/issues/91555
2029

2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042
	export enum StandardTokenType {
		Other = 0,
		Comment = 1,
		String = 2,
		RegEx = 4
	}

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

	export namespace languages {
2043
		export function getTokenInformationAtPosition(document: TextDocument, position: Position): Thenable<TokenInformation>;
K
kingwl 已提交
2044 2045 2046 2047
	}

	//#endregion

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

J
Johannes Rieken 已提交
2050 2051
	// todo@API rename to InlayHint
	// todo@API add "mini-markdown" for links and styles
2052 2053
	// todo@API remove description
	// (done:)  add InlayHintKind with type, argument, etc
J
Johannes Rieken 已提交
2054

K
kingwl 已提交
2055
	export namespace languages {
K
kingwl 已提交
2056 2057 2058
		/**
		 * Register a inline hints provider.
		 *
J
Johannes Rieken 已提交
2059 2060 2061
		 * 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 已提交
2062 2063
		 *
		 * @param selector A selector that defines the documents this provider is applicable to.
J
Johannes Rieken 已提交
2064
		 * @param provider An inline hints provider.
K
kingwl 已提交
2065 2066 2067
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
		 */
		export function registerInlineHintsProvider(selector: DocumentSelector, provider: InlineHintsProvider): Disposable;
2068 2069
	}

2070 2071 2072 2073 2074 2075
	export enum InlineHintKind {
		Other = 0,
		Type = 1,
		Parameter = 2,
	}

K
kingwl 已提交
2076 2077 2078 2079 2080 2081 2082 2083 2084
	/**
	 * Inline hint information.
	 */
	export class InlineHint {
		/**
		 * The text of the hint.
		 */
		text: string;
		/**
K
kingwl 已提交
2085
		 * The range of the hint.
K
kingwl 已提交
2086 2087
		 */
		range: Range;
2088 2089 2090 2091

		kind?: InlineHintKind;

		// todo@API remove this
2092
		description?: string | MarkdownString;
K
kingwl 已提交
2093 2094 2095 2096 2097 2098 2099 2100 2101
		/**
		 * Whitespace before the hint.
		 */
		whitespaceBefore?: boolean;
		/**
		 * Whitespace after the hint.
		 */
		whitespaceAfter?: boolean;

2102
		// todo@API make range first argument
2103
		constructor(text: string, range: Range, kind?: InlineHintKind);
K
kingwl 已提交
2104 2105 2106
	}

	/**
J
Johannes Rieken 已提交
2107
	 * The inline hints provider interface defines the contract between extensions and
K
kingwl 已提交
2108 2109 2110
	 * the inline hints feature.
	 */
	export interface InlineHintsProvider {
W
Wenlu Wang 已提交
2111 2112 2113 2114 2115 2116

		/**
		 * An optional event to signal that inline hints have changed.
		 * @see [EventEmitter](#EventEmitter)
		 */
		onDidChangeInlineHints?: Event<void>;
J
Johannes Rieken 已提交
2117

K
kingwl 已提交
2118 2119
		/**
		 * @param model The document in which the command was invoked.
J
Johannes Rieken 已提交
2120
		 * @param range The range for which line hints should be computed.
K
kingwl 已提交
2121 2122 2123 2124 2125 2126
		 * @param token A cancellation token.
		 *
		 * @return A list of arguments labels or a thenable that resolves to such.
		 */
		provideInlineHints(model: TextDocument, range: Range, token: CancellationToken): ProviderResult<InlineHint[]>;
	}
2127
	//#endregion
2128

2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146
	//#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
2147 2148 2149 2150

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

	export interface TextDocument {
2151 2152 2153 2154 2155

		/**
		 * The [notebook](#NotebookDocument) that contains this document as a notebook cell or `undefined` when
		 * the document is not contained by a notebook (this should be the more frequent case).
		 */
2156 2157 2158
		notebook: NotebookDocument | undefined;
	}
	//#endregion
C
Connor Peet 已提交
2159 2160 2161 2162

	//#region https://github.com/microsoft/vscode/issues/107467
	export namespace test {
		/**
2163 2164
		 * Registers a controller that can discover and
		 * run tests in workspaces and documents.
C
Connor Peet 已提交
2165
		 */
2166
		export function registerTestController<T>(testController: TestController<T>): Disposable;
C
Connor Peet 已提交
2167 2168

		/**
2169 2170 2171
		 * Requests that tests be run by their controller.
		 * @param run Run options to use
		 * @param token Cancellation token for the test run
C
Connor Peet 已提交
2172
		 */
2173
		export function runTests<T>(run: TestRunRequest<T>, token?: CancellationToken): Thenable<void>;
C
Connor Peet 已提交
2174 2175 2176

		/**
		 * Returns an observer that retrieves tests in the given workspace folder.
2177
		 * @stability experimental
C
Connor Peet 已提交
2178 2179 2180 2181 2182
		 */
		export function createWorkspaceTestObserver(workspaceFolder: WorkspaceFolder): TestObserver;

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

2187
		/**
2188 2189 2190 2191 2192
		 * Creates a {@link TestRunTask<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.
2193
		 *
2194 2195 2196 2197 2198 2199 2200 2201
		 * @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
		 * persisted in VS Code. This may be false if the results are coming from
		 * a file already saved externally, such as a coverage information file.
2202
		 */
2203
		export function createTestRunTask<T>(request: TestRunRequest<T>, name?: string, persist?: boolean): TestRunTask<T>;
2204

2205
		/**
2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222
		 * 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>;

		/**
		 * List of test results stored by VS Code, sorted in descnding
		 * order by their `completedAt` time.
		 * @stability experimental
		 */
C
Connor Peet 已提交
2223
		export const testResults: ReadonlyArray<TestRunResult>;
2224 2225

		/**
2226 2227 2228
		 * Event that fires when the {@link testResults} array is updated.
		 * @stability experimental
		 */
2229 2230 2231
		export const onDidChangeTestResults: Event<void>;
	}

2232 2233 2234
	/**
	 * @stability experimental
	 */
C
Connor Peet 已提交
2235 2236 2237 2238
	export interface TestObserver {
		/**
		 * List of tests returned by test provider for files in the workspace.
		 */
2239
		readonly tests: ReadonlyArray<TestItem<never>>;
C
Connor Peet 已提交
2240 2241 2242 2243 2244 2245

		/**
		 * 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 已提交
2246
		readonly onDidChangeTest: Event<TestsChangeEvent>;
C
Connor Peet 已提交
2247 2248

		/**
C
Connor Peet 已提交
2249
		 * An event that fires when all test providers have signalled that the tests
C
Connor Peet 已提交
2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264
		 * 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>;

		/**
		 * Dispose of the observer, allowing VS Code to eventually tell test
		 * providers that they no longer need to update tests.
		 */
		dispose(): void;
	}

2265 2266 2267
	/**
	 * @stability experimental
	 */
C
Connor Peet 已提交
2268
	export interface TestsChangeEvent {
C
Connor Peet 已提交
2269 2270 2271
		/**
		 * List of all tests that are newly added.
		 */
2272
		readonly added: ReadonlyArray<TestItem<never>>;
C
Connor Peet 已提交
2273 2274 2275 2276

		/**
		 * List of existing tests that have updated.
		 */
2277
		readonly updated: ReadonlyArray<TestItem<never>>;
C
Connor Peet 已提交
2278 2279 2280 2281

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

C
Connor Peet 已提交
2285
	/**
2286
	 * Interface to discover and execute tests.
C
Connor Peet 已提交
2287
	 */
2288
	export interface TestController<T> {
C
Connor Peet 已提交
2289 2290
		/**
		 * Requests that tests be provided for the given workspace. This will
2291 2292
		 * be called when tests need to be enumerated for the workspace, such as
		 * when the user opens the test explorer.
C
Connor Peet 已提交
2293 2294
		 *
		 * It's guaranteed that this method will not be called again while
C
Connor Peet 已提交
2295
		 * there is a previous uncancelled call for the given workspace folder.
2296 2297
		 *
		 * @param workspace The workspace in which to observe tests
2298
		 * @param cancellationToken Token that signals the used asked to abort the test run.
2299
		 * @returns the root test item for the workspace
C
Connor Peet 已提交
2300
		 */
2301
		createWorkspaceTestRoot(workspace: WorkspaceFolder, token: CancellationToken): ProviderResult<TestItem<T>>;
C
Connor Peet 已提交
2302 2303

		/**
2304 2305 2306 2307 2308
		 * 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
2309 2310
		 * document to provide information for tests that might not yet be
		 * saved.
2311 2312
		 *
		 * If the test system is not able to provide or estimate for tests on a
2313 2314
		 * per-file basis, this method may not be implemented. In that case, the
		 * editor will request and use the information from the workspace tree.
2315 2316
		 *
		 * @param document The document in which to observe tests
2317
		 * @param cancellationToken Token that signals the used asked to abort the test run.
2318
		 * @returns the root test item for the document
C
Connor Peet 已提交
2319
		 */
2320
		createDocumentTestRoot?(document: TextDocument, token: CancellationToken): ProviderResult<TestItem<T>>;
C
Connor Peet 已提交
2321 2322

		/**
2323 2324 2325 2326
		 * Starts a test run. When called, the controller should call
		 * {@link vscode.test.createTestRunTask}. All tasks associated with the
		 * run should be created before the function returns or the reutrned
		 * promise is resolved.
2327
		 *
2328 2329
		 * @param options Options for this test run
		 * @param cancellationToken Token that signals the used asked to abort the test run.
C
Connor Peet 已提交
2330
		 */
2331
		runTests(options: TestRunRequest<T>, token: CancellationToken): Thenable<void> | void;
C
Connor Peet 已提交
2332 2333 2334
	}

	/**
2335
	 * Options given to {@link test.runTests}.
C
Connor Peet 已提交
2336
	 */
2337
	export interface TestRunRequest<T> {
C
Connor Peet 已提交
2338
		/**
2339 2340 2341
		 * 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}.
C
Connor Peet 已提交
2342
		 */
2343
		tests: TestItem<T>[];
C
Connor Peet 已提交
2344

2345
		/**
2346
		 * An array of tests the user has marked as excluded in VS Code. May be
2347
		 * omitted if no exclusions were requested. Test controllers should not run
2348
		 * excluded tests or any children of excluded tests.
2349
		 */
2350
		exclude?: TestItem<T>[];
2351

C
Connor Peet 已提交
2352
		/**
2353
		 * Whether tests in this run should be debugged.
C
Connor Peet 已提交
2354 2355 2356 2357
		 */
		debug: boolean;
	}

2358
	/**
2359
	 * Options given to {@link TestController.runTests}
2360
	 */
2361
	export interface TestRunTask<T = void> {
2362
		/**
2363 2364 2365 2366 2367 2368
		 * 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;

2369
		/**
2370 2371 2372
		 * 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.
2373 2374 2375
		 *
		 * @param test The test to update
		 * @param state The state to assign to the test
C
Connor Peet 已提交
2376
		 * @param duration Optionally sets how long the test took to run
2377
		 */
2378
		setState(test: TestItem<T>, state: TestResultState, duration?: number): void;
C
Connor Peet 已提交
2379 2380 2381 2382

		/**
		 * Appends a message, such as an assertion error, to the test item.
		 *
2383 2384
		 * Calling with method with nodes outside the {@link TestRunRequest.tests}
		 * or in the {@link TestRunRequest.exclude} array will no-op.
C
Connor Peet 已提交
2385 2386 2387 2388 2389
		 *
		 * @param test The test to update
		 * @param state The state to assign to the test
		 *
		 */
2390
		appendMessage(test: TestItem<T>, message: TestMessage): void;
C
Connor Peet 已提交
2391 2392 2393 2394 2395

		/**
		 * 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.
C
wip  
Connor Peet 已提交
2396 2397 2398
		 *
		 * @param output Output text to append
		 * @param associateTo Optionally, associate the given segment of output
C
Connor Peet 已提交
2399 2400
		 */
		appendOutput(output: string): void;
2401 2402 2403 2404 2405 2406

		/**
		 * 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;
2407 2408
	}

2409 2410 2411 2412
	/**
	 * Indicates the the activity state of the {@link TestItem}.
	 */
	export enum TestItemStatus {
2413
		/**
2414
		 * All children of the test item, if any, have been discovered.
2415
		 */
2416
		Resolved = 1,
2417 2418

		/**
2419
		 * The test item may have children who have not been discovered yet.
2420
		 */
2421 2422
		Pending = 0,
	}
2423

2424 2425 2426 2427
	/**
	 * Options initially passed into `vscode.test.createTestItem`
	 */
	export interface TestItemOptions {
2428
		/**
2429 2430 2431
		 * 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.
2432
		 */
2433
		id: string;
2434 2435

		/**
2436
		 * URI this TestItem is associated with. May be a file or directory.
2437
		 */
2438
		uri: Uri;
2439 2440

		/**
2441
		 * Display name describing the test item.
2442
		 */
2443
		label: string;
2444 2445
	}

C
Connor Peet 已提交
2446 2447 2448 2449
	/**
	 * 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.
	 */
2450
	export interface TestItem<T, TChildren = any> {
C
Connor Peet 已提交
2451
		/**
2452 2453
		 * Unique identifier for the TestItem. This is used to correlate
		 * test results and tests in the document with those in the workspace
C
Connor Peet 已提交
2454
		 * (test explorer). This must not change for the lifetime of the TestItem.
C
Connor Peet 已提交
2455
		 */
2456
		readonly id: string;
C
Connor Peet 已提交
2457

2458
		/**
C
Connor Peet 已提交
2459
		 * URI this TestItem is associated with. May be a file or directory.
2460 2461 2462
		 */
		readonly uri: Uri;

2463
		/**
2464
		 * A mapping of children by ID to the associated TestItem instances.
2465
		 */
2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483
		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.
2484
		 */
2485
		status: TestItemStatus;
2486

2487
		/**
2488
		 * Display name describing the test case.
2489
		 */
2490
		label: string;
2491

C
Connor Peet 已提交
2492 2493 2494 2495 2496
		/**
		 * Optional description that appears next to the label.
		 */
		description?: string;

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

2503 2504 2505 2506 2507 2508 2509
		/**
		 * 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;

C
Connor Peet 已提交
2510
		/**
C
Connor Peet 已提交
2511 2512
		 * Whether this test item can be run by providing it in the
		 * {@link TestRunRequest.tests} array. Defaults to `true`.
C
Connor Peet 已提交
2513
		 */
2514
		runnable: boolean;
C
Connor Peet 已提交
2515 2516

		/**
C
Connor Peet 已提交
2517 2518
		 * Whether this test item can be debugged by providing it in the
		 * {@link TestRunRequest.tests} array. Defaults to `false`.
C
Connor Peet 已提交
2519
		 */
2520
		debuggable: boolean;
C
Connor Peet 已提交
2521 2522

		/**
2523 2524
		 * Custom extension data on the item. This data will never be serialized
		 * or shared outside the extenion who created the item.
2525
		 */
2526
		data: T;
2527 2528 2529 2530

		/**
		 * 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
C
Connor Peet 已提交
2531
		 * automatically rerun after a short delay. Invoking this on a
2532 2533 2534 2535 2536 2537 2538
		 * test with children will mark the entire subtree as outdated.
		 *
		 * Extensions should generally not override this method.
		 */
		invalidate(): void;

		/**
2539 2540
		 * A function provided by the extension that the editor may call to request
		 * children of the item, if the {@link TestItem.status} is `Pending`.
2541
		 *
2542 2543 2544
		 * 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.
2545 2546 2547
		 *
		 * The item should continue watching for changes to the children and
		 * firing updates until the token is cancelled. The process of watching
2548 2549 2550
		 * 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`.
2551 2552 2553 2554 2555 2556 2557
		 *
		 * 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.
2558
		 */
2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571
		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;
2572
	}
2573

2574 2575 2576
	/**
	 * Possible states of tests in a test run.
	 */
C
Connor Peet 已提交
2577
	export enum TestResultState {
C
Connor Peet 已提交
2578 2579
		// Initial state
		Unset = 0,
C
Connor Peet 已提交
2580 2581
		// Test will be run, but is not currently running.
		Queued = 1,
C
Connor Peet 已提交
2582
		// Test is currently running
C
Connor Peet 已提交
2583
		Running = 2,
C
Connor Peet 已提交
2584
		// Test run has passed
C
Connor Peet 已提交
2585
		Passed = 3,
C
Connor Peet 已提交
2586
		// Test run has failed (on an assertion)
C
Connor Peet 已提交
2587
		Failed = 4,
C
Connor Peet 已提交
2588
		// Test run has been skipped
C
Connor Peet 已提交
2589
		Skipped = 5,
C
Connor Peet 已提交
2590
		// Test run failed for some other reason (compilation error, timeout, etc)
C
Connor Peet 已提交
2591
		Errored = 6
C
Connor Peet 已提交
2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607
	}

	/**
	 * 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.
	 */
2608
	export class TestMessage {
C
Connor Peet 已提交
2609 2610 2611 2612 2613 2614
		/**
		 * Human-readable message text to display.
		 */
		message: string | MarkdownString;

		/**
2615
		 * Message severity. Defaults to "Error".
C
Connor Peet 已提交
2616
		 */
2617
		severity: TestMessageSeverity;
C
Connor Peet 已提交
2618 2619

		/**
C
Connor Peet 已提交
2620
		 * Expected test output. If given with `actualOutput`, a diff view will be shown.
C
Connor Peet 已提交
2621 2622 2623 2624
		 */
		expectedOutput?: string;

		/**
C
Connor Peet 已提交
2625
		 * Actual test output. If given with `expectedOutput`, a diff view will be shown.
C
Connor Peet 已提交
2626 2627 2628 2629 2630 2631 2632
		 */
		actualOutput?: string;

		/**
		 * Associated file location.
		 */
		location?: Location;
2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646

		/**
		 * 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);
C
Connor Peet 已提交
2647
	}
2648

2649
	/**
C
Connor Peet 已提交
2650 2651
	 * TestResults can be provided to VS Code in {@link test.publishTestResult},
	 * or read from it in {@link test.testResults}.
2652 2653
	 *
	 * The results contain a 'snapshot' of the tests at the point when the test
C
Connor Peet 已提交
2654 2655 2656
	 * 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.
2657
	 *
2658
	 * @todo coverage and other info may eventually be provided here
2659
	 */
C
Connor Peet 已提交
2660
	export interface TestRunResult {
2661
		/**
C
Connor Peet 已提交
2662
		 * Unix milliseconds timestamp at which the test run was completed.
2663 2664 2665
		 */
		completedAt: number;

2666 2667 2668 2669 2670
		/**
		 * Optional raw output from the test run.
		 */
		output?: string;

2671 2672 2673 2674
		/**
		 * List of test results. The items in this array are the items that
		 * were passed in the {@link test.runTests} method.
		 */
2675
		results: ReadonlyArray<Readonly<TestResultSnapshot>>;
2676 2677 2678
	}

	/**
2679 2680
	 * A {@link TestItem}-like interface with an associated result, which appear
	 * or can be provided in {@link TestResult} interfaces.
2681
	 */
2682 2683 2684 2685 2686 2687 2688 2689
	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;

2690 2691 2692 2693 2694
		/**
		 * URI this TestItem is associated with. May be a file or file.
		 */
		readonly uri: Uri;

2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705
		/**
		 * Display name describing the test case.
		 */
		readonly label: string;

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

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

2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723
		/**
		 * 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.
		 */
		readonly taskStates: ReadonlyArray<TestSnapshoptTaskState>;

		/**
		 * Optional list of nested tests for this item.
		 */
		readonly children: Readonly<TestResultSnapshot>[];
	}

	export interface TestSnapshoptTaskState {
2724 2725 2726
		/**
		 * Current result of the test.
		 */
C
Connor Peet 已提交
2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739
		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>;
2740 2741
	}

C
Connor Peet 已提交
2742
	//#endregion
2743 2744 2745

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

2746 2747 2748
	/**
	 * Details if an `ExternalUriOpener` can open a uri.
	 *
2749 2750 2751 2752 2753 2754 2755
	 * 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.
	 *
	 * VS Code will try to use the best available opener, as sorted by `ExternalUriOpenerPriority`.
	 * If there are multiple potential "best" openers for a URI, then the user will be prompted
	 * to select an opener.
2756
	 */
M
Matt Bierner 已提交
2757
	export enum ExternalUriOpenerPriority {
2758
		/**
2759
		 * The opener is disabled and will never be shown to users.
M
Matt Bierner 已提交
2760
		 *
2761 2762
		 * Note that the opener can still be used if the user specifically
		 * configures it in their settings.
2763
		 */
M
Matt Bierner 已提交
2764
		None = 0,
2765 2766

		/**
2767 2768
		 * The opener can open the uri but will not cause a prompt on its own
		 * since VS Code always contributes a built-in `Default` opener.
2769
		 */
M
Matt Bierner 已提交
2770
		Option = 1,
2771 2772

		/**
M
Matt Bierner 已提交
2773 2774
		 * The opener can open the uri.
		 *
2775 2776
		 * VS Code's built-in opener has `Default` priority. This means that any additional `Default`
		 * openers will cause the user to be prompted to select from a list of all potential openers.
2777
		 */
M
Matt Bierner 已提交
2778 2779 2780
		Default = 2,

		/**
2781 2782
		 * The opener can open the uri and should be automatically selected over any
		 * default openers, include the built-in one from VS Code.
M
Matt Bierner 已提交
2783
		 *
2784
		 * A preferred opener will be automatically selected if no other preferred openers
2785
		 * are available. If multiple preferred openers are available, then the user
2786
		 * is shown a prompt with all potential openers (not just preferred openers).
M
Matt Bierner 已提交
2787 2788
		 */
		Preferred = 3,
2789 2790
	}

2791
	/**
M
Matt Bierner 已提交
2792
	 * Handles opening uris to external resources, such as http(s) links.
2793
	 *
M
Matt Bierner 已提交
2794
	 * Extensions can implement an `ExternalUriOpener` to open `http` links to a webserver
M
Matt Bierner 已提交
2795
	 * inside of VS Code instead of having the link be opened by the web browser.
2796 2797 2798 2799 2800 2801
	 *
	 * Currently openers may only be registered for `http` and `https` uris.
	 */
	export interface ExternalUriOpener {

		/**
2802
		 * Check if the opener can open a uri.
2803
		 *
M
Matt Bierner 已提交
2804 2805 2806
		 * @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.
2807
		 *
2808
		 * @return Priority indicating if the opener can open the external uri.
M
Matt Bierner 已提交
2809
		 */
M
Matt Bierner 已提交
2810
		canOpenExternalUri(uri: Uri, token: CancellationToken): ExternalUriOpenerPriority | Thenable<ExternalUriOpenerPriority>;
M
Matt Bierner 已提交
2811 2812

		/**
2813
		 * Open a uri.
2814
		 *
M
Matt Bierner 已提交
2815
		 * This is invoked when:
2816
		 *
M
Matt Bierner 已提交
2817 2818 2819
		 * - 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.
2820
		 *
M
Matt Bierner 已提交
2821 2822 2823 2824 2825 2826
		 * @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.
		 *
2827
		 * @return Thenable indicating that the opening has completed.
M
Matt Bierner 已提交
2828 2829 2830 2831 2832 2833 2834 2835 2836 2837
		 */
		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.
2838
		 *
2839
		 * This is the original uri that the user clicked on or that was passed to `openExternal.`
M
Matt Bierner 已提交
2840
		 * Due to port forwarding, this may not match the `resolvedUri` passed to `openExternalUri`.
2841
		 */
M
Matt Bierner 已提交
2842 2843 2844
		readonly sourceUri: Uri;
	}

M
Matt Bierner 已提交
2845
	/**
2846
	 * Additional metadata about a registered `ExternalUriOpener`.
M
Matt Bierner 已提交
2847
	 */
M
Matt Bierner 已提交
2848
	interface ExternalUriOpenerMetadata {
M
Matt Bierner 已提交
2849

M
Matt Bierner 已提交
2850 2851 2852 2853 2854 2855 2856
		/**
		 * List of uri schemes the opener is triggered for.
		 *
		 * Currently only `http` and `https` are supported.
		 */
		readonly schemes: readonly string[]

M
Matt Bierner 已提交
2857 2858
		/**
		 * Text displayed to the user that explains what the opener does.
2859
		 *
M
Matt Bierner 已提交
2860
		 * For example, 'Open in browser preview'
2861
		 */
M
Matt Bierner 已提交
2862
		readonly label: string;
2863 2864 2865 2866 2867 2868
	}

	namespace window {
		/**
		 * Register a new `ExternalUriOpener`.
		 *
2869
		 * When a uri is about to be opened, an `onOpenExternalUri:SCHEME` activation event is fired.
2870
		 *
M
Matt Bierner 已提交
2871 2872
		 * @param id Unique id of the opener, such as `myExtension.browserPreview`. This is used in settings
		 *   and commands to identify the opener.
2873
		 * @param opener Opener to register.
M
Matt Bierner 已提交
2874
		 * @param metadata Additional information about the opener.
2875 2876
		 *
		* @returns Disposable that unregisters the opener.
M
Matt Bierner 已提交
2877 2878
		*/
		export function registerExternalUriOpener(id: string, opener: ExternalUriOpener, metadata: ExternalUriOpenerMetadata): Disposable;
2879 2880
	}

2881 2882
	interface OpenExternalOptions {
		/**
2883 2884
		 * Allows using openers contributed by extensions through  `registerExternalUriOpener`
		 * when opening the resource.
2885
		 *
2886
		 * If `true`, VS Code will check if any contributed openers can handle the
2887 2888
		 * uri, and fallback to the default opener behavior.
		 *
2889
		 * If it is string, this specifies the id of the `ExternalUriOpener`
2890 2891 2892 2893 2894 2895 2896 2897 2898 2899
		 * that should be used if it is available. Use `'default'` to force VS Code's
		 * standard external opener to be used.
		 */
		readonly allowContributedOpeners?: boolean | string;
	}

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

J
Johannes Rieken 已提交
2900
	//#endregion
2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917

	//#region https://github.com/Microsoft/vscode/issues/15178

	// TODO@API must be a class
	export interface OpenEditorInfo {
		name: string;
		resource: Uri;
	}

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

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

	//#endregion
2918

2919
	//#region https://github.com/microsoft/vscode/issues/120173
L
Ladislau Szomoru 已提交
2920 2921 2922
	/**
	 * The object describing the properties of the workspace trust request
	 */
2923
	export interface WorkspaceTrustRequestOptions {
L
Ladislau Szomoru 已提交
2924 2925
		/**
		 * When true, a modal dialog will be used to request workspace trust.
S
SteVen Batten 已提交
2926
		 * When false, a badge will be displayed on the settings gear activity bar item.
L
Ladislau Szomoru 已提交
2927
		 */
L
Ladislau Szomoru 已提交
2928
		readonly modal: boolean;
L
Ladislau Szomoru 已提交
2929 2930
	}

2931 2932
	export namespace workspace {
		/**
S
SteVen Batten 已提交
2933
		 * When true, the user has explicitly trusted the contents of the workspace.
2934
		 */
S
SteVen Batten 已提交
2935
		export const isTrusted: boolean;
2936 2937 2938

		/**
		 * Prompt the user to chose whether to trust the current workspace
2939
		 * @param options Optional object describing the properties of the
S
SteVen Batten 已提交
2940
		 * workspace trust request. Defaults to { modal: false }
2941 2942 2943
		 * When using a non-modal request, the promise will return immediately.
		 * Any time trust is not given, it is recommended to use the
		 * `onDidReceiveWorkspaceTrust` event to listen for trust changes.
2944
		 */
S
SteVen Batten 已提交
2945
		export function requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Thenable<boolean>;
2946 2947

		/**
S
SteVen Batten 已提交
2948
		 * Event that fires when the current workspace has been trusted.
2949
		 */
S
SteVen Batten 已提交
2950
		export const onDidReceiveWorkspaceTrust: Event<void>;
2951 2952 2953
	}

	//#endregion
2954

2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965
	//#region https://github.com/microsoft/vscode/issues/115807

	export interface Webview {
		/**
		 * @param message A json serializable message to send to the webview.
		 *
		 *   For older versions of vscode, if an `ArrayBuffer` is included in `message`,
		 *   it will not be serialized properly and will not be received by the webview.
		 *   Similarly any TypedArrays, such as a `Uint8Array`, will be very inefficiently
		 *   serialized and will also not be recreated as a typed array inside the webview.
		 *
2966
		 *   However if your extension targets vscode 1.56+ in the `engines` field of its
2967 2968 2969 2970 2971 2972 2973
		 *   `package.json` any `ArrayBuffer` values that appear in `message` will be more
		 *   efficiently transferred to the webview and will also be recreated inside of
		 *   the webview.
		 */
		postMessage(message: any): Thenable<boolean>;
	}

2974
	//#endregion
2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990

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

	export interface PortAttributes {
		port: number;
		autoForwardAction: PortAutoForwardAction
	}

	export interface PortAttributesProvider {
2991
		/**
2992 2993 2994
		 * 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.
2995
		 */
2996
		providePortAttributes(port: number, pid: number | undefined, commandLine: string | undefined, token: CancellationToken): ProviderResult<PortAttributes>;
2997 2998 2999 3000 3001 3002 3003 3004 3005 3006
	}

	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
		 * this information with a PortAttributesProvider the extension can tell VS Code that these ports should be
		 * 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
3007 3008
		 * 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.
3009
		 * The `portRange` is start inclusive and end exclusive.
3010 3011
		 * @param provider The PortAttributesProvider
		 */
3012
		export function registerPortAttributesProvider(portSelector: { pid?: number, portRange?: [number, number], commandMatcher?: RegExp }, provider: PortAttributesProvider): Disposable;
3013 3014
	}
	//#endregion
3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026

	// region https://github.com/microsoft/vscode/issues/119904 @eamodio

	export interface SourceControlInputBox {

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

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