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

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

17 18
declare module 'vscode' {

19
	//#region Joh - ExecutionContext
20
	// THIS is a deprecated proposal
21 22 23 24
	export enum ExtensionExecutionContext {
		Local = 1,
		Remote = 2
	}
25 26 27 28 29
	export interface ExtensionContext {
		executionContext: ExtensionExecutionContext;
	}
	//#endregion

30 31 32 33 34 35 36 37 38 39 40
	//#region Joh - call hierarchy

	export enum CallHierarchyDirection {
		CallsFrom = 1,
		CallsTo = 2,
	}

	export class CallHierarchyItem {
		kind: SymbolKind;
		name: string;
		detail?: string;
41
		uri: Uri;
42 43 44
		range: Range;
		selectionRange: Range;

45
		constructor(kind: SymbolKind, name: string, detail: string, uri: Uri, range: Range, selectionRange: Range);
46 47 48 49
	}

	export interface CallHierarchyItemProvider {

J
Johannes Rieken 已提交
50 51 52 53
		/**
		 * Given a document and position compute a call hierarchy item. This is justed as
		 * anchor for call hierarchy and then `resolveCallHierarchyItem` is being called.
		 */
54 55
		provideCallHierarchyItem(
			document: TextDocument,
J
Julien Brianceau 已提交
56
			position: Position,
57 58 59
			token: CancellationToken
		): ProviderResult<CallHierarchyItem>;

J
Johannes Rieken 已提交
60 61 62 63 64 65 66 67 68 69
		/**
		 * Resolve a call hierarchy item, e.g. compute all calls from or to a function.
		 * The result is an array of item/location-tuples. The location in the returned tuples
		 * is always relative to the "caller" with the caller either being the provided item or
		 * the returned item.
		 *
		 * @param item A call hierarchy item previously returned from `provideCallHierarchyItem` or `resolveCallHierarchyItem`
		 * @param direction Resolve calls from a function or calls to a function
		 * @param token A cancellation token
		 */
70 71 72 73 74 75 76 77 78 79 80 81 82 83
		resolveCallHierarchyItem(
			item: CallHierarchyItem,
			direction: CallHierarchyDirection,
			token: CancellationToken
		): ProviderResult<[CallHierarchyItem, Location[]][]>;
	}

	export namespace languages {
		export function registerCallHierarchyProvider(selector: DocumentSelector, provider: CallHierarchyItemProvider): Disposable;
	}

	//#endregion


A
Alex Dima 已提交
84 85
	//#region Alex - resolvers

A
Tweaks  
Alex Dima 已提交
86 87 88 89
	export interface RemoteAuthorityResolverContext {
		resolveAttempt: number;
	}

A
Alex Dima 已提交
90 91 92 93 94 95 96
	export class ResolvedAuthority {
		readonly host: string;
		readonly port: number;

		constructor(host: string, port: number);
	}

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

		constructor(message?: string);
	}

A
Alex Dima 已提交
104
	export interface RemoteAuthorityResolver {
A
Tweaks  
Alex Dima 已提交
105
		resolve(authority: string, context: RemoteAuthorityResolverContext): ResolvedAuthority | Thenable<ResolvedAuthority>;
A
Alex Dima 已提交
106 107
	}

108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
	export interface ResourceLabelFormatter {
		scheme: string;
		authority?: string;
		formatting: ResourceLabelFormatting;
	}

	export interface ResourceLabelFormatting {
		label: string; // myLabel:/${path}
		separator: '/' | '\\' | '';
		tildify?: boolean;
		normalizeDriveLetter?: boolean;
		workspaceSuffix?: string;
		authorityPrefix?: string;
	}

A
Alex Dima 已提交
123 124
	export namespace workspace {
		export function registerRemoteAuthorityResolver(authorityPrefix: string, resolver: RemoteAuthorityResolver): Disposable;
125
		export function registerResourceLabelFormatter(formatter: ResourceLabelFormatter): Disposable;
126
	}
127

128 129 130 131 132
	//#endregion


	// #region Joh - code insets

133 134
	export interface WebviewEditorInset {
		readonly editor: TextEditor;
135 136
		readonly line: number;
		readonly height: number;
137 138 139
		readonly webview: Webview;
		readonly onDidDispose: Event<void>;
		dispose(): void;
140 141
	}

142
	export namespace window {
143
		export function createWebviewTextEditorInset(editor: TextEditor, line: number, height: number, options?: WebviewOptions): WebviewEditorInset;
A
Alex Dima 已提交
144 145 146 147
	}

	//#endregion

148 149 150
	//#region Joh - read/write in chunks

	export interface FileSystemProvider {
J
Johannes Rieken 已提交
151
		open?(resource: Uri, options: { create: boolean }): number | Thenable<number>;
152 153 154 155 156 157 158
		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

159
	//#region Rob: search provider
160

161 162 163
	/**
	 * The parameters of a query for text search.
	 */
164
	export interface TextSearchQuery {
165 166 167
		/**
		 * The text pattern to search for.
		 */
168
		pattern: string;
169

R
Rob Lourens 已提交
170 171 172 173 174
		/**
		 * Whether or not `pattern` should match multiple lines of text.
		 */
		isMultiline?: boolean;

175 176 177
		/**
		 * Whether or not `pattern` should be interpreted as a regular expression.
		 */
R
Rob Lourens 已提交
178
		isRegExp?: boolean;
179 180 181 182

		/**
		 * Whether or not the search should be case-sensitive.
		 */
R
Rob Lourens 已提交
183
		isCaseSensitive?: boolean;
184 185 186 187

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

191 192 193 194 195 196 197 198 199 200
	/**
	 * A file glob pattern to match file paths against.
	 * TODO@roblou - merge this with the GlobPattern docs/definition in vscode.d.ts.
	 * @see [GlobPattern](#GlobPattern)
	 */
	export type GlobString = string;

	/**
	 * Options common to file and text search
	 */
R
Rob Lourens 已提交
201
	export interface SearchOptions {
202 203 204
		/**
		 * The root folder to search within.
		 */
205
		folder: Uri;
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220

		/**
		 * 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 已提交
221
		useIgnoreFiles: boolean;
222 223 224 225 226

		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
227
		followSymlinks: boolean;
P
pkoushik 已提交
228 229 230 231 232 233

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

R
Rob Lourens 已提交
236 237
	/**
	 * Options to specify the size of the result text preview.
R
Rob Lourens 已提交
238
	 * These options don't affect the size of the match itself, just the amount of preview text.
R
Rob Lourens 已提交
239
	 */
240
	export interface TextSearchPreviewOptions {
241
		/**
R
Rob Lourens 已提交
242
		 * The maximum number of lines in the preview.
R
Rob Lourens 已提交
243
		 * Only search providers that support multiline search will ever return more than one line in the match.
244
		 */
R
Rob Lourens 已提交
245
		matchLines: number;
R
Rob Lourens 已提交
246 247 248 249

		/**
		 * The maximum number of characters included per line.
		 */
R
Rob Lourens 已提交
250
		charsPerLine: number;
251 252
	}

253 254 255
	/**
	 * Options that apply to text search.
	 */
R
Rob Lourens 已提交
256
	export interface TextSearchOptions extends SearchOptions {
257
		/**
258
		 * The maximum number of results to be returned.
259
		 */
260 261
		maxResults: number;

R
Rob Lourens 已提交
262 263 264
		/**
		 * Options to specify the size of the result text preview.
		 */
265
		previewOptions?: TextSearchPreviewOptions;
266 267 268 269

		/**
		 * Exclude files larger than `maxFileSize` in bytes.
		 */
270
		maxFileSize?: number;
271 272 273 274 275

		/**
		 * Interpret files using this encoding.
		 * See the vscode setting `"files.encoding"`
		 */
276
		encoding?: string;
277 278 279 280 281 282 283 284 285 286

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

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

289 290 291 292 293 294 295 296 297 298 299 300 301 302
	/**
	 * Information collected when text search is complete.
	 */
	export interface TextSearchComplete {
		/**
		 * Whether the search hit the limit on the maximum number of search results.
		 * `maxResults` on [`TextSearchOptions`](#TextSearchOptions) specifies the max number of results.
		 * - If exactly that number of matches exist, this should be false.
		 * - If `maxResults` matches are returned and more exist, this should be true.
		 * - If search hits an internal limit which is less than `maxResults`, this should be true.
		 */
		limitHit?: boolean;
	}

303 304 305
	/**
	 * The parameters of a query for file search.
	 */
306
	export interface FileSearchQuery {
307 308 309
		/**
		 * The search pattern to match against file paths.
		 */
310 311
		pattern: string;
	}
312 313 314 315

	/**
	 * Options that apply to file search.
	 */
316
	export interface FileSearchOptions extends SearchOptions {
317
		/**
318
		 * The maximum number of results to be returned.
319
		 */
R
Rob Lourens 已提交
320
		maxResults?: number;
321 322 323 324 325 326

		/**
		 * 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;
327 328
	}

R
Rob Lourens 已提交
329 330 331
	/**
	 * A preview of the text result.
	 */
332
	export interface TextSearchMatchPreview {
333
		/**
R
Rob Lourens 已提交
334
		 * The matching lines of text, or a portion of the matching line that contains the match.
335 336 337 338 339
		 */
		text: string;

		/**
		 * The Range within `text` corresponding to the text of the match.
340
		 * The number of matches must match the TextSearchMatch's range property.
341
		 */
342
		matches: Range | Range[];
343 344 345 346 347
	}

	/**
	 * A match from a text search
	 */
348
	export interface TextSearchMatch {
349 350 351
		/**
		 * The uri for the matching document.
		 */
352
		uri: Uri;
353 354

		/**
355
		 * The range of the match within the document, or multiple ranges for multiple matches.
356
		 */
357
		ranges: Range | Range[];
R
Rob Lourens 已提交
358

359
		/**
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
		 * 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.
382
		 */
383
		lineNumber: number;
384 385
	}

386 387
	export type TextSearchResult = TextSearchMatch | TextSearchContext;

388
	/**
R
Rob Lourens 已提交
389 390 391 392 393 394 395
	 * A FileSearchProvider provides search results for files in the given folder that match a query string. It can be invoked by quickopen or other extensions.
	 *
	 * A FileSearchProvider is the more powerful of two ways to implement file search in VS Code. Use a FileSearchProvider if you wish to search within a folder for
	 * all files that match the user's query.
	 *
	 * The FileSearchProvider will be invoked on every keypress in quickopen. When `workspace.findFiles` is called, it will be invoked with an empty query string,
	 * and in that case, every file in the folder should be returned.
396
	 */
397
	export interface FileSearchProvider {
398 399 400 401 402 403
		/**
		 * 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.
		 */
404
		provideFileSearchResults(query: FileSearchQuery, options: FileSearchOptions, token: CancellationToken): ProviderResult<Uri[]>;
405
	}
406

R
Rob Lourens 已提交
407 408 409 410
	/**
	 * A TextSearchProvider provides search results for text results inside files in the workspace.
	 */
	export interface TextSearchProvider {
411 412 413 414 415 416 417
		/**
		 * 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.
		 */
418
		provideTextSearchResults(query: TextSearchQuery, options: TextSearchOptions, progress: Progress<TextSearchResult>, token: CancellationToken): ProviderResult<TextSearchComplete>;
419 420
	}

421 422 423
	/**
	 * Options that can be set on a findTextInFiles search.
	 */
R
Rob Lourens 已提交
424
	export interface FindTextInFilesOptions {
425 426 427 428 429
		/**
		 * A [glob pattern](#GlobPattern) that defines the files to search for. The glob pattern
		 * will be matched against the file paths of files relative to their workspace. Use a [relative pattern](#RelativePattern)
		 * to restrict the search results to a [workspace folder](#WorkspaceFolder).
		 */
430
		include?: GlobPattern;
431 432 433 434 435 436 437 438 439 440 441

		/**
		 * A [glob pattern](#GlobPattern) that defines files and folders to exclude. The glob pattern
		 * will be matched against the file paths of resulting matches relative to their workspace. When `undefined` only default excludes will
		 * apply, when `null` no excludes will apply.
		 */
		exclude?: GlobPattern | null;

		/**
		 * The maximum number of results to search for
		 */
R
Rob Lourens 已提交
442
		maxResults?: number;
443 444 445 446 447

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

P
pkoushik 已提交
450 451 452 453
		/**
		 * Whether global files that exclude files, like .gitignore, should be respected.
		 * See the vscode setting `"search.useGlobalIgnoreFiles"`.
		 */
454
		useGlobalIgnoreFiles?: boolean;
P
pkoushik 已提交
455

456 457 458 459
		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
460
		followSymlinks?: boolean;
461 462 463 464 465

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

R
Rob Lourens 已提交
468 469 470
		/**
		 * Options to specify the size of the result text preview.
		 */
471
		previewOptions?: TextSearchPreviewOptions;
472 473 474 475 476 477 478 479 480 481

		/**
		 * 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 已提交
482 483
	}

484
	export namespace workspace {
485 486 487 488 489 490 491 492 493
		/**
		 * Register a search provider.
		 *
		 * Only one provider can be registered per scheme.
		 *
		 * @param scheme The provider will be invoked for workspace folders that have this file scheme.
		 * @param provider The provider.
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
		 */
R
Rob Lourens 已提交
494
		export function registerFileSearchProvider(scheme: string, provider: FileSearchProvider): Disposable;
495

496
		/**
R
Rob Lourens 已提交
497
		 * Register a text search provider.
498 499 500 501 502 503 504
		 *
		 * Only one provider can be registered per scheme.
		 *
		 * @param scheme The provider will be invoked for workspace folders that have this file scheme.
		 * @param provider The provider.
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
		 */
R
Rob Lourens 已提交
505
		export function registerTextSearchProvider(scheme: string, provider: TextSearchProvider): Disposable;
506 507 508 509 510 511 512 513

		/**
		 * Search text in files across all [workspace folders](#workspace.workspaceFolders) in the workspace.
		 * @param query The query parameters for the search - the search string, whether it's case-sensitive, or a regex, or matches whole words.
		 * @param callback A callback, called for each result
		 * @param token A token that can be used to signal cancellation to the underlying search engine.
		 * @return A thenable that resolves when the search is complete.
		 */
514
		export function findTextInFiles(query: TextSearchQuery, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
515 516 517 518 519 520 521 522 523

		/**
		 * Search text in files across all [workspace folders](#workspace.workspaceFolders) in the workspace.
		 * @param query The query parameters for the search - the search string, whether it's case-sensitive, or a regex, or matches whole words.
		 * @param options An optional set of query options. Include and exclude patterns, maxResults, etc.
		 * @param callback A callback, called for each result
		 * @param token A token that can be used to signal cancellation to the underlying search engine.
		 * @return A thenable that resolves when the search is complete.
		 */
524
		export function findTextInFiles(query: TextSearchQuery, options: FindTextInFilesOptions, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
525 526
	}

J
Johannes Rieken 已提交
527
	//#endregion
528

J
Johannes Rieken 已提交
529
	//#region Joao: diff command
P
Pine Wu 已提交
530

J
Joao Moreno 已提交
531 532 533
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
534 535 536 537 538 539 540
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
	export namespace commands {

		/**
		 * Registers a diff information command that can be invoked via a keyboard shortcut,
		 * a menu item, an action, or directly.
		 *
		 * Diff information commands are different from ordinary [commands](#commands.registerCommand) as
		 * they only execute when there is an active diff editor when the command is called, and the diff
		 * information has been computed. Also, the command handler of an editor command has access to
		 * the diff information.
		 *
		 * @param command A unique identifier for the command.
		 * @param callback A command handler function with access to the [diff information](#LineChange).
		 * @param thisArg The `this` context used when invoking the handler function.
		 * @return Disposable which unregisters this command on disposal.
		 */
		export function registerDiffInformationCommand(command: string, callback: (diff: LineChange[], ...args: any[]) => any, thisArg?: any): Disposable;
	}
559

J
Johannes Rieken 已提交
560 561 562
	//#endregion

	//#region Joh: decorations
563 564 565

	//todo@joh -> make class
	export interface DecorationData {
566
		letter?: string;
567 568 569
		title?: string;
		color?: ThemeColor;
		priority?: number;
570
		bubble?: boolean;
J
Johannes Rieken 已提交
571
		source?: string; // hacky... we should remove it and use equality under the hood
572 573
	}

574 575 576 577 578 579
	export interface SourceControlResourceDecorations {
		source?: string;
		letter?: string;
		color?: ThemeColor;
	}

580
	export interface DecorationProvider {
581
		onDidChangeDecorations: Event<undefined | Uri | Uri[]>;
582 583 584 585
		provideDecoration(uri: Uri, token: CancellationToken): ProviderResult<DecorationData>;
	}

	export namespace window {
586
		export function registerDecorationProvider(provider: DecorationProvider): Disposable;
587 588 589
	}

	//#endregion
590

J
Johannes Rieken 已提交
591 592
	//#region André: debug

A
Andre Weinand 已提交
593 594
	// deprecated

595
	export interface DebugConfigurationProvider {
596
		/**
A
Andre Weinand 已提交
597 598
		 * Deprecated, use DebugAdapterDescriptorFactory.provideDebugAdapter instead.
		 * @deprecated Use DebugAdapterDescriptorFactory.createDebugAdapterDescriptor instead
599 600
		 */
		debugAdapterExecutable?(folder: WorkspaceFolder | undefined, token?: CancellationToken): ProviderResult<DebugAdapterExecutable>;
601 602
	}

J
Johannes Rieken 已提交
603 604 605 606
	//#endregion

	//#region Rob, Matt: logging

607 608 609 610 611 612 613 614 615 616 617 618 619
	/**
	 * The severity level of a log message
	 */
	export enum LogLevel {
		Trace = 1,
		Debug = 2,
		Info = 3,
		Warning = 4,
		Error = 5,
		Critical = 6,
		Off = 7
	}

M
Matt Bierner 已提交
620 621 622 623 624
	export namespace env {
		/**
		 * Current logging level.
		 */
		export const logLevel: LogLevel;
625 626 627 628 629

		/**
		 * An [event](#Event) that fires when the log level has changed.
		 */
		export const onDidChangeLogLevel: Event<LogLevel>;
M
Matt Bierner 已提交
630 631
	}

J
Johannes Rieken 已提交
632 633 634
	//#endregion

	//#region Joao: SCM validation
635

J
Joao Moreno 已提交
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680
	/**
	 * Represents the validation type of the Source Control input.
	 */
	export enum SourceControlInputBoxValidationType {

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

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

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

	export interface SourceControlInputBoxValidation {

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

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

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

		/**
		 * A validation function for the input box. It's possible to change
		 * the validation provider simply by setting this property to a different function.
		 */
		validateInput?(value: string, cursorPosition: number): ProviderResult<SourceControlInputBoxValidation | undefined | null>;
	}
M
Matt Bierner 已提交
681

J
Johannes Rieken 已提交
682 683
	//#endregion

684 685 686 687 688 689 690 691 692 693 694 695 696
	//#region Joao: SCM selected provider

	export interface SourceControl {

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

		/**
		 * An event signaling when the selection state changes.
		 */
		readonly onDidChangeSelection: Event<boolean>;
697 698 699 700
	}

	//#endregion

701 702 703 704 705 706 707 708
	//#region Joao: SCM Input Box

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

		/**
J
Joao Moreno 已提交
709 710
			* Controls whether the input box is visible (default is `true`).
			*/
711 712 713 714 715
		visible: boolean;
	}

	//#endregion

716 717 718 719 720
	//#region Comments
	/**
	 * Comments provider related APIs are still in early stages, they may be changed significantly during our API experiments.
	 */

721
	interface CommentInfo {
722 723 724
		/**
		 * All of the comment threads associated with the document.
		 */
725
		threads: CommentThread[];
726 727 728 729

		/**
		 * The ranges of the document which support commenting.
		 */
730
		commentingRanges?: Range[];
R
rebornix 已提交
731 732 733 734 735

		/**
		 * If it's in draft mode or not
		 */
		inDraftMode?: boolean;
736 737
	}

738 739 740
	/**
	 * A comment is displayed within the editor or the Comments Panel, depending on how it is provided.
	 */
741 742 743 744 745 746 747 748 749 750 751
	export interface Comment {
		/**
		 * The display name of the user who created the comment
		 */
		readonly userName: string;

		/**
		 * The icon path for the user who created the comment
		 */
		readonly userIconPath?: Uri;

P
Peng Lyu 已提交
752 753 754 755 756
		/**
		 * The id of the comment
		 *
		 * @deprecated Use Id instead
		 */
P
Peng Lyu 已提交
757
		readonly commentId: string;
758

759 760
		/**
		 * @deprecated Use userIconPath instead. The avatar src of the user who created the comment
761
		 */
762
		gravatar?: string;
763 764 765 766 767 768

		/**
		 * Whether the current user has permission to edit the comment.
		 *
		 * This will be treated as false if the comment is provided by a `WorkspaceCommentProvider`, or
		 * if it is provided by a `DocumentCommentProvider` and  no `editComment` method is given.
P
Peng Lyu 已提交
769 770
		 *
		 * DEPRECATED, use editCommand
771 772 773
		 */
		canEdit?: boolean;

774 775 776 777 778
		/**
		 * Whether the current user has permission to delete the comment.
		 *
		 * This will be treated as false if the comment is provided by a `WorkspaceCommentProvider`, or
		 * if it is provided by a `DocumentCommentProvider` and  no `deleteComment` method is given.
P
Peng Lyu 已提交
779 780
		 *
		 * DEPRECATED, use deleteCommand
781 782 783
		 */
		canDelete?: boolean;

784
		/**
P
Peng Lyu 已提交
785
		 * @deprecated
786 787
		 * The command to be executed if the comment is selected in the Comments Panel
		 */
788
		command?: Command;
R
rebornix 已提交
789

P
Peng Lyu 已提交
790 791 792
		/**
		 * Deprecated
		 */
R
rebornix 已提交
793
		isDraft?: boolean;
P
Peng Lyu 已提交
794

795 796 797 798 799
		/**
		 * The command to be executed when users try to delete the comment
		 */
		deleteCommand?: Command;

P
Peng Lyu 已提交
800 801 802
		/**
		 * Proposed Comment Reaction
		 */
P
Peng Lyu 已提交
803
		commentReactions?: CommentReaction[];
M
Matt Bierner 已提交
804 805
	}

P
Peng Lyu 已提交
806 807 808
	/**
	 * Deprecated
	 */
809 810 811 812
	export interface CommentThreadChangedEvent {
		/**
		 * Added comment threads.
		 */
813
		readonly added: ReadonlyArray<CommentThread>;
814 815 816 817

		/**
		 * Removed comment threads.
		 */
818
		readonly removed: ReadonlyArray<CommentThread>;
819 820 821 822

		/**
		 * Changed comment threads.
		 */
823
		readonly changed: ReadonlyArray<CommentThread>;
R
rebornix 已提交
824 825 826 827 828

		/**
		 * Changed draft mode
		 */
		readonly inDraftMode: boolean;
829 830
	}

P
Peng Lyu 已提交
831 832
	/**
	 * Comment Reactions
P
Peng Lyu 已提交
833
	 * Stay in proposed.
P
Peng Lyu 已提交
834
	 */
P
Peng Lyu 已提交
835
	interface CommentReaction {
P
Peng Lyu 已提交
836
		readonly hasReacted?: boolean;
P
Peng Lyu 已提交
837 838
	}

P
Peng Lyu 已提交
839 840 841
	/**
	 * DEPRECATED
	 */
842
	interface DocumentCommentProvider {
843 844 845
		/**
		 * Provide the commenting ranges and comment threads for the given document. The comments are displayed within the editor.
		 */
846
		provideDocumentComments(document: TextDocument, token: CancellationToken): Promise<CommentInfo>;
847 848 849 850

		/**
		 * Called when a user adds a new comment thread in the document at the specified range, with body text.
		 */
851
		createNewCommentThread(document: TextDocument, range: Range, text: string, token: CancellationToken): Promise<CommentThread>;
852 853 854 855

		/**
		 * Called when a user replies to a new comment thread in the document at the specified range, with body text.
		 */
856
		replyToCommentThread(document: TextDocument, range: Range, commentThread: CommentThread, text: string, token: CancellationToken): Promise<CommentThread>;
857 858

		/**
N
Nick Schonning 已提交
859
		 * Called when a user edits the comment body to the be new text.
860
		 */
861
		editComment?(document: TextDocument, comment: Comment, text: string, token: CancellationToken): Promise<void>;
862

863 864 865 866 867
		/**
		 * Called when a user deletes the comment.
		 */
		deleteComment?(document: TextDocument, comment: Comment, token: CancellationToken): Promise<void>;

868 869 870
		startDraft?(document: TextDocument, token: CancellationToken): Promise<void>;
		deleteDraft?(document: TextDocument, token: CancellationToken): Promise<void>;
		finishDraft?(document: TextDocument, token: CancellationToken): Promise<void>;
R
rebornix 已提交
871 872 873 874 875

		startDraftLabel?: string;
		deleteDraftLabel?: string;
		finishDraftLabel?: string;

P
Peng Lyu 已提交
876 877 878
		addReaction?(document: TextDocument, comment: Comment, reaction: CommentReaction): Promise<void>;
		deleteReaction?(document: TextDocument, comment: Comment, reaction: CommentReaction): Promise<void>;
		reactionGroup?: CommentReaction[];
P
Peng Lyu 已提交
879

880 881 882
		/**
		 * Notify of updates to comment threads.
		 */
883
		onDidChangeCommentThreads: Event<CommentThreadChangedEvent>;
884 885
	}

P
Peng Lyu 已提交
886 887 888
	/**
	 * DEPRECATED
	 */
889
	interface WorkspaceCommentProvider {
890 891 892 893
		/**
		 * Provide all comments for the workspace. Comments are shown within the comments panel. Selecting a comment
		 * from the panel runs the comment's command.
		 */
894
		provideWorkspaceComments(token: CancellationToken): Promise<CommentThread[]>;
895 896 897 898

		/**
		 * Notify of updates to comment threads.
		 */
899
		onDidChangeCommentThreads: Event<CommentThreadChangedEvent>;
M
Matt Bierner 已提交
900 901
	}

P
Peng Lyu 已提交
902 903 904
	/**
	 * Stay in proposed
	 */
P
Peng Lyu 已提交
905 906 907 908 909
	export interface CommentReactionProvider {
		availableReactions: CommentReaction[];
		toggleReaction?(document: TextDocument, comment: Comment, reaction: CommentReaction): Promise<void>;
	}

910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929
	export interface CommentThread {
		/**
		 * The uri of the document the thread has been created on.
		 */
		readonly resource: Uri;

		/**
		 * Optional additonal commands.
		 *
		 * `additionalCommands` are the secondary actions rendered on Comment Widget.
		 */
		additionalCommands?: Command[];

		/**
		 * The command to be executed when users try to delete the comment thread. Currently, this is only called
		 * when the user collapses a comment thread that has no comments in it.
		 */
		deleteCommand?: Command;
	}

930

P
Peng Lyu 已提交
931
	export interface CommentController {
P
Peng Lyu 已提交
932 933
		/**
		 * Optional reaction provider
P
Peng Lyu 已提交
934
		 * Stay in proposed.
P
Peng Lyu 已提交
935 936
		 */
		reactionProvider?: CommentReactionProvider;
P
Peng Lyu 已提交
937
	}
P
Peng Lyu 已提交
938

M
Matt Bierner 已提交
939
	namespace workspace {
P
Peng Lyu 已提交
940 941 942 943
		/**
		 * DEPRECATED
		 * Use vscode.comment.createCommentController instead.
		 */
944
		export function registerDocumentCommentProvider(provider: DocumentCommentProvider): Disposable;
P
Peng Lyu 已提交
945 946 947 948
		/**
		 * DEPRECATED
		 * Use vscode.comment.createCommentController instead and we don't differentiate document comments and workspace comments anymore.
		 */
949
		export function registerWorkspaceCommentProvider(provider: WorkspaceCommentProvider): Disposable;
M
Matt Bierner 已提交
950
	}
951

P
Peng Lyu 已提交
952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
	/**
	 * A collection of [comments](#Comment) representing a conversation at a particular range in a document.
	 */
	export interface CommentThread {
		/**
		 * A unique identifier of the comment thread.
		 */
		readonly id: string;

		/**
		 * The uri of the document the thread has been created on.
		 */
		readonly uri: Uri;

		/**
		 * Optional accept input command
		 *
		 * `acceptInputCommand` is the default action rendered on Comment Widget, which is always placed rightmost.
		 * This command will be invoked when users the user accepts the value in the comment editor.
		 * This command will disabled when the comment editor is empty.
		 */
		acceptInputCommand?: Command;
	}

	/**
	 * A comment is displayed within the editor or the Comments Panel, depending on how it is provided.
	 */
	export interface Comment {
		/**
		 * The id of the comment
		 */
		id: string;

		/**
		 * The command to be executed if the comment is selected in the Comments Panel
		 */
		selectCommand?: Command;

		/**
		 * The command to be executed when users try to save the edits to the comment
		 */
		editCommand?: Command;
	}

	/**
	 * The comment input box in Comment Widget.
	 */
	export interface CommentInputBox {
		/**
		 * Setter and getter for the contents of the comment input box
		 */
		value: string;
	}

	/**
	 * Commenting range provider for a [comment controller](#CommentController).
	 */
	export interface CommentingRangeProvider {
		/**
		 * Provide a list of ranges which allow new comment threads creation or null for a given document
		 */
		provideCommentingRanges(document: TextDocument, token: CancellationToken): ProviderResult<Range[]>;
	}

P
Peng Lyu 已提交
1016
	export interface EmptyCommentThreadFactory {
P
Peng Lyu 已提交
1017
		/**
P
Peng Lyu 已提交
1018 1019
		 * The method `createEmptyCommentThread` is called when users attempt to create new comment thread from the gutter or command palette.
		 * Extensions still need to call `createCommentThread` inside this call when appropriate.
P
Peng Lyu 已提交
1020
		 */
P
Peng Lyu 已提交
1021
		createEmptyCommentThread(document: TextDocument, range: Range): ProviderResult<void>;
P
Peng Lyu 已提交
1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033
	}

	/**
	 * A comment controller is able to provide [comments](#CommentThread) support to the editor and
	 * provide users various ways to interact with comments.
	 */
	export interface CommentController {

		/**
		 * The active [comment input box](#CommentInputBox) or `undefined`. The active `inputBox` is the input box of
		 * the comment thread widget that currently has focus. It's `undefined` when the focus is not in any CommentInputBox.
		 */
P
Peng Lyu 已提交
1034
		readonly inputBox?: CommentInputBox;
P
Peng Lyu 已提交
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044

		/**
		 * Create a [comment thread](#CommentThread). The comment thread will be displayed in visible text editors (if the resource matches)
		 * and Comments Panel once created.
		 *
		 * @param id An `id` for the comment thread.
		 * @param resource The uri of the document the thread has been created on.
		 * @param range The range the comment thread is located within the document.
		 * @param comments The ordered comments of the thread.
		 */
1045
		createCommentThread(id: string, resource: Uri, range: Range, comments: Comment[]): CommentThread;
P
Peng Lyu 已提交
1046

P
Peng Lyu 已提交
1047 1048 1049 1050 1051 1052 1053 1054 1055 1056
		/**
		 * Optional new comment thread factory.
		 */
		emptyCommentThreadFactory?: EmptyCommentThreadFactory;

		/**
		 * Optional reaction provider
		 */
		reactionProvider?: CommentReactionProvider;

P
Peng Lyu 已提交
1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076
		/**
		 * Dispose this comment controller.
		 *
		 * Once disposed, all [comment threads](#CommentThread) created by this comment controller will also be removed from the editor
		 * and Comments Panel.
		 */
		dispose(): void;
	}

	namespace comment {
		/**
		 * Creates a new [comment controller](#CommentController) instance.
		 *
		 * @param id An `id` for the comment controller.
		 * @param label A human-readable string for the comment controller.
		 * @return An instance of [comment controller](#CommentController).
		 */
		export function createCommentController(id: string, label: string): CommentController;
	}

1077 1078
	//#endregion

1079 1080
	//#region Terminal

1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101
	/**
	 * An [event](#Event) which fires when a [Terminal](#Terminal)'s dimensions change.
	 */
	export interface TerminalDimensionsChangeEvent {
		/**
		 * The [terminal](#Terminal) for which the dimensions have changed.
		 */
		readonly terminal: Terminal;
		/**
		 * The new value for the [terminal's dimensions](#Terminal.dimensions).
		 */
		readonly dimensions: TerminalDimensions;
	}

	namespace window {
		/**
		 * An event which fires when the [dimensions](#Terminal.dimensions) of the terminal change.
		 */
		export const onDidChangeTerminalDimensions: Event<TerminalDimensionsChangeEvent>;
	}

D
Daniel Imms 已提交
1102
	export interface Terminal {
1103
		/**
1104 1105 1106
		 * 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.
1107
		 */
1108
		readonly dimensions: TerminalDimensions | undefined;
1109

D
Daniel Imms 已提交
1110
		/**
D
Daniel Imms 已提交
1111
		 * Fires when the terminal's pty slave pseudo-device is written to. In other words, this
D
Daniel Imms 已提交
1112
		 * provides access to the raw data stream from the process running within the terminal,
1113
		 * including VT sequences.
D
Daniel Imms 已提交
1114
		 */
1115
		readonly onDidWriteData: Event<string>;
D
Daniel Imms 已提交
1116 1117
	}

1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129

	export interface TerminalOptions {
		/**
		 * When enabled the terminal will run the process as normal but not be surfaced to the user
		 * until `Terminal.show` is called. The typical usage for this is when you need to run
		 * something that may need interactivity but only want to tell the user about it when
		 * interaction is needed. Note that the terminals will still be exposed to all extensions
		 * as normal.
		 */
		runInBackground?: boolean;
	}

D
Daniel Imms 已提交
1130
	/**
1131
	 * Represents the dimensions of a terminal.
D
Daniel Imms 已提交
1132 1133 1134 1135 1136
	 */
	export interface TerminalDimensions {
		/**
		 * The number of columns in the terminal.
		 */
1137
		readonly columns: number;
D
Daniel Imms 已提交
1138 1139 1140 1141

		/**
		 * The number of rows in the terminal.
		 */
1142
		readonly rows: number;
D
Daniel Imms 已提交
1143 1144
	}

1145 1146 1147
	/**
	 * Represents a terminal without a process where all interaction and output in the terminal is
	 * controlled by an extension. This is similar to an output window but has the same VT sequence
1148
	 * compatibility as the regular terminal.
D
Daniel Imms 已提交
1149 1150 1151 1152
	 *
	 * Note that an instance of [Terminal](#Terminal) will be created when a TerminalRenderer is
	 * created with all its APIs available for use by extensions. When using the Terminal object
	 * of a TerminalRenderer it acts just like normal only the extension that created the
1153
	 * TerminalRenderer essentially acts as a process. For example when an
1154 1155
	 * [Terminal.onDidWriteData](#Terminal.onDidWriteData) listener is registered, that will fire
	 * when [TerminalRenderer.write](#TerminalRenderer.write) is called. Similarly when
D
Daniel Imms 已提交
1156
	 * [Terminal.sendText](#Terminal.sendText) is triggered that will fire the
1157
	 * [TerminalRenderer.onDidAcceptInput](#TerminalRenderer.onDidAcceptInput) event.
1158
	 *
1159 1160
	 * @deprecated Use [virtual processes](#TerminalVirtualProcess) instead.
	 *
1161 1162 1163 1164 1165 1166
	 * **Example:** Create a terminal renderer, show it and write hello world in red
	 * ```typescript
	 * const renderer = window.createTerminalRenderer('foo');
	 * renderer.terminal.then(t => t.show());
	 * renderer.write('\x1b[31mHello world\x1b[0m');
	 * ```
1167
	 */
1168
	export interface TerminalRenderer {
1169 1170
		/**
		 * The name of the terminal, this will appear in the terminal selector.
1171
		 * @deprecated Use [virtual processes](#TerminalVirtualProcess) instead.
1172
		 */
1173 1174
		name: string;

D
Daniel Imms 已提交
1175 1176 1177 1178
		/**
		 * The dimensions of the terminal, the rows and columns of the terminal can only be set to
		 * a value smaller than the maximum value, if this is undefined the terminal will auto fit
		 * to the maximum value [maximumDimensions](TerminalRenderer.maximumDimensions).
1179
		 *
1180 1181
		 * @deprecated Use [virtual processes](#TerminalVirtualProcess) instead.
		 *
1182 1183 1184 1185 1186 1187 1188
		 * **Example:** Override the dimensions of a TerminalRenderer to 20 columns and 10 rows
		 * ```typescript
		 * terminalRenderer.dimensions = {
		 *   cols: 20,
		 *   rows: 10
		 * };
		 * ```
D
Daniel Imms 已提交
1189
		 */
1190
		dimensions: TerminalDimensions | undefined;
D
Daniel Imms 已提交
1191 1192 1193 1194 1195 1196

		/**
		 * The maximum dimensions of the terminal, this will be undefined immediately after a
		 * terminal renderer is created and also until the terminal becomes visible in the UI.
		 * Listen to [onDidChangeMaximumDimensions](TerminalRenderer.onDidChangeMaximumDimensions)
		 * to get notified when this value changes.
1197 1198
		 *
		 * @deprecated Use [virtual processes](#TerminalVirtualProcess) instead.
D
Daniel Imms 已提交
1199
		 */
1200
		readonly maximumDimensions: TerminalDimensions | undefined;
1201

1202
		/**
1203
		 * The corresponding [Terminal](#Terminal) for this TerminalRenderer.
1204 1205
		 *
		 * @deprecated Use [virtual processes](#TerminalVirtualProcess) instead.
1206
		 */
1207
		readonly terminal: Terminal;
1208

1209 1210 1211 1212
		/**
		 * Write text to the terminal. Unlike [Terminal.sendText](#Terminal.sendText) which sends
		 * text to the underlying _process_, this will write the text to the terminal itself.
		 *
1213 1214 1215
		 * @param text The text to write.
		 * @deprecated Use [virtual processes](#TerminalVirtualProcess) instead.
		 *
1216 1217 1218 1219 1220 1221 1222 1223 1224 1225
		 * **Example:** Write red text to the terminal
		 * ```typescript
		 * terminalRenderer.write('\x1b[31mHello world\x1b[0m');
		 * ```
		 *
		 * **Example:** Move the cursor to the 10th row and 20th column and write an asterisk
		 * ```typescript
		 * terminalRenderer.write('\x1b[10;20H*');
		 * ```
		 */
D
Daniel Imms 已提交
1226
		write(text: string): void;
1227

1228 1229 1230 1231
		/**
		 * An event which fires on keystrokes in the terminal or when an extension calls
		 * [Terminal.sendText](#Terminal.sendText). Keystrokes are converted into their
		 * corresponding VT sequence representation.
1232
		 *
1233 1234
		 * @deprecated Use [virtual processes](#TerminalVirtualProcess) instead.
		 *
1235 1236 1237 1238
		 * **Example:** Simulate interaction with the terminal from an outside extension or a
		 * workbench command such as `workbench.action.terminal.runSelectedText`
		 * ```typescript
		 * const terminalRenderer = window.createTerminalRenderer('test');
1239
		 * terminalRenderer.onDidAcceptInput(data => {
1240
		 *   console.log(data); // 'Hello world'
1241
		 * });
D
Daniel Imms 已提交
1242
		 * terminalRenderer.terminal.sendText('Hello world');
1243
		 * ```
1244
		 */
1245
		readonly onDidAcceptInput: Event<string>;
1246

D
Daniel Imms 已提交
1247
		/**
1248
		 * An event which fires when the [maximum dimensions](#TerminalRenderer.maximumDimensions) of
D
Daniel Imms 已提交
1249
		 * the terminal renderer change.
1250 1251
		 *
		 * @deprecated Use [virtual processes](#TerminalVirtualProcess) instead.
D
Daniel Imms 已提交
1252
		 */
1253
		readonly onDidChangeMaximumDimensions: Event<TerminalDimensions>;
1254 1255
	}

1256
	export namespace window {
D
Daniel Imms 已提交
1257 1258 1259 1260
		/**
		 * Create a [TerminalRenderer](#TerminalRenderer).
		 *
		 * @param name The name of the terminal renderer, this shows up in the terminal selector.
1261
		 * @deprecated Use [virtual processes](#TerminalVirtualProcess) instead.
D
Daniel Imms 已提交
1262
		 */
1263
		export function createTerminalRenderer(name: string): TerminalRenderer;
1264 1265 1266
	}

	//#endregion
J
Joao Moreno 已提交
1267

1268 1269
	//#region Terminal virtual process

D
Daniel Imms 已提交
1270 1271 1272 1273 1274 1275 1276 1277 1278 1279
	export namespace window {
		/**
		 * Creates a [Terminal](#Terminal) where an extension acts as the process.
		 *
		 * @param options A [TerminalVirtualProcessOptions](#TerminalVirtualProcessOptions) object describing the
		 * characteristics of the new terminal.
		 * @return A new Terminal.
		 */
		export function createTerminal(options: TerminalVirtualProcessOptions): Terminal;
	}
1280

D
Daniel Imms 已提交
1281 1282 1283
	/**
	 * Value-object describing what options a virtual process terminal should use.
	 */
1284
	export interface TerminalVirtualProcessOptions {
D
Daniel Imms 已提交
1285 1286 1287
		/**
		 * A human-readable string which will be used to represent the terminal in the UI.
		 */
1288 1289
		name: string;

D
Daniel Imms 已提交
1290 1291 1292 1293
		/**
		 * An implementation of [TerminalVirtualProcess](#TerminalVirtualProcess) that allows an
		 * extension to act as a terminal's backing process.
		 */
1294 1295 1296
		virtualProcess: TerminalVirtualProcess;
	}

D
Daniel Imms 已提交
1297 1298 1299 1300
	/**
	 * Defines the interface of a terminal virtual process, enabling extensions to act as a process
	 * in the terminal.
	 */
1301
	interface TerminalVirtualProcess {
D
Daniel Imms 已提交
1302 1303 1304 1305 1306 1307 1308 1309 1310
		/**
		 * An event that when fired will write data to the terminal. Unlike
		 * [Terminal.sendText](#Terminal.sendText) which sends text to the underlying _process_,
		 * this will write the text to the terminal itself.
		 *
		 * **Example:** Write red text to the terminal
		 * ```typescript
		 * const writeEmitter = new vscode.EventEmitter<string>();
		 * const virtualProcess: TerminalVirtualProcess = {
D
Daniel Imms 已提交
1311
		 *   onDidWrite: writeEmitter.event
D
Daniel Imms 已提交
1312 1313 1314 1315 1316 1317 1318 1319 1320 1321
		 * };
		 * vscode.window.createTerminal({ name: 'My terminal', virtualProcess });
		 * writeEmitter.fire('\x1b[31mHello world\x1b[0m');
		 * ```
		 *
		 * **Example:** Move the cursor to the 10th row and 20th column and write an asterisk
		 * ```typescript
		 * writeEmitter.fire('\x1b[10;20H*');
		 * ```
		 */
D
Daniel Imms 已提交
1322
		onDidWrite: Event<string>;
1323

D
Daniel Imms 已提交
1324 1325 1326 1327 1328 1329 1330 1331 1332 1333
		/**
		 * An event that when fired allows overriding the [dimensions](#Terminal.dimensions) of the
		 * terminal. Note that when set the overridden dimensions will only take effect when they
		 * are lower than the actual dimensions of the terminal (ie. there will never be a scroll
		 * bar). Set to `undefined` for the terminal to go back to the regular dimensions.
		 *
		 * **Example:** Override the dimensions of a terminal to 20 columns and 10 rows
		 * ```typescript
		 * const dimensionsEmitter = new vscode.EventEmitter<string>();
		 * const virtualProcess: TerminalVirtualProcess = {
D
Daniel Imms 已提交
1334 1335
		 *   onDidWrite: writeEmitter.event,
		 *   onDidOverrideDimensions: dimensionsEmitter.event
D
Daniel Imms 已提交
1336 1337 1338 1339 1340 1341 1342 1343
		 * };
		 * vscode.window.createTerminal({ name: 'My terminal', virtualProcess });
		 * dimensionsEmitter.fire({
		 *   columns: 20,
		 *   rows: 10
		 * });
		 * ```
		 */
D
Daniel Imms 已提交
1344
		onDidOverrideDimensions?: Event<TerminalDimensions | undefined>;
1345

D
Daniel Imms 已提交
1346 1347 1348
		/**
		 * An event that when fired will exit the process with an exit code, this will behave the
		 * same for a virtual process as when a regular process exits with an exit code.
D
Daniel Imms 已提交
1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359
		 *
		 * **Example:** Exit with an exit code of `0` if the y key is pressed, otherwise `1`.
		 * ```typescript
		 * const writeEmitter = new vscode.EventEmitter<string>();
		 * const exitEmitter = new vscode.EventEmitter<number>();
		 * const virtualProcess: TerminalVirtualProcess = {
		 *   onDidWrite: writeEmitter.event,
		 *   input: data => exitEmitter.fire(data === 'y' ? 0 : 1)
		 * };
		 * vscode.window.createTerminal({ name: 'Exit example', virtualProcess });
		 * writeEmitter.fire('Press y to exit successfully');
D
Daniel Imms 已提交
1360
		 */
D
Daniel Imms 已提交
1361
		onDidExit?: Event<number>;
1362

D
Daniel Imms 已提交
1363 1364
		/**
		 * Implement to handle keystrokes in the terminal or when an extension calls
D
Daniel Imms 已提交
1365 1366 1367 1368
		 * [Terminal.sendText](#Terminal.sendText). Keystrokes are converted into their
		 * corresponding VT sequence representation.
		 *
		 * @param data The sent data.
D
Daniel Imms 已提交
1369 1370 1371 1372 1373 1374
		 *
		 * **Example:** Echo input in the terminal. The sequence for enter (`\r`) is translated to
		 * CRLF to go to a new line and move the cursor to the start of the line.
		 * ```typescript
		 * const writeEmitter = new vscode.EventEmitter<string>();
		 * const virtualProcess: TerminalVirtualProcess = {
D
Daniel Imms 已提交
1375
		 *   onDidWrite: writeEmitter.event,
D
Daniel Imms 已提交
1376
		 *   handleInput: data => writeEmitter.fire(data === '\r' ? '\r\n' : data)
D
Daniel Imms 已提交
1377 1378 1379 1380
		 * };
		 * vscode.window.createTerminal({ name: 'Local echo', virtualProcess });
		 * ```
		 */
D
Daniel Imms 已提交
1381
		handleInput?(data: string): void;
1382

D
Daniel Imms 已提交
1383 1384
		/**
		 * Implement to handle when the number of rows and columns that fit into the terminal panel
D
Daniel Imms 已提交
1385 1386 1387
		 * changes, for example when font size changes or when the panel is resized. The initial
		 * state of a terminal's dimensions should be treated as `undefined` until this is triggered
		 * as the size of a terminal isn't know until it shows up in the user interface.
D
Daniel Imms 已提交
1388 1389 1390
		 *
		 * @param dimensions The new dimensions.
		 */
D
Daniel Imms 已提交
1391
		setDimensions?(dimensions: TerminalDimensions): void;
1392 1393

		/**
D
Daniel Imms 已提交
1394
		 * Implement to handle when the terminal shuts down by an act of the user.
1395
		 */
D
Daniel Imms 已提交
1396
		shutdown?(): void;
1397 1398 1399 1400
	}

	//#endregion

1401 1402 1403 1404 1405 1406 1407
	//#region Joh -> exclusive document filters

	export interface DocumentFilter {
		exclusive?: boolean;
	}

	//#endregion
C
Christof Marti 已提交
1408

J
Johannes Rieken 已提交
1409
	//#region mjbvz,joh: https://github.com/Microsoft/vscode/issues/43768
1410 1411 1412
	export interface FileRenameEvent {
		readonly oldUri: Uri;
		readonly newUri: Uri;
C
Christof Marti 已提交
1413 1414
	}

1415 1416 1417
	export interface FileWillRenameEvent {
		readonly oldUri: Uri;
		readonly newUri: Uri;
1418
		waitUntil(thenable: Thenable<WorkspaceEdit>): void;
1419 1420
	}

1421
	export namespace workspace {
1422
		export const onWillRenameFile: Event<FileWillRenameEvent>;
1423
		export const onDidRenameFile: Event<FileRenameEvent>;
1424 1425
	}
	//#endregion
1426

1427 1428 1429 1430 1431 1432 1433 1434
	//#region Alex - OnEnter enhancement
	export interface OnEnterRule {
		/**
		 * This rule will only execute if the text above the this line matches this regular expression.
		 */
		oneLineAboveText?: RegExp;
	}
	//#endregion
1435

1436 1437
	//#region Tree View

S
Sandeep Somavarapu 已提交
1438 1439 1440 1441 1442 1443 1444 1445 1446
	export interface TreeView<T> {

		/**
		 * An optional human-readable message that will be rendered in the view.
		 */
		message?: string | MarkdownString;

	}

1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457
	/**
	 * Label describing the [Tree item](#TreeItem)
	 */
	export interface TreeItemLabel {

		/**
		 * A human-readable string describing the [Tree item](#TreeItem).
		 */
		label: string;

		/**
S
Sandeep Somavarapu 已提交
1458
		 * Ranges in the label to highlight. A range is defined as a tuple of two number where the
S
Sandeep Somavarapu 已提交
1459
		 * first is the inclusive start index and the second the exclusive end index
1460
		 */
S
Sandeep Somavarapu 已提交
1461
		highlights?: [number, number][];
1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476

	}

	export class TreeItem2 extends TreeItem {
		/**
		 * Label describing this item. When `falsy`, it is derived from [resourceUri](#TreeItem.resourceUri).
		 */
		label?: string | TreeItemLabel | /* for compilation */ any;

		/**
		 * @param label Label describing this item
		 * @param collapsibleState [TreeItemCollapsibleState](#TreeItemCollapsibleState) of the tree item. Default is [TreeItemCollapsibleState.None](#TreeItemCollapsibleState.None)
		 */
		constructor(label: TreeItemLabel, collapsibleState?: TreeItemCollapsibleState);
	}
1477 1478
	//#endregion

1479 1480 1481
	/**
	 * Class used to execute an extension callback as a task.
	 */
G
Gabriel DeBacker 已提交
1482
	export class CustomExecution {
1483 1484 1485
		/**
		 * @param callback The callback that will be called when the extension callback task is executed.
		 */
G
Gabriel DeBacker 已提交
1486
		constructor(callback: (terminalRenderer: TerminalRenderer, cancellationToken: CancellationToken, thisArg?: any) => Thenable<number>);
1487 1488 1489

		/**
		 * The callback used to execute the task.
G
Gabriel DeBacker 已提交
1490 1491 1492
		 * @param terminalRenderer Used by the task to render output and receive input.
		 * @param cancellationToken Cancellation used to signal a cancel request to the executing task.
		 * @returns The callback should return '0' for success and a non-zero value for failure.
1493
		 */
G
Gabriel DeBacker 已提交
1494
		callback: (terminalRenderer: TerminalRenderer, cancellationToken: CancellationToken, thisArg?: any) => Thenable<number>;
1495 1496 1497 1498 1499
	}

	/**
	 * A task to execute
	 */
G
Gabriel DeBacker 已提交
1500
	export class Task2 extends Task {
1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512
		/**
		 * Creates a new task.
		 *
		 * @param definition The task definition as defined in the taskDefinitions extension point.
		 * @param scope Specifies the task's scope. It is either a global or a workspace task or a task for a specific workspace folder.
		 * @param name The task's name. Is presented in the user interface.
		 * @param source The task's source (e.g. 'gulp', 'npm', ...). Is presented in the user interface.
		 * @param execution The process or shell execution.
		 * @param problemMatchers the names of problem matchers to use, like '$tsc'
		 *  or '$eslint'. Problem matchers can be contributed by an extension using
		 *  the `problemMatchers` extension point.
		 */
G
Gabriel DeBacker 已提交
1513
		constructor(taskDefinition: TaskDefinition, scope: WorkspaceFolder | TaskScope.Global | TaskScope.Workspace, name: string, source: string, execution?: ProcessExecution | ShellExecution | CustomExecution, problemMatchers?: string | string[]);
1514 1515 1516 1517

		/**
		 * The task's execution engine
		 */
G
Gabriel DeBacker 已提交
1518
		execution2?: ProcessExecution | ShellExecution | CustomExecution;
1519
	}
G
Gabriel DeBacker 已提交
1520

1521 1522 1523 1524 1525 1526 1527 1528
	//#region Tasks
	export interface TaskPresentationOptions {
		/**
		 * Controls whether the task is executed in a specific terminal group using split panes.
		 */
		group?: string;
	}
	//#endregion
1529

1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 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 1573 1574 1575 1576
	// #region Ben - status bar item with ID and Name

	export namespace window {

		/**
		 * Options to configure the status bar item.
		 */
		export interface StatusBarItemOptions {

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

			/**
			 * A human readable name of the status bar item. The name is
			 * for example used as a label in the UI to show or hide the
			 * status bar item.
			 */
			name: string;

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

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

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

	//#endregion
1577 1578 1579

	//#region Webview Resource Roots

1580
	export interface Webview {
1581
		/**
M
Matt Bierner 已提交
1582 1583 1584 1585 1586 1587
		 * Convert a uri for the local file system to one that can be used inside webviews.
		 */
		toWebviewResource(localResource: Uri): Uri;

		/**
		 * Content security policy rule for webview resources.
1588
		 */
1589
		readonly cspSource: string;
1590 1591 1592
	}

	//#endregion
1593 1594 1595 1596


	//#region Joh - read/write files of any scheme

J
Johannes Rieken 已提交
1597 1598 1599 1600 1601 1602
	/**
	 * The file system interface exposes the editor's built-in and contributed
	 * [file system providers](#FileSystemProvider). It allows extensions to work
	 * with files from the local disk as well as files from remote places, like the
	 * remote extension host or ftp-servers.
	 */
1603
	export interface FileSystem {
J
Johannes Rieken 已提交
1604 1605 1606 1607 1608 1609 1610

		/**
		 * Retrieve metadata about a file.
		 *
		 * @param uri The uri of the file to retrieve metadata about.
		 * @return The file metadata about the file.
		 */
1611
		stat(uri: Uri): Thenable<FileStat>;
J
Johannes Rieken 已提交
1612 1613 1614 1615 1616 1617 1618

		/**
		 * Retrieve all entries of a [directory](#FileType.Directory).
		 *
		 * @param uri The uri of the folder.
		 * @return An array of name/type-tuples or a thenable that resolves to such.
		 */
1619
		readDirectory(uri: Uri): Thenable<[string, FileType][]>;
J
Johannes Rieken 已提交
1620 1621 1622 1623 1624 1625

		/**
		 * Create a new directory (Note, that new files are created via `write`-calls).
		 *
		 * @param uri The uri of the new folder.
		 */
1626
		createDirectory(uri: Uri): Thenable<void>;
J
Johannes Rieken 已提交
1627 1628 1629 1630 1631 1632 1633

		/**
		 * Read the entire contents of a file.
		 *
		 * @param uri The uri of the file.
		 * @return An array of bytes or a thenable that resolves to such.
		 */
1634
		readFile(uri: Uri): Thenable<Uint8Array>;
J
Johannes Rieken 已提交
1635 1636 1637 1638 1639 1640 1641

		/**
		 * Write data to a file, replacing its entire contents.
		 *
		 * @param uri The uri of the file.
		 * @param content The new content of the file.
		 */
1642
		writeFile(uri: Uri, content: Uint8Array): Thenable<void>;
J
Johannes Rieken 已提交
1643 1644 1645 1646 1647

		/**
		 * Delete a file.
		 *
		 * @param uri The resource that is to be deleted.
1648
		 * @param options Defines if trash can should be used and if deletion of folders is recursive
J
Johannes Rieken 已提交
1649
		 */
1650
		delete(uri: Uri, options?: { recursive?: boolean, useTrash?: boolean }): Thenable<void>;
J
Johannes Rieken 已提交
1651 1652 1653 1654 1655 1656 1657 1658

		/**
		 * Rename a file or folder.
		 *
		 * @param oldUri The existing file.
		 * @param newUri The new location.
		 * @param options Defines if existing files should be overwritten.
		 */
1659
		rename(source: Uri, target: Uri, options?: { overwrite?: boolean }): Thenable<void>;
J
Johannes Rieken 已提交
1660 1661 1662 1663 1664 1665 1666 1667 1668

		/**
		 * Copy files or folders. Implementing this function is optional but it will speedup
		 * the copy operation.
		 *
		 * @param source The existing file.
		 * @param destination The destination location.
		 * @param options Defines if existing files should be overwritten.
		 */
1669
		copy(source: Uri, target: Uri, options?: { overwrite?: boolean }): Thenable<void>;
1670 1671 1672 1673
	}

	export namespace workspace {

J
Johannes Rieken 已提交
1674 1675 1676
		/**
		 * File system that allows to interact with local and remote files.
		 */
1677 1678 1679 1680
		export const fs: FileSystem;
	}

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