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

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

17 18
declare module 'vscode' {

19
	// eslint-disable-next-line vscode-dts-region-comments
A
Alex Ross 已提交
20
	//#region @alexdima - resolvers
A
Alex Dima 已提交
21

22 23 24 25 26 27 28
	export interface MessageOptions {
		/**
		 * Do not render a native message box.
		 */
		useCustom?: boolean;
	}

A
Tweaks  
Alex Dima 已提交
29 30 31 32
	export interface RemoteAuthorityResolverContext {
		resolveAttempt: number;
	}

A
Alex Dima 已提交
33 34 35
	export class ResolvedAuthority {
		readonly host: string;
		readonly port: number;
36
		readonly connectionToken: string | undefined;
A
Alex Dima 已提交
37

38
		constructor(host: string, port: number, connectionToken?: string);
A
Alex Dima 已提交
39 40
	}

41
	export interface ResolvedOptions {
R
rebornix 已提交
42
		extensionHostEnv?: { [key: string]: string | null; };
A
Alexandru Dima 已提交
43

A
Alex Dima 已提交
44
		isTrusted?: boolean;
45 46
	}

47
	export interface TunnelOptions {
R
rebornix 已提交
48
		remoteAddress: { port: number, host: string; };
A
Alex Ross 已提交
49 50 51
		// The desired local port. If this port can't be used, then another will be chosen.
		localAddressPort?: number;
		label?: string;
52
		public?: boolean;
A
Alex Ross 已提交
53
		protocol?: string;
54 55
	}

A
Alex Ross 已提交
56
	export interface TunnelDescription {
R
rebornix 已提交
57
		remoteAddress: { port: number, host: string; };
A
Alex Ross 已提交
58
		//The complete local address(ex. localhost:1234)
R
rebornix 已提交
59
		localAddress: { port: number, host: string; } | string;
60
		public?: boolean;
A
Alex Ross 已提交
61 62
		// If protocol is not provided it is assumed to be http, regardless of the localAddress.
		protocol?: string;
A
Alex Ross 已提交
63 64 65
	}

	export interface Tunnel extends TunnelDescription {
A
Alex Ross 已提交
66 67
		// Implementers of Tunnel should fire onDidDispose when dispose is called.
		onDidDispose: Event<void>;
68
		dispose(): void | Thenable<void>;
69 70 71
	}

	/**
72 73
	 * Used as part of the ResolverResult if the extension has any candidate,
	 * published, or forwarded ports.
74 75 76 77
	 */
	export interface TunnelInformation {
		/**
		 * Tunnels that are detected by the extension. The remotePort is used for display purposes.
A
Alex Ross 已提交
78
		 * The localAddress should be the complete local address (ex. localhost:1234) for connecting to the port. Tunnels provided through
79 80
		 * detected are read-only from the forwarded ports UI.
		 */
A
Alex Ross 已提交
81
		environmentTunnels?: TunnelDescription[];
A
Alex Ross 已提交
82

83 84
	}

85
	export interface TunnelCreationOptions {
86 87 88 89 90 91
		/**
		 * True when the local operating system will require elevation to use the requested local port.
		 */
		elevationRequired?: boolean;
	}

92 93 94 95 96 97
	export enum CandidatePortSource {
		None = 0,
		Process = 1,
		Output = 2
	}

98
	export type ResolverResult = ResolvedAuthority & ResolvedOptions & TunnelInformation;
99

A
Tweaks  
Alex Dima 已提交
100 101 102 103 104 105 106
	export class RemoteAuthorityResolverError extends Error {
		static NotAvailable(message?: string, handled?: boolean): RemoteAuthorityResolverError;
		static TemporarilyNotAvailable(message?: string): RemoteAuthorityResolverError;

		constructor(message?: string);
	}

A
Alex Dima 已提交
107
	export interface RemoteAuthorityResolver {
108 109 110
		/**
		 * Resolve the authority part of the current opened `vscode-remote://` URI.
		 *
M
Matt Bierner 已提交
111 112
		 * This method will be invoked once during the startup of the editor and again each time
		 * the editor detects a disconnection.
113 114 115 116
		 *
		 * @param authority The authority part of the current opened `vscode-remote://` URI.
		 * @param context A context indicating if this is the first call or a subsequent call.
		 */
117
		resolve(authority: string, context: RemoteAuthorityResolverContext): ResolverResult | Thenable<ResolverResult>;
118 119 120 121 122 123 124 125

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

126 127 128 129
		/**
		 * 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.
130 131 132
		 *
		 * 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.
133
		 */
134
		tunnelFactory?: (tunnelOptions: TunnelOptions, tunnelCreationOptions: TunnelCreationOptions) => Thenable<Tunnel> | undefined;
135

136
		/**p
137 138 139
		 * Provides filtering for candidate ports.
		 */
		showCandidatePort?: (host: string, port: number, detail: string) => Thenable<boolean>;
140 141 142 143 144 145 146

		/**
		 * Lets the resolver declare which tunnel factory features it supports.
		 * UNDER DISCUSSION! MAY CHANGE SOON.
		 */
		tunnelFeatures?: {
			elevation: boolean;
147
			public: boolean;
148
		};
149 150

		candidatePortSource?: CandidatePortSource;
151 152
	}

153 154 155 156 157 158 159 160 161 162 163 164
	/**
	 * More options to be used when getting an {@link AuthenticationSession} from an {@link AuthenticationProvider}.
	 */
	export interface AuthenticationGetSessionOptions {
		/**
		 * Whether we should attempt to reauthenticate even if there is already a session available.
		 *
		 * If true, a modal dialog will be shown asking the user to sign in again. This is mostly used for scenarios
		 * where the token needs to be re minted because it has lost some authorization.
		 *
		 * Defaults to false.
		 */
165
		forceNewSession?: boolean | { detail: string };
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
	}

	export namespace authentication {
		/**
		 * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
		 * registered, or if the user does not consent to sharing authentication information with
		 * the extension. If there are multiple sessions with the same scopes, the user will be shown a
		 * quickpick to select which account they would like to use.
		 *
		 * Currently, there are only two authentication providers that are contributed from built in extensions
		 * to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
		 * @param providerId The id of the provider to use
		 * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
		 * @param options The {@link AuthenticationGetSessionOptions} to use
		 * @returns A thenable that resolves to an authentication session
		 */
182
		export function getSession(providerId: string, scopes: readonly string[], options: AuthenticationGetSessionOptions & { forceNewSession: true | { detail: string } }): Thenable<AuthenticationSession>;
183 184
	}

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

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

202 203 204 205
		/**
		 * Fired when the list of tunnels has changed.
		 */
		export const onDidChangeTunnels: Event<void>;
A
Alex Dima 已提交
206 207
	}

208 209 210 211 212 213 214 215
	export interface ResourceLabelFormatter {
		scheme: string;
		authority?: string;
		formatting: ResourceLabelFormatting;
	}

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

A
Alex Dima 已提交
227 228
	export namespace workspace {
		export function registerRemoteAuthorityResolver(authorityPrefix: string, resolver: RemoteAuthorityResolver): Disposable;
229
		export function registerResourceLabelFormatter(formatter: ResourceLabelFormatter): Disposable;
230
	}
231

C
Christof Marti 已提交
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
	export namespace env {

		/**
		 * The authority part of the current opened `vscode-remote://` URI.
		 * Defined by extensions, e.g. `ssh-remote+${host}` for remotes using a secure shell.
		 *
		 * *Note* that the value is `undefined` when there is no remote extension host but that the
		 * value is defined in all extension hosts (local and remote) in case a remote extension host
		 * exists. Use {@link Extension.extensionKind} to know if
		 * a specific extension runs remote or not.
		 */
		export const remoteAuthority: string | undefined;

	}

247 248
	//#endregion

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

251 252
	export interface WebviewEditorInset {
		readonly editor: TextEditor;
253 254
		readonly line: number;
		readonly height: number;
255 256 257
		readonly webview: Webview;
		readonly onDidDispose: Event<void>;
		dispose(): void;
258 259
	}

260
	export namespace window {
261
		export function createWebviewTextEditorInset(editor: TextEditor, line: number, height: number, options?: WebviewOptions): WebviewEditorInset;
A
Alex Dima 已提交
262 263 264 265
	}

	//#endregion

J
Johannes Rieken 已提交
266
	//#region read/write in chunks: https://github.com/microsoft/vscode/issues/84515
267 268

	export interface FileSystemProvider {
R
rebornix 已提交
269
		open?(resource: Uri, options: { create: boolean; }): number | Thenable<number>;
270 271 272 273 274 275 276
		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 已提交
277
	//#region TextSearchProvider: https://github.com/microsoft/vscode/issues/59921
278

279 280 281
	/**
	 * The parameters of a query for text search.
	 */
282
	export interface TextSearchQuery {
283 284 285
		/**
		 * The text pattern to search for.
		 */
286
		pattern: string;
287

R
Rob Lourens 已提交
288 289 290 291 292
		/**
		 * Whether or not `pattern` should match multiple lines of text.
		 */
		isMultiline?: boolean;

293 294 295
		/**
		 * Whether or not `pattern` should be interpreted as a regular expression.
		 */
R
Rob Lourens 已提交
296
		isRegExp?: boolean;
297 298 299 300

		/**
		 * Whether or not the search should be case-sensitive.
		 */
R
Rob Lourens 已提交
301
		isCaseSensitive?: boolean;
302 303 304 305

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

309 310
	/**
	 * A file glob pattern to match file paths against.
311
	 * TODO@roblourens merge this with the GlobPattern docs/definition in vscode.d.ts.
M
Matt Bierner 已提交
312
	 * @see {@link GlobPattern}
313 314 315 316 317 318
	 */
	export type GlobString = string;

	/**
	 * Options common to file and text search
	 */
R
Rob Lourens 已提交
319
	export interface SearchOptions {
320 321 322
		/**
		 * The root folder to search within.
		 */
323
		folder: Uri;
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338

		/**
		 * 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 已提交
339
		useIgnoreFiles: boolean;
340 341 342 343 344

		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
345
		followSymlinks: boolean;
P
pkoushik 已提交
346 347 348 349 350 351

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

R
Rob Lourens 已提交
354 355
	/**
	 * Options to specify the size of the result text preview.
R
Rob Lourens 已提交
356
	 * These options don't affect the size of the match itself, just the amount of preview text.
R
Rob Lourens 已提交
357
	 */
358
	export interface TextSearchPreviewOptions {
359
		/**
R
Rob Lourens 已提交
360
		 * The maximum number of lines in the preview.
R
Rob Lourens 已提交
361
		 * Only search providers that support multiline search will ever return more than one line in the match.
362
		 */
R
Rob Lourens 已提交
363
		matchLines: number;
R
Rob Lourens 已提交
364 365 366 367

		/**
		 * The maximum number of characters included per line.
		 */
R
Rob Lourens 已提交
368
		charsPerLine: number;
369 370
	}

371 372 373
	/**
	 * Options that apply to text search.
	 */
R
Rob Lourens 已提交
374
	export interface TextSearchOptions extends SearchOptions {
375
		/**
376
		 * The maximum number of results to be returned.
377
		 */
378 379
		maxResults: number;

R
Rob Lourens 已提交
380 381 382
		/**
		 * Options to specify the size of the result text preview.
		 */
383
		previewOptions?: TextSearchPreviewOptions;
384 385 386 387

		/**
		 * Exclude files larger than `maxFileSize` in bytes.
		 */
388
		maxFileSize?: number;
389 390 391 392 393

		/**
		 * Interpret files using this encoding.
		 * See the vscode setting `"files.encoding"`
		 */
394
		encoding?: string;
395 396 397 398 399 400 401 402 403 404

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

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

407 408 409 410 411 412 413 414
	/**
	 * Represents the severiry of a TextSearchComplete message.
	 */
	export enum TextSearchCompleteMessageType {
		Information = 1,
		Warning = 2,
	}

415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
	/**
	 * A message regarding a completed search.
	 */
	export interface TextSearchCompleteMessage {
		/**
		 * Markdown text of the message.
		 */
		text: string,
		/**
		 * Whether the source of the message is trusted, command links are disabled for untrusted message sources.
		 * Messaged are untrusted by default.
		 */
		trusted?: boolean,
		/**
		 * The message type, this affects how the message will be rendered.
		 */
		type: TextSearchCompleteMessageType,
	}

434 435 436 437 438 439
	/**
	 * Information collected when text search is complete.
	 */
	export interface TextSearchComplete {
		/**
		 * Whether the search hit the limit on the maximum number of search results.
440
		 * `maxResults` on {@linkcode TextSearchOptions} specifies the max number of results.
441 442 443 444 445
		 * - 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;
446 447 448 449

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

R
Rob Lourens 已提交
459 460 461
	/**
	 * A preview of the text result.
	 */
462
	export interface TextSearchMatchPreview {
463
		/**
R
Rob Lourens 已提交
464
		 * The matching lines of text, or a portion of the matching line that contains the match.
465 466 467 468 469
		 */
		text: string;

		/**
		 * The Range within `text` corresponding to the text of the match.
470
		 * The number of matches must match the TextSearchMatch's range property.
471
		 */
472
		matches: Range | Range[];
473 474 475 476 477
	}

	/**
	 * A match from a text search
	 */
478
	export interface TextSearchMatch {
479 480 481
		/**
		 * The uri for the matching document.
		 */
482
		uri: Uri;
483 484

		/**
485
		 * The range of the match within the document, or multiple ranges for multiple matches.
486
		 */
487
		ranges: Range | Range[];
R
Rob Lourens 已提交
488

489
		/**
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511
		 * 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.
512
		 */
513
		lineNumber: number;
514 515
	}

516 517
	export type TextSearchResult = TextSearchMatch | TextSearchContext;

R
Rob Lourens 已提交
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561
	/**
	 * 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;
	}

562
	/**
R
Rob Lourens 已提交
563 564
	 * A FileSearchProvider provides search results for files in the given folder that match a query string. It can be invoked by quickopen or other extensions.
	 *
M
Matt Bierner 已提交
565
	 * A FileSearchProvider is the more powerful of two ways to implement file search in the editor. Use a FileSearchProvider if you wish to search within a folder for
R
Rob Lourens 已提交
566 567 568 569
	 * 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.
570
	 */
571
	export interface FileSearchProvider {
572 573 574 575 576 577
		/**
		 * 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.
		 */
578
		provideFileSearchResults(query: FileSearchQuery, options: FileSearchOptions, token: CancellationToken): ProviderResult<Uri[]>;
579
	}
580

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

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

R
Rob Lourens 已提交
605 606 607 608
	//#endregion

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

609 610 611
	/**
	 * Options that can be set on a findTextInFiles search.
	 */
R
Rob Lourens 已提交
612
	export interface FindTextInFilesOptions {
613
		/**
M
Matt Bierner 已提交
614 615 616
		 * A {@link GlobPattern glob pattern} that defines the files to search for. The glob pattern
		 * will be matched against the file paths of files relative to their workspace. Use a {@link RelativePattern relative pattern}
		 * to restrict the search results to a {@link WorkspaceFolder workspace folder}.
617
		 */
618
		include?: GlobPattern;
619 620

		/**
M
Matt Bierner 已提交
621
		 * A {@link GlobPattern glob pattern} that defines files and folders to exclude. The glob pattern
622 623
		 * will be matched against the file paths of resulting matches relative to their workspace. When `undefined`, default excludes will
		 * apply.
624
		 */
625 626 627 628
		exclude?: GlobPattern;

		/**
		 * Whether to use the default and user-configured excludes. Defaults to true.
629
		 */
630
		useDefaultExcludes?: boolean;
631 632 633 634

		/**
		 * The maximum number of results to search for
		 */
R
Rob Lourens 已提交
635
		maxResults?: number;
636 637 638 639 640

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

P
pkoushik 已提交
643 644 645 646
		/**
		 * Whether global files that exclude files, like .gitignore, should be respected.
		 * See the vscode setting `"search.useGlobalIgnoreFiles"`.
		 */
647
		useGlobalIgnoreFiles?: boolean;
P
pkoushik 已提交
648

649 650 651 652
		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
653
		followSymlinks?: boolean;
654 655 656 657 658

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

R
Rob Lourens 已提交
661 662 663
		/**
		 * Options to specify the size of the result text preview.
		 */
664
		previewOptions?: TextSearchPreviewOptions;
665 666 667 668 669 670 671 672 673 674

		/**
		 * 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 已提交
675 676
	}

677
	export namespace workspace {
678
		/**
M
Matt Bierner 已提交
679
		 * Search text in files across all {@link workspace.workspaceFolders workspace folders} in the workspace.
680 681 682 683 684
		 * @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.
		 */
685
		export function findTextInFiles(query: TextSearchQuery, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
686 687

		/**
M
Matt Bierner 已提交
688
		 * Search text in files across all {@link workspace.workspaceFolders workspace folders} in the workspace.
689 690 691 692 693 694
		 * @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.
		 */
695
		export function findTextInFiles(query: TextSearchQuery, options: FindTextInFilesOptions, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
696 697
	}

J
Johannes Rieken 已提交
698
	//#endregion
699

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

J
Joao Moreno 已提交
702 703 704
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
705 706 707 708 709 710 711
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

712 713 714 715 716 717
	export namespace commands {

		/**
		 * Registers a diff information command that can be invoked via a keyboard shortcut,
		 * a menu item, an action, or directly.
		 *
M
Matt Bierner 已提交
718
		 * Diff information commands are different from ordinary {@link commands.registerCommand commands} as
719 720 721 722 723
		 * they only execute when there is an active diff editor when the command is called, and the diff
		 * information has been computed. Also, the command handler of an editor command has access to
		 * the diff information.
		 *
		 * @param command A unique identifier for the command.
M
Matt Bierner 已提交
724
		 * @param callback A command handler function with access to the {@link LineChange diff information}.
725 726 727 728 729
		 * @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;
	}
730

J
Johannes Rieken 已提交
731 732
	//#endregion

733
	// eslint-disable-next-line vscode-dts-region-comments
734
	//#region @roblourens: new debug session option for simple UI 'managedByParent' (see https://github.com/microsoft/vscode/issues/128588)
735 736 737 738 739 740

	/**
	 * Options for {@link debug.startDebugging starting a debug session}.
	 */
	export interface DebugSessionOptions {

741 742 743 744 745 746
		debugUI?: {
			/**
			 * When true, the debug toolbar will not be shown for this session, the window statusbar color will not be changed, and the debug viewlet will not be automatically revealed.
			 */
			simple?: boolean;
		}
747 748 749 750 751

		/**
		 * When true, a save will not be triggered for open editors when starting a debug session, regardless of the value of the `debug.saveBeforeStart` setting.
		 */
		suppressSaveBeforeStart?: boolean;
752 753 754 755
	}

	//#endregion

756
	// eslint-disable-next-line vscode-dts-region-comments
757
	//#region @weinand: variables view action contributions
758

759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774
	/**
	 * 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 已提交
775 776
	//#endregion

777
	// eslint-disable-next-line vscode-dts-region-comments
778
	//#region @joaomoreno: SCM validation
779

J
Joao Moreno 已提交
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805
	/**
	 * 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.
		 */
806
		readonly message: string | MarkdownString;
J
Joao Moreno 已提交
807 808 809 810 811 812 813 814 815 816 817 818

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

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

819 820 821
		/**
		 * Shows a transient contextual message on the input.
		 */
822
		showValidationMessage(message: string | MarkdownString, type: SourceControlInputBoxValidationType): void;
823

J
Joao Moreno 已提交
824 825 826 827
		/**
		 * A validation function for the input box. It's possible to change
		 * the validation provider simply by setting this property to a different function.
		 */
828
		validateInput?(value: string, cursorPosition: number): ProviderResult<SourceControlInputBoxValidation>;
J
Joao Moreno 已提交
829
	}
M
Matt Bierner 已提交
830

J
Johannes Rieken 已提交
831 832
	//#endregion

833
	// eslint-disable-next-line vscode-dts-region-comments
834
	//#region @joaomoreno: SCM selected provider
835 836 837 838 839 840 841 842 843 844 845 846

	export interface SourceControl {

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

		/**
		 * An event signaling when the selection state changes.
		 */
		readonly onDidChangeSelection: Event<boolean>;
847 848 849 850
	}

	//#endregion

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

853 854
	export interface TerminalDataWriteEvent {
		/**
M
Matt Bierner 已提交
855
		 * The {@link Terminal} for which the data was written.
856 857 858 859 860 861 862 863
		 */
		readonly terminal: Terminal;
		/**
		 * The data being written.
		 */
		readonly data: string;
	}

D
Daniel Imms 已提交
864 865
	namespace window {
		/**
D
Daniel Imms 已提交
866 867 868
		 * 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 已提交
869 870 871 872 873 874 875 876 877
		 */
		export const onDidWriteTerminalData: Event<TerminalDataWriteEvent>;
	}

	//#endregion

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

	/**
M
Matt Bierner 已提交
878
	 * An {@link Event} which fires when a {@link Terminal}'s dimensions change.
D
Daniel Imms 已提交
879 880 881
	 */
	export interface TerminalDimensionsChangeEvent {
		/**
M
Matt Bierner 已提交
882
		 * The {@link Terminal} for which the dimensions have changed.
D
Daniel Imms 已提交
883 884 885
		 */
		readonly terminal: Terminal;
		/**
M
Matt Bierner 已提交
886
		 * The new value for the {@link Terminal.dimensions terminal's dimensions}.
D
Daniel Imms 已提交
887 888 889
		 */
		readonly dimensions: TerminalDimensions;
	}
890

D
Daniel Imms 已提交
891
	export namespace window {
D
Daniel Imms 已提交
892
		/**
M
Matt Bierner 已提交
893
		 * An event which fires when the {@link Terminal.dimensions dimensions} of the terminal change.
D
Daniel Imms 已提交
894 895 896 897 898
		 */
		export const onDidChangeTerminalDimensions: Event<TerminalDimensionsChangeEvent>;
	}

	export interface Terminal {
899
		/**
900 901 902
		 * 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.
903
		 */
904
		readonly dimensions: TerminalDimensions | undefined;
D
Daniel Imms 已提交
905 906
	}

907 908
	//#endregion

909 910
	//#region Terminal location https://github.com/microsoft/vscode/issues/45407

911 912 913 914 915 916 917 918 919
	export interface TerminalOptions {
		location?: TerminalLocation | TerminalEditorLocationOptions | TerminalSplitLocationOptions;
	}

	export interface ExtensionTerminalOptions {
		location?: TerminalLocation | TerminalEditorLocationOptions | TerminalSplitLocationOptions;
	}

	export enum TerminalLocation {
M
meganrogge 已提交
920 921
		Panel = 1,
		Editor = 2,
922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946
	}

	export interface TerminalEditorLocationOptions {
		/**
		 * A view column in which the {@link Terminal terminal} should be shown in the editor area.
		 * Use {@link ViewColumn.Active active} to open in the active editor group, other values are
		 * adjusted to be `Min(column, columnCount + 1)`, the
		 * {@link ViewColumn.Active active}-column is not adjusted. Use
		 * {@linkcode ViewColumn.Beside} to open the editor to the side of the currently active one.
		 */
		viewColumn: ViewColumn;
		/**
		 * An optional flag that when `true` will stop the {@link Terminal} from taking focus.
		 */
		preserveFocus?: boolean;
	}

	export interface TerminalSplitLocationOptions {
		/**
		 * The parent terminal to split this terminal beside. This works whether the parent terminal
		 * is in the panel or the editor area.
		 */
		parentTerminal: Terminal;
	}

947 948
	//#endregion

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

951
	export interface Pseudoterminal {
D
Daniel Imms 已提交
952
		/**
953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968
		 * An event that when fired allows changing the name of the terminal.
		 *
		 * **Example:** Change the terminal name to "My new terminal".
		 * ```typescript
		 * const writeEmitter = new vscode.EventEmitter<string>();
		 * const changeNameEmitter = new vscode.EventEmitter<string>();
		 * const pty: vscode.Pseudoterminal = {
		 *   onDidWrite: writeEmitter.event,
		 *   onDidChangeName: changeNameEmitter.event,
		 *   open: () => changeNameEmitter.fire('My new terminal'),
		 *   close: () => {}
		 * };
		 * vscode.window.createTerminal({ name: 'My terminal', pty });
		 * ```
		 */
		onDidChangeName?: Event<string>;
969 970 971 972
	}

	//#endregion

973
	// eslint-disable-next-line vscode-dts-region-comments
974
	//#region @jrieken -> exclusive document filters
975 976

	export interface DocumentFilter {
977
		readonly exclusive?: boolean;
978 979 980
	}

	//#endregion
C
Christof Marti 已提交
981

982
	//#region Tree View: https://github.com/microsoft/vscode/issues/61313 @alexr00
983
	export interface TreeView<T> extends Disposable {
984
		reveal(element: T | undefined, options?: { select?: boolean, focus?: boolean, expand?: boolean | number; }): Thenable<void>;
985
	}
986
	//#endregion
987

988
	//#region Custom Tree View Drag and Drop https://github.com/microsoft/vscode/issues/32592
989 990 991 992
	/**
	 * A data provider that provides tree data
	 */
	export interface TreeDataProvider<T> {
993
		/**
994
		 * An optional event to signal that an element or root has changed.
995 996 997
		 * This will trigger the view to update the changed element/root and its children recursively (if shown).
		 * To signal that root has changed, do not pass any argument or pass `undefined` or `null`.
		 */
998 999 1000 1001
		onDidChangeTreeData2?: Event<T | T[] | undefined | null | void>;
	}

	export interface TreeViewOptions<T> {
1002 1003 1004
		/**
		* An optional interface to implement drag and drop in the tree view.
		*/
1005
		dragAndDropController?: DragAndDropController<T>;
1006 1007
	}

A
Alex Ross 已提交
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017
	export interface TreeDataTransferItem {
		asString(): Thenable<string>;
	}

	export interface TreeDataTransfer {
		/**
		 * A map containing a mapping of the mime type of the corresponding data.
		 * The type for tree elements is text/treeitem.
		 * For example, you can reconstruct the your tree elements:
		 * ```ts
A
Alex Ross 已提交
1018
		 * JSON.parse(await (items.get('text/treeitem')!.asString()))
A
Alex Ross 已提交
1019 1020
		 * ```
		 */
A
Alex Ross 已提交
1021
		items: { get: (mimeType: string) => TreeDataTransferItem | undefined };
A
Alex Ross 已提交
1022 1023
	}

1024
	export interface DragAndDropController<T> extends Disposable {
A
Alex Ross 已提交
1025 1026
		readonly supportedTypes: string[];

A
Alex Ross 已提交
1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039
		/**
		 * todo@API maybe
		 *
		 * When the user drops an item from this DragAndDropController on **another tree item** in **the same tree**,
		 * `onWillDrop` will be called with the dropped tree item. This is the DragAndDropController's opportunity to
		 * package the data from the dropped tree item into whatever format they want the target tree item to receive.
		 *
		 * The returned `TreeDataTransfer` will be merged with the original`TreeDataTransfer` for the operation.
		 *
		 * Note for implementation later: This means that the `text/treeItem` mime type will go away.
		 *
		 * @param source
		 */
M
Matt Bierner 已提交
1040
		// onWillDrop?(source: T): Thenable<TreeDataTransfer>;
J
Johannes Rieken 已提交
1041

1042
		/**
1043
		 * Extensions should fire `TreeDataProvider.onDidChangeTreeData` for any elements that need to be refreshed.
1044
		 *
1045 1046
		 * @param source
		 * @param target
1047
		 */
A
Alex Ross 已提交
1048
		onDrop(source: TreeDataTransfer, target: T): Thenable<void>;
1049 1050 1051
	}
	//#endregion

1052
	//#region Task presentation group: https://github.com/microsoft/vscode/issues/47265
1053 1054 1055 1056 1057
	export interface TaskPresentationOptions {
		/**
		 * Controls whether the task is executed in a specific terminal group using split panes.
		 */
		group?: string;
1058

1059
		/**
1060 1061 1062
		 * Controls whether the terminal is closed after executing the task.
		 */
		close?: boolean;
1063 1064
	}
	//#endregion
1065

1066
	//#region Custom editor move https://github.com/microsoft/vscode/issues/86146
1067

1068
	// TODO: Also for custom editor
1069

1070
	export interface CustomTextEditorProvider {
M
Matt Bierner 已提交
1071

1072 1073 1074 1075
		/**
		 * Handle when the underlying resource for a custom editor is renamed.
		 *
		 * This allows the webview for the editor be preserved throughout the rename. If this method is not implemented,
M
Matt Bierner 已提交
1076
		 * the editor will destroy the previous custom editor and create a replacement one.
1077 1078 1079
		 *
		 * @param newDocument New text document to use for the custom editor.
		 * @param existingWebviewPanel Webview panel for the custom editor.
1080
		 * @param token A cancellation token that indicates the result is no longer needed.
1081 1082 1083
		 *
		 * @return Thenable indicating that the webview editor has been moved.
		 */
J
Johannes Rieken 已提交
1084
		// eslint-disable-next-line vscode-dts-provider-naming
1085
		moveCustomTextEditor?(newDocument: TextDocument, existingWebviewPanel: WebviewPanel, token: CancellationToken): Thenable<void>;
1086 1087 1088
	}

	//#endregion
1089

J
Johannes Rieken 已提交
1090
	//#region allow QuickPicks to skip sorting: https://github.com/microsoft/vscode/issues/73904
P
Peter Elmers 已提交
1091 1092 1093

	export interface QuickPick<T extends QuickPickItem> extends QuickInput {
		/**
1094 1095
		 * An optional flag to sort the final results by index of first query match in label. Defaults to true.
		 */
P
Peter Elmers 已提交
1096
		sortByLabel: boolean;
J
Johannes Rieken 已提交
1097 1098 1099 1100 1101 1102 1103
	}

	//#endregion

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

	export interface QuickPick<T extends QuickPickItem> extends QuickInput {
1104 1105 1106 1107 1108

		/*
		 * An optional flag that can be set to true to maintain the scroll position of the quick pick when the quick pick items are updated. Defaults to false.
		 */
		keepScrollPosition?: boolean;
P
Peter Elmers 已提交
1109 1110 1111
	}

	//#endregion
M
Matt Bierner 已提交
1112

1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147
	//#region https://github.com/microsoft/vscode/issues/124970, Cell Execution State

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

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

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

1148
	export namespace notebooks {
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159

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

	//#endregion

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

1162 1163 1164
	export interface NotebookCellOutput {
		id: string;
	}
1165 1166 1167

	//#endregion

1168 1169
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookEditor

J
Johannes Rieken 已提交
1170 1171 1172
	/**
	 * Represents a notebook editor that is attached to a {@link NotebookDocument notebook}.
	 */
1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195
	export enum NotebookEditorRevealType {
		/**
		 * The range will be revealed with as little scrolling as possible.
		 */
		Default = 0,

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

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

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

J
Johannes Rieken 已提交
1196 1197 1198
	/**
	 * Represents a notebook editor that is attached to a {@link NotebookDocument notebook}.
	 */
1199 1200 1201 1202
	export interface NotebookEditor {
		/**
		 * The document associated with this notebook editor.
		 */
J
Johannes Rieken 已提交
1203
		//todo@api rename to notebook?
1204 1205 1206 1207 1208 1209 1210
		readonly document: NotebookDocument;

		/**
		 * The selections on this notebook editor.
		 *
		 * The primary selection (or focused range) is `selections[0]`. When the document has no cells, the primary selection is empty `{ start: 0, end: 0 }`;
		 */
1211
		selections: NotebookRange[];
1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229

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

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

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

1232
	export interface NotebookDocumentMetadataChangeEvent {
R
rebornix 已提交
1233
		/**
M
Matt Bierner 已提交
1234
		 * The {@link NotebookDocument notebook document} for which the document metadata have changed.
R
rebornix 已提交
1235
		 */
J
Johannes Rieken 已提交
1236
		//todo@API rename to notebook?
1237 1238 1239
		readonly document: NotebookDocument;
	}

1240
	export interface NotebookCellsChangeData {
R
rebornix 已提交
1241
		readonly start: number;
J
Johannes Rieken 已提交
1242
		// todo@API end? Use NotebookCellRange instead?
R
rebornix 已提交
1243
		readonly deletedCount: number;
J
Johannes Rieken 已提交
1244
		// todo@API removedCells, deletedCells?
1245
		readonly deletedItems: NotebookCell[];
J
Johannes Rieken 已提交
1246
		// todo@API addedCells, insertedCells, newCells?
R
rebornix 已提交
1247
		readonly items: NotebookCell[];
R
rebornix 已提交
1248 1249
	}

R
rebornix 已提交
1250
	export interface NotebookCellsChangeEvent {
1251
		/**
M
Matt Bierner 已提交
1252
		 * The {@link NotebookDocument notebook document} for which the cells have changed.
1253
		 */
J
Johannes Rieken 已提交
1254
		//todo@API rename to notebook?
R
rebornix 已提交
1255
		readonly document: NotebookDocument;
1256
		readonly changes: ReadonlyArray<NotebookCellsChangeData>;
R
rebornix 已提交
1257 1258
	}

1259
	export interface NotebookCellOutputsChangeEvent {
1260
		/**
M
Matt Bierner 已提交
1261
		 * The {@link NotebookDocument notebook document} for which the cell outputs have changed.
1262
		 */
J
Johannes Rieken 已提交
1263
		//todo@API remove? use cell.notebook instead?
R
rebornix 已提交
1264
		readonly document: NotebookDocument;
J
Johannes Rieken 已提交
1265
		// NotebookCellOutputsChangeEvent.cells vs NotebookCellMetadataChangeEvent.cell
1266
		readonly cells: NotebookCell[];
R
rebornix 已提交
1267
	}
1268

1269
	export interface NotebookCellMetadataChangeEvent {
1270
		/**
M
Matt Bierner 已提交
1271
		 * The {@link NotebookDocument notebook document} for which the cell metadata have changed.
1272
		 */
J
Johannes Rieken 已提交
1273
		//todo@API remove? use cell.notebook instead?
R
rebornix 已提交
1274
		readonly document: NotebookDocument;
J
Johannes Rieken 已提交
1275
		// NotebookCellOutputsChangeEvent.cells vs NotebookCellMetadataChangeEvent.cell
R
rebornix 已提交
1276
		readonly cell: NotebookCell;
R
rebornix 已提交
1277 1278
	}

1279
	export interface NotebookEditorSelectionChangeEvent {
R
rebornix 已提交
1280
		/**
M
Matt Bierner 已提交
1281
		 * The {@link NotebookEditor notebook editor} for which the selections have changed.
R
rebornix 已提交
1282
		 */
1283
		readonly notebookEditor: NotebookEditor;
1284
		readonly selections: ReadonlyArray<NotebookRange>
R
rebornix 已提交
1285 1286
	}

1287
	export interface NotebookEditorVisibleRangesChangeEvent {
R
rebornix 已提交
1288
		/**
M
Matt Bierner 已提交
1289
		 * The {@link NotebookEditor notebook editor} for which the visible ranges have changed.
R
rebornix 已提交
1290
		 */
1291
		readonly notebookEditor: NotebookEditor;
1292
		readonly visibleRanges: ReadonlyArray<NotebookRange>;
R
rebornix 已提交
1293 1294
	}

R
rebornix 已提交
1295

1296 1297 1298 1299
	export interface NotebookDocumentShowOptions {
		viewColumn?: ViewColumn;
		preserveFocus?: boolean;
		preview?: boolean;
1300
		selections?: NotebookRange[];
R
rebornix 已提交
1301 1302
	}

1303
	export namespace notebooks {
1304

1305

1306 1307

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

1309 1310
		export const onDidChangeNotebookDocumentMetadata: Event<NotebookDocumentMetadataChangeEvent>;
		export const onDidChangeNotebookCells: Event<NotebookCellsChangeEvent>;
J
Johannes Rieken 已提交
1311 1312

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

J
Johannes Rieken 已提交
1315
		// todo@API add onDidChangeNotebookCellMetadata
1316
		export const onDidChangeCellMetadata: Event<NotebookCellMetadataChangeEvent>;
R
rebornix 已提交
1317 1318
	}

1319 1320 1321 1322 1323 1324 1325
	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>;
1326

1327 1328 1329
		export function showNotebookDocument(uri: Uri, options?: NotebookDocumentShowOptions): Thenable<NotebookEditor>;
		export function showNotebookDocument(document: NotebookDocument, options?: NotebookDocumentShowOptions): Thenable<NotebookEditor>;
	}
1330

1331
	//#endregion
1332

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

1335 1336 1337 1338 1339 1340 1341
	// todo@API add NotebookEdit-type which handles all these cases?
	// export class NotebookEdit {
	// 	range: NotebookRange;
	// 	newCells: NotebookCellData[];
	// 	newMetadata?: NotebookDocumentMetadata;
	// 	constructor(range: NotebookRange, newCells: NotebookCellData)
	// }
J
Johannes Rieken 已提交
1342

1343 1344 1345
	// export class NotebookCellEdit {
	// 	newMetadata?: NotebookCellMetadata;
	// }
J
Johannes Rieken 已提交
1346

1347 1348 1349
	// export interface WorkspaceEdit {
	// 	set(uri: Uri, edits: TextEdit[] | NotebookEdit[]): void
	// }
1350

1351 1352
	export interface WorkspaceEdit {
		// todo@API add NotebookEdit-type which handles all these cases?
1353
		replaceNotebookMetadata(uri: Uri, value: { [key: string]: any }): void;
1354
		replaceNotebookCells(uri: Uri, range: NotebookRange, cells: NotebookCellData[], metadata?: WorkspaceEditEntryMetadata): void;
1355
		replaceNotebookCellMetadata(uri: Uri, index: number, cellMetadata: { [key: string]: any }, metadata?: WorkspaceEditEntryMetadata): void;
1356
	}
1357

1358
	export interface NotebookEditorEdit {
1359
		replaceMetadata(value: { [key: string]: any }): void;
1360
		replaceCells(start: number, end: number, cells: NotebookCellData[]): void;
1361
		replaceCellMetadata(index: number, metadata: { [key: string]: any }): void;
1362
	}
1363

1364
	export interface NotebookEditor {
1365
		/**
1366
		 * Perform an edit on the notebook associated with this notebook editor.
1367
		 *
1368 1369 1370
		 * The given callback-function is invoked with an {@link NotebookEditorEdit edit-builder} which must
		 * be used to make edits. Note that the edit-builder is only valid while the
		 * callback executes.
1371
		 *
1372 1373
		 * @param callback A function which can create edits using an {@link NotebookEditorEdit edit-builder}.
		 * @return A promise that resolves with a value indicating if the edits could be applied.
1374
		 */
1375 1376
		// @jrieken REMOVE maybe
		edit(callback: (editBuilder: NotebookEditorEdit) => void): Thenable<boolean>;
1377 1378
	}

1379 1380
	//#endregion

J
Johannes Rieken 已提交
1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookEditorDecorationType

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

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

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

1398
	export namespace notebooks {
J
Johannes Rieken 已提交
1399 1400 1401 1402 1403 1404 1405
		export function createNotebookEditorDecorationType(options: NotebookDecorationRenderOptions): NotebookEditorDecorationType;
	}

	//#endregion

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

1406
	export namespace notebooks {
J
Johannes Rieken 已提交
1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438
		/**
		 * Create a document that is the concatenation of all  notebook cells. By default all code-cells are included
		 * but a selector can be provided to narrow to down the set of cells.
		 *
		 * @param notebook
		 * @param selector
		 */
		// todo@API really needed? we didn't find a user here
		export function createConcatTextDocument(notebook: NotebookDocument, selector?: DocumentSelector): NotebookConcatTextDocument;
	}

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

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

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

	//#endregion

1439 1440
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookContentProvider

1441

1442 1443 1444 1445
	interface NotebookDocumentBackup {
		/**
		 * Unique identifier for the backup.
		 *
R
Rob Lourens 已提交
1446
		 * This id is passed back to your extension in `openNotebook` when opening a notebook editor from a backup.
1447 1448 1449 1450 1451 1452
		 */
		readonly id: string;

		/**
		 * Delete the current backup.
		 *
M
Matt Bierner 已提交
1453
		 * This is called by the editor when it is clear the current backup is no longer needed, such as when a new backup
1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464
		 * is made or when the file is saved.
		 */
		delete(): void;
	}

	interface NotebookDocumentBackupContext {
		readonly destination: Uri;
	}

	interface NotebookDocumentOpenContext {
		readonly backupId?: string;
1465
		readonly untitledDocumentData?: Uint8Array;
1466 1467
	}

1468
	// todo@API use openNotebookDOCUMENT to align with openCustomDocument etc?
J
Johannes Rieken 已提交
1469
	// todo@API rename to NotebookDocumentContentProvider
R
rebornix 已提交
1470
	export interface NotebookContentProvider {
1471

1472 1473 1474
		readonly options?: NotebookDocumentContentOptions;
		readonly onDidChangeNotebookContentOptions?: Event<NotebookDocumentContentOptions>;

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

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

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

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

1491
	export namespace workspace {
J
Johannes Rieken 已提交
1492

1493 1494
		// TODO@api use NotebookDocumentFilter instead of just notebookType:string?
		// TODO@API options duplicates the more powerful variant on NotebookContentProvider
1495
		export function registerNotebookContentProvider(notebookType: string, provider: NotebookContentProvider, options?: NotebookDocumentContentOptions): Disposable;
R
rebornix 已提交
1496 1497
	}

1498 1499
	//#endregion

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

J
Johannes Rieken 已提交
1502 1503 1504 1505
	export interface NotebookRegistrationData {
		displayName: string;
		filenamePattern: (GlobPattern | { include: GlobPattern; exclude: GlobPattern; })[];
		exclusive?: boolean;
1506 1507
	}

1508
	export namespace workspace {
J
Johannes Rieken 已提交
1509 1510 1511 1512
		// SPECIAL overload with NotebookRegistrationData
		export function registerNotebookContentProvider(notebookType: string, provider: NotebookContentProvider, options?: NotebookDocumentContentOptions, registrationData?: NotebookRegistrationData): Disposable;
		// SPECIAL overload with NotebookRegistrationData
		export function registerNotebookSerializer(notebookType: string, serializer: NotebookSerializer, options?: NotebookDocumentContentOptions, registration?: NotebookRegistrationData): Disposable;
1513 1514
	}

1515 1516
	//#endregion

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

1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532
	/**
	 * Represents a script that is loaded into the notebook renderer before rendering output. This allows
	 * to provide and share functionality for notebook markup and notebook output renderers.
	 */
	export class NotebookRendererScript {

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

		/**
1533 1534 1535
		 * URI of the JavaScript module to preload.
		 *
		 * This module must export an `activate` function that takes a context object that contains the notebook API.
1536 1537 1538 1539
		 */
		uri: Uri;

		/**
1540
		 * @param uri URI of the JavaScript module to preload
1541 1542 1543 1544 1545
		 * @param provides Value for the `provides` property
		 */
		constructor(uri: Uri, provides?: string | string[]);
	}

1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572
	export interface NotebookController {

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

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

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

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

1573
	export namespace notebooks {
1574

1575
		export function createNotebookController(id: string, viewType: string, label: string, handler?: (cells: NotebookCell[], notebook: NotebookDocument, controller: NotebookController) => void | Thenable<void>, rendererScripts?: NotebookRendererScript[]): NotebookController;
1576 1577 1578 1579
	}

	//#endregion

1580
	//#region @eamodio - timeline: https://github.com/microsoft/vscode/issues/84297
1581 1582 1583

	export class TimelineItem {
		/**
1584
		 * A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred.
1585
		 */
E
Eric Amodio 已提交
1586
		timestamp: number;
1587 1588

		/**
1589
		 * A human-readable string describing the timeline item.
1590 1591 1592 1593
		 */
		label: string;

		/**
1594
		 * Optional id for the timeline item. It must be unique across all the timeline items provided by this source.
1595
		 *
1596
		 * If not provided, an id is generated using the timeline item's timestamp.
1597 1598 1599 1600
		 */
		id?: string;

		/**
M
Matt Bierner 已提交
1601
		 * The icon path or {@link ThemeIcon} for the timeline item.
1602
		 */
R
rebornix 已提交
1603
		iconPath?: Uri | { light: Uri; dark: Uri; } | ThemeIcon;
1604 1605

		/**
1606
		 * A human readable string describing less prominent details of the timeline item.
1607 1608 1609 1610 1611 1612
		 */
		description?: string;

		/**
		 * The tooltip text when you hover over the timeline item.
		 */
1613
		detail?: string;
1614 1615

		/**
M
Matt Bierner 已提交
1616
		 * The {@link Command} that should be executed when the timeline item is selected.
1617 1618 1619 1620
		 */
		command?: Command;

		/**
1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636
		 * 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`.
1637 1638 1639
		 */
		contextValue?: string;

1640 1641 1642 1643 1644
		/**
		 * Accessibility information used when screen reader interacts with this timeline item.
		 */
		accessibilityInformation?: AccessibilityInformation;

1645 1646
		/**
		 * @param label A human-readable string describing the timeline item
E
Eric Amodio 已提交
1647
		 * @param timestamp A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred
1648
		 */
E
Eric Amodio 已提交
1649
		constructor(label: string, timestamp: number);
1650 1651
	}

1652
	export interface TimelineChangeEvent {
E
Eric Amodio 已提交
1653
		/**
M
Matt Bierner 已提交
1654
		 * The {@link Uri} of the resource for which the timeline changed.
E
Eric Amodio 已提交
1655
		 */
E
Eric Amodio 已提交
1656
		uri: Uri;
1657

E
Eric Amodio 已提交
1658
		/**
1659
		 * A flag which indicates whether the entire timeline should be reset.
E
Eric Amodio 已提交
1660
		 */
1661 1662
		reset?: boolean;
	}
E
Eric Amodio 已提交
1663

1664 1665 1666
	export interface Timeline {
		readonly paging?: {
			/**
E
Eric Amodio 已提交
1667
			 * A provider-defined cursor specifying the starting point of timeline items which are after the ones returned.
E
Eric Amodio 已提交
1668
			 * Use `undefined` to signal that there are no more items to be returned.
1669
			 */
E
Eric Amodio 已提交
1670
			readonly cursor: string | undefined;
R
rebornix 已提交
1671
		};
E
Eric Amodio 已提交
1672 1673

		/**
M
Matt Bierner 已提交
1674
		 * An array of {@link TimelineItem timeline items}.
E
Eric Amodio 已提交
1675
		 */
1676
		readonly items: readonly TimelineItem[];
E
Eric Amodio 已提交
1677 1678
	}

1679
	export interface TimelineOptions {
E
Eric Amodio 已提交
1680
		/**
E
Eric Amodio 已提交
1681
		 * A provider-defined cursor specifying the starting point of the timeline items that should be returned.
E
Eric Amodio 已提交
1682
		 */
1683
		cursor?: string;
E
Eric Amodio 已提交
1684 1685

		/**
1686 1687
		 * 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 已提交
1688
		 */
R
rebornix 已提交
1689
		limit?: number | { timestamp: number; id?: string; };
E
Eric Amodio 已提交
1690 1691
	}

1692
	export interface TimelineProvider {
1693
		/**
1694 1695
		 * 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`.
1696
		 */
E
Eric Amodio 已提交
1697
		onDidChange?: Event<TimelineChangeEvent | undefined>;
1698 1699

		/**
1700
		 * An identifier of the source of the timeline items. This can be used to filter sources.
1701
		 */
1702
		readonly id: string;
1703

E
Eric Amodio 已提交
1704
		/**
1705
		 * 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 已提交
1706
		 */
1707
		readonly label: string;
1708 1709

		/**
M
Matt Bierner 已提交
1710
		 * Provide {@link TimelineItem timeline items} for a {@link Uri}.
1711
		 *
M
Matt Bierner 已提交
1712
		 * @param uri The {@link Uri} of the file to provide the timeline for.
1713
		 * @param options A set of options to determine how results should be returned.
1714
		 * @param token A cancellation token.
M
Matt Bierner 已提交
1715
		 * @return The {@link TimelineResult timeline result} or a thenable that resolves to such. The lack of a result
1716 1717
		 * can be signaled by returning `undefined`, `null`, or an empty array.
		 */
1718
		provideTimeline(uri: Uri, options: TimelineOptions, token: CancellationToken): ProviderResult<Timeline>;
1719 1720 1721 1722 1723 1724 1725 1726 1727 1728
	}

	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.
		 *
1729
		 * @param scheme A scheme or schemes that defines which documents this provider is applicable to. Can be `*` to target all documents.
1730
		 * @param provider A timeline provider.
M
Matt Bierner 已提交
1731
		 * @return A {@link Disposable} that unregisters this provider when being disposed.
E
Eric Amodio 已提交
1732
		*/
1733
		export function registerTimelineProvider(scheme: string | string[], provider: TimelineProvider): Disposable;
1734 1735 1736
	}

	//#endregion
1737

1738
	//#region https://github.com/microsoft/vscode/issues/91555
1739

1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752
	export enum StandardTokenType {
		Other = 0,
		Comment = 1,
		String = 2,
		RegEx = 4
	}

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

	export namespace languages {
1753
		export function getTokenInformationAtPosition(document: TextDocument, position: Position): Thenable<TokenInformation>;
K
kingwl 已提交
1754 1755 1756 1757
	}

	//#endregion

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

1760
	// todo@API Split between Inlay- and OverlayHints (InlayHint are for a position, OverlayHints for a non-empty range)
J
Johannes Rieken 已提交
1761
	// todo@API add "mini-markdown" for links and styles
1762 1763 1764
	// (done) remove description
	// (done) rename to InlayHint
	// (done)  add InlayHintKind with type, argument, etc
J
Johannes Rieken 已提交
1765

K
kingwl 已提交
1766
	export namespace languages {
K
kingwl 已提交
1767
		/**
1768
		 * Register a inlay hints provider.
K
kingwl 已提交
1769
		 *
J
Johannes Rieken 已提交
1770 1771 1772
		 * 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 已提交
1773 1774
		 *
		 * @param selector A selector that defines the documents this provider is applicable to.
J
Johannes Rieken 已提交
1775
		 * @param provider An inlay hints provider.
M
Matt Bierner 已提交
1776
		 * @return A {@link Disposable} that unregisters this provider when being disposed.
K
kingwl 已提交
1777
		 */
1778
		export function registerInlayHintsProvider(selector: DocumentSelector, provider: InlayHintsProvider): Disposable;
1779 1780
	}

1781
	export enum InlayHintKind {
1782 1783 1784 1785 1786
		Other = 0,
		Type = 1,
		Parameter = 2,
	}

K
kingwl 已提交
1787
	/**
J
Johannes Rieken 已提交
1788
	 * Inlay hint information.
K
kingwl 已提交
1789
	 */
1790
	export class InlayHint {
K
kingwl 已提交
1791 1792 1793 1794 1795
		/**
		 * The text of the hint.
		 */
		text: string;
		/**
1796
		 * The position of this hint.
K
kingwl 已提交
1797
		 */
1798 1799 1800 1801 1802
		position: Position;
		/**
		 * The kind of this hint.
		 */
		kind?: InlayHintKind;
K
kingwl 已提交
1803

1804
		// todo@API make range first argument
1805
		constructor(text: string, position: Position, kind?: InlayHintKind);
K
kingwl 已提交
1806 1807 1808
	}

	/**
J
Johannes Rieken 已提交
1809 1810
	 * The inlay hints provider interface defines the contract between extensions and
	 * the inlay hints feature.
K
kingwl 已提交
1811
	 */
1812
	export interface InlayHintsProvider {
W
Wenlu Wang 已提交
1813 1814

		/**
J
Johannes Rieken 已提交
1815
		 * An optional event to signal that inlay hints have changed.
M
Matt Bierner 已提交
1816
		 * @see {@link EventEmitter}
W
Wenlu Wang 已提交
1817
		 */
1818
		onDidChangeInlayHints?: Event<void>;
J
Johannes Rieken 已提交
1819

K
kingwl 已提交
1820
		/**
J
Johannes Rieken 已提交
1821
		 *
K
kingwl 已提交
1822
		 * @param model The document in which the command was invoked.
J
Johannes Rieken 已提交
1823
		 * @param range The range for which inlay hints should be computed.
K
kingwl 已提交
1824
		 * @param token A cancellation token.
J
Johannes Rieken 已提交
1825
		 * @return A list of inlay hints or a thenable that resolves to such.
K
kingwl 已提交
1826
		 */
1827
		provideInlayHints(model: TextDocument, range: Range, token: CancellationToken): ProviderResult<InlayHint[]>;
K
kingwl 已提交
1828
	}
1829
	//#endregion
1830

1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848
	//#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
1849 1850 1851 1852

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

	export interface TextDocument {
1853 1854

		/**
M
Matt Bierner 已提交
1855
		 * The {@link NotebookDocument notebook} that contains this document as a notebook cell or `undefined` when
1856 1857
		 * the document is not contained by a notebook (this should be the more frequent case).
		 */
1858 1859 1860
		notebook: NotebookDocument | undefined;
	}
	//#endregion
1861

1862
	//#region proposed test APIs https://github.com/microsoft/vscode/issues/107467
C
Connor Peet 已提交
1863
	export namespace tests {
C
Connor Peet 已提交
1864 1865
		/**
		 * Requests that tests be run by their controller.
1866
		 * @param run Run options to use.
C
Connor Peet 已提交
1867 1868
		 * @param token Cancellation token for the test run
		 */
1869
		export function runTests(run: TestRunRequest, token?: CancellationToken): Thenable<void>;
C
Connor Peet 已提交
1870

C
Connor Peet 已提交
1871
		/**
1872
		 * Returns an observer that watches and can request tests.
C
Connor Peet 已提交
1873
		 */
1874
		export function createTestObserver(): TestObserver;
1875
		/**
M
Matt Bierner 已提交
1876
		 * List of test results stored by the editor, sorted in descending
1877 1878
		 * order by their `completedAt` time.
		 */
C
Connor Peet 已提交
1879
		export const testResults: ReadonlyArray<TestRunResult>;
1880 1881

		/**
1882 1883
		 * Event that fires when the {@link testResults} array is updated.
		 */
1884
		export const onDidChangeTestResults: Event<void>;
C
Connor Peet 已提交
1885 1886 1887 1888 1889 1890
	}

	export interface TestObserver {
		/**
		 * List of tests returned by test provider for files in the workspace.
		 */
1891
		readonly tests: ReadonlyArray<TestItem>;
C
Connor Peet 已提交
1892 1893 1894 1895 1896 1897

		/**
		 * 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 已提交
1898
		readonly onDidChangeTest: Event<TestsChangeEvent>;
C
Connor Peet 已提交
1899 1900

		/**
M
Matt Bierner 已提交
1901
		 * Dispose of the observer, allowing the editor to eventually tell test
C
Connor Peet 已提交
1902 1903 1904 1905 1906
		 * providers that they no longer need to update tests.
		 */
		dispose(): void;
	}

C
Connor Peet 已提交
1907
	export interface TestsChangeEvent {
C
Connor Peet 已提交
1908 1909 1910
		/**
		 * List of all tests that are newly added.
		 */
1911
		readonly added: ReadonlyArray<TestItem>;
C
Connor Peet 已提交
1912 1913 1914 1915

		/**
		 * List of existing tests that have updated.
		 */
1916
		readonly updated: ReadonlyArray<TestItem>;
C
Connor Peet 已提交
1917 1918 1919 1920

		/**
		 * List of existing tests that have been removed.
		 */
1921
		readonly removed: ReadonlyArray<TestItem>;
C
Connor Peet 已提交
1922 1923
	}

1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954
	/**
	 * A test item is an item shown in the "test explorer" view. It encompasses
	 * both a suite and a test, since they have almost or identical capabilities.
	 */
	export interface TestItem {
		/**
		 * Marks the test as outdated. This can happen as a result of file changes,
		 * for example. In "auto run" mode, tests that are outdated will be
		 * automatically rerun after a short delay. Invoking this on a
		 * test with children will mark the entire subtree as outdated.
		 *
		 * Extensions should generally not override this method.
		 */
		// todo@api still unsure about this
		invalidateResults(): void;
	}


	/**
	 * TestResults can be provided to the editor in {@link tests.publishTestResult},
	 * or read from it in {@link tests.testResults}.
	 *
	 * The results contain a 'snapshot' of the tests at the point when the test
	 * 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.
	 */
	export interface TestRunResult {
		/**
		 * Unix milliseconds timestamp at which the test run was completed.
		 */
C
Connor Peet 已提交
1955
		readonly completedAt: number;
1956 1957 1958 1959

		/**
		 * Optional raw output from the test run.
		 */
C
Connor Peet 已提交
1960
		readonly output?: string;
1961 1962 1963 1964 1965

		/**
		 * List of test results. The items in this array are the items that
		 * were passed in the {@link tests.runTests} method.
		 */
C
Connor Peet 已提交
1966
		readonly results: ReadonlyArray<Readonly<TestResultSnapshot>>;
1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010
	}

	/**
	 * A {@link TestItem}-like interface with an associated result, which appear
	 * or can be provided in {@link TestResult} interfaces.
	 */
	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;

		/**
		 * Parent of this item.
		 */
		readonly parent?: TestResultSnapshot;

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

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

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

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

		/**
		 * 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.
		 */
2011
		readonly taskStates: ReadonlyArray<TestSnapshotTaskState>;
2012 2013 2014 2015 2016 2017 2018

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

2019
	export interface TestSnapshotTaskState {
2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037
		/**
		 * Current result of the test.
		 */
		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>;
	}

C
Connor Peet 已提交
2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054
	/**
	 * Possible states of tests in a test run.
	 */
	export enum TestResultState {
		// Test will be run, but is not currently running.
		Queued = 1,
		// Test is currently running
		Running = 2,
		// Test run has passed
		Passed = 3,
		// Test run has failed (on an assertion)
		Failed = 4,
		// Test run has been skipped
		Skipped = 5,
		// Test run failed for some other reason (compilation error, timeout, etc)
		Errored = 6
	}
2055

C
Connor Peet 已提交
2056
	//#endregion
2057 2058 2059

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

2060 2061 2062
	/**
	 * Details if an `ExternalUriOpener` can open a uri.
	 *
2063 2064 2065 2066
	 * The priority is also used to rank multiple openers against each other and determine
	 * if an opener should be selected automatically or if the user should be prompted to
	 * select an opener.
	 *
M
Matt Bierner 已提交
2067
	 * The editor will try to use the best available opener, as sorted by `ExternalUriOpenerPriority`.
2068 2069
	 * If there are multiple potential "best" openers for a URI, then the user will be prompted
	 * to select an opener.
2070
	 */
M
Matt Bierner 已提交
2071
	export enum ExternalUriOpenerPriority {
2072
		/**
2073
		 * The opener is disabled and will never be shown to users.
M
Matt Bierner 已提交
2074
		 *
2075 2076
		 * Note that the opener can still be used if the user specifically
		 * configures it in their settings.
2077
		 */
M
Matt Bierner 已提交
2078
		None = 0,
2079 2080

		/**
2081
		 * The opener can open the uri but will not cause a prompt on its own
M
Matt Bierner 已提交
2082
		 * since the editor always contributes a built-in `Default` opener.
2083
		 */
M
Matt Bierner 已提交
2084
		Option = 1,
2085 2086

		/**
M
Matt Bierner 已提交
2087 2088
		 * The opener can open the uri.
		 *
M
Matt Bierner 已提交
2089
		 * The editor's built-in opener has `Default` priority. This means that any additional `Default`
2090
		 * openers will cause the user to be prompted to select from a list of all potential openers.
2091
		 */
M
Matt Bierner 已提交
2092 2093 2094
		Default = 2,

		/**
2095
		 * The opener can open the uri and should be automatically selected over any
M
Matt Bierner 已提交
2096
		 * default openers, include the built-in one from the editor.
M
Matt Bierner 已提交
2097
		 *
2098
		 * A preferred opener will be automatically selected if no other preferred openers
2099
		 * are available. If multiple preferred openers are available, then the user
2100
		 * is shown a prompt with all potential openers (not just preferred openers).
M
Matt Bierner 已提交
2101 2102
		 */
		Preferred = 3,
2103 2104
	}

2105
	/**
M
Matt Bierner 已提交
2106
	 * Handles opening uris to external resources, such as http(s) links.
2107
	 *
M
Matt Bierner 已提交
2108
	 * Extensions can implement an `ExternalUriOpener` to open `http` links to a webserver
M
Matt Bierner 已提交
2109
	 * inside of the editor instead of having the link be opened by the web browser.
2110 2111 2112 2113 2114 2115
	 *
	 * Currently openers may only be registered for `http` and `https` uris.
	 */
	export interface ExternalUriOpener {

		/**
2116
		 * Check if the opener can open a uri.
2117
		 *
M
Matt Bierner 已提交
2118 2119 2120
		 * @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.
2121
		 *
2122
		 * @return Priority indicating if the opener can open the external uri.
M
Matt Bierner 已提交
2123
		 */
M
Matt Bierner 已提交
2124
		canOpenExternalUri(uri: Uri, token: CancellationToken): ExternalUriOpenerPriority | Thenable<ExternalUriOpenerPriority>;
M
Matt Bierner 已提交
2125 2126

		/**
2127
		 * Open a uri.
2128
		 *
M
Matt Bierner 已提交
2129
		 * This is invoked when:
2130
		 *
M
Matt Bierner 已提交
2131 2132 2133
		 * - 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.
2134
		 *
M
Matt Bierner 已提交
2135 2136 2137 2138 2139 2140
		 * @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.
		 *
2141
		 * @return Thenable indicating that the opening has completed.
M
Matt Bierner 已提交
2142 2143 2144 2145 2146 2147 2148 2149 2150 2151
		 */
		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.
2152
		 *
2153
		 * This is the original uri that the user clicked on or that was passed to `openExternal.`
M
Matt Bierner 已提交
2154
		 * Due to port forwarding, this may not match the `resolvedUri` passed to `openExternalUri`.
2155
		 */
M
Matt Bierner 已提交
2156 2157 2158
		readonly sourceUri: Uri;
	}

M
Matt Bierner 已提交
2159
	/**
2160
	 * Additional metadata about a registered `ExternalUriOpener`.
M
Matt Bierner 已提交
2161
	 */
M
Matt Bierner 已提交
2162
	interface ExternalUriOpenerMetadata {
M
Matt Bierner 已提交
2163

M
Matt Bierner 已提交
2164 2165 2166 2167 2168 2169 2170
		/**
		 * List of uri schemes the opener is triggered for.
		 *
		 * Currently only `http` and `https` are supported.
		 */
		readonly schemes: readonly string[]

M
Matt Bierner 已提交
2171 2172
		/**
		 * Text displayed to the user that explains what the opener does.
2173
		 *
M
Matt Bierner 已提交
2174
		 * For example, 'Open in browser preview'
2175
		 */
M
Matt Bierner 已提交
2176
		readonly label: string;
2177 2178 2179 2180 2181 2182
	}

	namespace window {
		/**
		 * Register a new `ExternalUriOpener`.
		 *
2183
		 * When a uri is about to be opened, an `onOpenExternalUri:SCHEME` activation event is fired.
2184
		 *
M
Matt Bierner 已提交
2185 2186
		 * @param id Unique id of the opener, such as `myExtension.browserPreview`. This is used in settings
		 *   and commands to identify the opener.
2187
		 * @param opener Opener to register.
M
Matt Bierner 已提交
2188
		 * @param metadata Additional information about the opener.
2189 2190
		 *
		* @returns Disposable that unregisters the opener.
M
Matt Bierner 已提交
2191 2192
		*/
		export function registerExternalUriOpener(id: string, opener: ExternalUriOpener, metadata: ExternalUriOpenerMetadata): Disposable;
2193 2194
	}

2195 2196
	interface OpenExternalOptions {
		/**
2197 2198
		 * Allows using openers contributed by extensions through  `registerExternalUriOpener`
		 * when opening the resource.
2199
		 *
M
Matt Bierner 已提交
2200
		 * If `true`, the editor will check if any contributed openers can handle the
2201 2202
		 * uri, and fallback to the default opener behavior.
		 *
2203
		 * If it is string, this specifies the id of the `ExternalUriOpener`
M
Matt Bierner 已提交
2204
		 * that should be used if it is available. Use `'default'` to force the editor's
2205 2206 2207 2208 2209 2210 2211 2212 2213
		 * standard external opener to be used.
		 */
		readonly allowContributedOpeners?: boolean | string;
	}

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

J
Johannes Rieken 已提交
2214
	//#endregion
2215 2216 2217

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

2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233
	/**
	 * Represents a tab within the window
	 */
	export interface Tab {
		/**
		 * The text displayed on the tab
		 */
		readonly label: string;

		/**
		 * The position of the tab
		 */
		readonly viewColumn: ViewColumn;

		/**
		 * The resource represented by the tab if availble.
L
Logan Ramos 已提交
2234
		 * Note: Not all tabs have a resource associated with them.
2235
		 */
L
Logan Ramos 已提交
2236
		readonly resource?: Uri;
2237 2238

		/**
L
Logan Ramos 已提交
2239 2240
		 * The identifier of the view contained in the tab
		 * This is equivalent to `viewType` for custom editors and `notebookType` for notebooks.
2241 2242
		 * The built-in text editor has an id of 'default' for all configurations.
		 */
L
Logan Ramos 已提交
2243
		readonly viewId?: string;
2244 2245 2246 2247 2248 2249

		/**
		 * Whether or not the tab is currently active
		 * Dictated by being the selected tab in the active group
		 */
		readonly isActive: boolean;
2250 2251 2252
	}

	export namespace window {
2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275
		/**
		 * A list of all opened tabs
		 * Ordered from left to right
		 */
		export const tabs: readonly Tab[];

		/**
		 * The currently active tab
		 * Undefined if no tabs are currently opened
		 */
		export const activeTab: Tab | undefined;

		/**
		 * An {@link Event} which fires when the array of {@link window.tabs tabs}
		 * has changed.
		 */
		export const onDidChangeTabs: Event<readonly Tab[]>;

		/**
		 * An {@link Event} which fires when the {@link window.activeTab activeTab}
		 * has changed.
		 */
		export const onDidChangeActiveTab: Event<Tab | undefined>;
2276 2277 2278 2279

	}

	//#endregion
2280

2281
	//#region https://github.com/microsoft/vscode/issues/120173
L
Ladislau Szomoru 已提交
2282 2283 2284
	/**
	 * The object describing the properties of the workspace trust request
	 */
2285
	export interface WorkspaceTrustRequestOptions {
L
Ladislau Szomoru 已提交
2286
		/**
2287 2288 2289
		 * Custom message describing the user action that requires workspace
		 * trust. If omitted, a generic message will be displayed in the workspace
		 * trust request dialog.
L
Ladislau Szomoru 已提交
2290
		 */
2291
		readonly message?: string;
L
Ladislau Szomoru 已提交
2292 2293
	}

2294 2295 2296
	export namespace workspace {
		/**
		 * Prompt the user to chose whether to trust the current workspace
2297
		 * @param options Optional object describing the properties of the
2298
		 * workspace trust request.
2299
		 */
2300
		export function requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Thenable<boolean | undefined>;
2301 2302
	}

2303
	//#endregion
2304 2305 2306 2307 2308 2309 2310

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

A
Alex Ross 已提交
2315 2316 2317 2318
	export class PortAttributes {
		/**
		 * The port number associated with this this set of attributes.
		 */
2319
		port: number;
A
Alex Ross 已提交
2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331

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

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

	export interface PortAttributesProvider {
2335
		/**
2336 2337 2338
		 * 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.
2339
		 */
2340
		providePortAttributes(port: number, pid: number | undefined, commandLine: string | undefined, token: CancellationToken): ProviderResult<PortAttributes>;
2341 2342 2343 2344 2345 2346
	}

	export namespace workspace {
		/**
		 * If your extension listens on ports, consider registering a PortAttributesProvider to provide information
		 * about the ports. For example, a debug extension may know about debug ports in it's debuggee. By providing
M
Matt Bierner 已提交
2347
		 * this information with a PortAttributesProvider the extension can tell the editor that these ports should be
2348 2349 2350
		 * 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
2351 2352
		 * 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.
2353
		 * The `portRange` is start inclusive and end exclusive.
2354 2355
		 * @param provider The PortAttributesProvider
		 */
2356
		export function registerPortAttributesProvider(portSelector: { pid?: number, portRange?: [number, number], commandMatcher?: RegExp }, provider: PortAttributesProvider): Disposable;
2357 2358
	}
	//#endregion
2359

J
Johannes Rieken 已提交
2360
	//#region https://github.com/microsoft/vscode/issues/119904 @eamodio
2361 2362 2363 2364 2365 2366 2367 2368 2369 2370

	export interface SourceControlInputBox {

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

	//#endregion
2371

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

2374
	export namespace languages {
2375 2376 2377
		/**
		 * Registers an inline completion provider.
		 */
2378
		export function registerInlineCompletionItemProvider(selector: DocumentSelector, provider: InlineCompletionItemProvider): Disposable;
A
Alex Dima 已提交
2379 2380
	}

2381
	export interface InlineCompletionItemProvider<T extends InlineCompletionItem = InlineCompletionItem> {
2382 2383 2384 2385 2386 2387
		/**
		 * Provides inline completion items for the given position and document.
		 * If inline completions are enabled, this method will be called whenever the user stopped typing.
		 * It will also be called when the user explicitly triggers inline completions or asks for the next or previous inline completion.
		 * Use `context.triggerKind` to distinguish between these scenarios.
		*/
2388
		provideInlineCompletionItems(document: TextDocument, position: Position, context: InlineCompletionContext, token: CancellationToken): ProviderResult<InlineCompletionList<T> | T[]>;
2389
	}
H
wip  
Henning Dieterichs 已提交
2390

2391 2392 2393 2394 2395
	export interface InlineCompletionContext {
		/**
		 * How the completion was triggered.
		 */
		readonly triggerKind: InlineCompletionTriggerKind;
2396 2397

		/**
2398 2399
		 * Provides information about the currently selected item in the autocomplete widget if it is visible.
		 *
2400 2401
		 * If set, provided inline completions must extend the text of the selected item
		 * and use the same range, otherwise they are not shown as preview.
2402 2403 2404 2405 2406 2407
		 * As an example, if the document text is `console.` and the selected item is `.log` replacing the `.` in the document,
		 * the inline completion must also replace `.` and start with `.log`, for example `.log()`.
		 *
		 * Inline completion providers are requested again whenever the selected item changes.
		 *
		 * The user must configure `"editor.suggest.preview": true` for this feature.
2408
		*/
2409
		readonly selectedCompletionInfo: SelectedCompletionInfo | undefined;
2410 2411
	}

2412
	export interface SelectedCompletionInfo {
2413 2414
		range: Range;
		text: string;
H
wip  
Henning Dieterichs 已提交
2415 2416
	}

2417 2418 2419 2420 2421 2422 2423 2424 2425 2426
	/**
	 * How an {@link InlineCompletionItemProvider inline completion provider} was triggered.
	 */
	export enum InlineCompletionTriggerKind {
		/**
		 * Completion was triggered automatically while editing.
		 * It is sufficient to return a single completion item in this case.
		 */
		Automatic = 0,

H
wip  
Henning Dieterichs 已提交
2427
		/**
2428 2429 2430 2431 2432
		 * Completion was triggered explicitly by a user gesture.
		 * Return multiple completion items to enable cycling through them.
		 */
		Explicit = 1,
	}
2433 2434 2435 2436 2437 2438 2439 2440

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

		constructor(items: T[]);
	}

	export class InlineCompletionItem {
2441
		/**
2442 2443 2444
		 * The text to replace the range with.
		 *
		 * The text the range refers to should be a prefix of this value and must be a subword (`AB` and `BEF` are subwords of `ABCDEF`, but `Ab` is not).
2445 2446 2447 2448 2449 2450
		*/
		text: string;

		/**
		 * The range to replace.
		 * Must begin and end on the same line.
2451
		 *
2452 2453
		 * Prefer replacements over insertions to avoid cache invalidation:
		 * Instead of reporting a completion that inserts an extension at the end of a word,
2454
		 * the whole word should be replaced with the extended word.
2455 2456 2457 2458 2459
		*/
		range?: Range;

		/**
		 * An optional {@link Command} that is executed *after* inserting this completion.
2460
		 */
2461 2462 2463
		command?: Command;

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

2466 2467 2468 2469 2470 2471

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

2474 2475 2476 2477
	/**
	 * Be aware that this API will not ever be finalized.
	 */
	export interface InlineCompletionController<T extends InlineCompletionItem> {
2478 2479 2480
		/**
		 * Is fired when an inline completion item is shown to the user.
		 */
2481 2482 2483 2484 2485 2486 2487 2488 2489
		// eslint-disable-next-line vscode-dts-event-naming
		readonly onDidShowCompletionItem: Event<InlineCompletionItemDidShowEvent<T>>;
	}

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

	//#endregion

2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520
	//#region https://github.com/microsoft/vscode/issues/126280 @mjbvz

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

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

	//#endregion
2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711

	//#region https://github.com/microsoft/vscode/issues/123713 @connor4312
	export interface TestRun {
		/**
		 * Test coverage provider for this result. An extension can defer setting
		 * this until after a run is complete and coverage is available.
		 */
		coverageProvider?: TestCoverageProvider
		// ...
	}

	/**
	 * Provides information about test coverage for a test result.
	 * Methods on the provider will not be called until the test run is complete
	 */
	export interface TestCoverageProvider<T extends FileCoverage = FileCoverage> {
		/**
		 * Returns coverage information for all files involved in the test run.
		 * @param token A cancellation token.
		 * @return Coverage metadata for all files involved in the test.
		 */
		provideFileCoverage(token: CancellationToken): ProviderResult<T[]>;

		/**
		 * Give a FileCoverage to fill in more data, namely {@link FileCoverage.detailedCoverage}.
		 * The editor will only resolve a FileCoverage once, and onyl if detailedCoverage
		 * is undefined.
		 *
		 * @param coverage A coverage object obtained from {@link provideFileCoverage}
		 * @param token A cancellation token.
		 * @return The resolved file coverage, or a thenable that resolves to one. It
		 * is OK to return the given `coverage`. When no result is returned, the
		 * given `coverage` will be used.
		 */
		resolveFileCoverage?(coverage: T, token: CancellationToken): ProviderResult<T>;
	}

	/**
	 * A class that contains information about a covered resource. A count can
	 * be give for lines, branches, and functions in a file.
	 */
	export class CoveredCount {
		/**
		 * Number of items covered in the file.
		 */
		covered: number;
		/**
		 * Total number of covered items in the file.
		 */
		total: number;

		/**
		 * @param covered Value for {@link CovereredCount.covered}
		 * @param total Value for {@link CovereredCount.total}
		 */
		constructor(covered: number, total: number);
	}

	/**
	 * Contains coverage metadata for a file.
	 */
	export class FileCoverage {
		/**
		 * File URI.
		 */
		readonly uri: Uri;

		/**
		 * Statement coverage information. If the reporter does not provide statement
		 * coverage information, this can instead be used to represent line coverage.
		 */
		statementCoverage: CoveredCount;

		/**
		 * Branch coverage information.
		 */
		branchCoverage?: CoveredCount;

		/**
		 * Function coverage information.
		 */
		functionCoverage?: CoveredCount;

		/**
		 * Detailed, per-statement coverage. If this is undefined, the editor will
		 * call {@link TestCoverageProvider.resolveFileCoverage} when necessary.
		 */
		detailedCoverage?: DetailedCoverage[];

		/**
		 * Creates a {@link FileCoverage} instance with counts filled in from
		 * the coverage details.
		 * @param uri Covered file URI
		 * @param detailed Detailed coverage information
		 */
		static fromDetails(uri: Uri, details: readonly DetailedCoverage[]): FileCoverage;

		/**
		 * @param uri Covered file URI
		 * @param statementCoverage Statement coverage information. If the reporter
		 * does not provide statement coverage information, this can instead be
		 * used to represent line coverage.
		 * @param branchCoverage Branch coverage information
		 * @param functionCoverage Function coverage information
		 */
		constructor(
			uri: Uri,
			statementCoverage: CoveredCount,
			branchCoverage?: CoveredCount,
			functionCoverage?: CoveredCount,
		);
	}

	/**
	 * Contains coverage information for a single statement or line.
	 */
	export class StatementCoverage {
		/**
		 * The number of times this statement was executed. If zero, the
		 * statement will be marked as un-covered.
		 */
		executionCount: number;

		/**
		 * Statement location.
		 */
		location: Position | Range;

		/**
		 * Coverage from branches of this line or statement. If it's not a
		 * conditional, this will be empty.
		 */
		branches: BranchCoverage[];

		/**
		 * @param location The statement position.
		 * @param executionCount The number of times this statement was
		 * executed. If zero, the statement will be marked as un-covered.
		 * @param branches Coverage from branches of this line.  If it's not a
		 * conditional, this should be omitted.
		 */
		constructor(executionCount: number, location: Position | Range, branches?: BranchCoverage[]);
	}

	/**
	 * Contains coverage information for a branch of a {@link StatementCoverage}.
	 */
	export class BranchCoverage {
		/**
		 * The number of times this branch was executed. If zero, the
		 * branch will be marked as un-covered.
		 */
		executionCount: number;

		/**
		 * Branch location.
		 */
		location?: Position | Range;

		/**
		 * @param executionCount The number of times this branch was executed.
		 * @param location The branch position.
		 */
		constructor(executionCount: number, location?: Position | Range);
	}

	/**
	 * Contains coverage information for a function or method.
	 */
	export class FunctionCoverage {
		/**
		 * The number of times this function was executed. If zero, the
		 * function will be marked as un-covered.
		 */
		executionCount: number;

		/**
		 * Function location.
		 */
		location: Position | Range;

		/**
		 * @param executionCount The number of times this function was executed.
		 * @param location The function position.
		 */
		constructor(executionCount: number, location: Position | Range);
	}

	export type DetailedCoverage = StatementCoverage | FunctionCoverage;

	//#endregion
Y
Yan Zhang 已提交
2712

2713 2714
	//#region https://github.com/microsoft/vscode/issues/129037

2715 2716 2717 2718 2719
	enum LanguageStatusSeverity {
		Information = 0,
		Warning = 1,
		Error = 2
	}
2720

2721
	interface LanguageStatusItem {
2722
		readonly id: string;
2723
		selector: DocumentSelector;
2724 2725 2726
		// todo@jrieken replace with boolean ala needsAttention
		severity: LanguageStatusSeverity;
		name: string | undefined;
2727
		text: string;
2728
		detail?: string;
2729
		command: Command | undefined;
2730
		accessibilityInformation?: AccessibilityInformation;
2731
		dispose(): void;
2732 2733 2734
	}

	namespace languages {
2735
		export function createLanguageStatusItem(id: string, selector: DocumentSelector): LanguageStatusItem;
2736 2737 2738
	}

	//#endregion
L
Logan Ramos 已提交
2739

2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752
	//#region https://github.com/microsoft/vscode/issues/88716
	export interface QuickPickItem {
		buttons?: QuickInputButton[];
	}
	export interface QuickPick<T extends QuickPickItem> extends QuickInput {
		readonly onDidTriggerItemButton: Event<QuickPickItemButtonEvent<T>>;
	}
	export interface QuickPickItemButtonEvent<T extends QuickPickItem> {
		button: QuickInputButton;
		item: T;
	}

	//#endregion
2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769

	//#region @mjbvz https://github.com/microsoft/vscode/issues/40607
	export interface MarkdownString {
		/**
		 * Indicates that this markdown string can contain raw html tags. Default to false.
		 *
		 * When `supportHtml` is false, the markdown renderer will strip out any raw html tags
		 * that appear in the markdown text. This means you can only use markdown syntax for rendering.
		 *
		 * When `supportHtml` is true, the markdown render will also allow a safe subset of html tags
		 * and attributes to be rendered. See https://github.com/microsoft/vscode/blob/6d2920473c6f13759c978dd89104c4270a83422d/src/vs/base/browser/markdownRenderer.ts#L296
		 * for a list of all supported tags and attributes.
		 */
		supportHtml?: boolean;
	}

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