vscode.proposed.d.ts 36.5 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' {

A
Alex Dima 已提交
19 20
	//#region Alex - resolvers

A
Tweaks  
Alex Dima 已提交
21 22 23 24
	export interface RemoteAuthorityResolverContext {
		resolveAttempt: number;
	}

A
Alex Dima 已提交
25 26 27 28 29 30 31
	export class ResolvedAuthority {
		readonly host: string;
		readonly port: number;

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

32
	export interface ResolvedOptions {
33
		extensionHostEnv?: { [key: string]: string | null };
34 35
	}

36
	export type ResolverResult = ResolvedAuthority & ResolvedOptions;
37

A
Tweaks  
Alex Dima 已提交
38 39 40 41 42 43 44
	export class RemoteAuthorityResolverError extends Error {
		static NotAvailable(message?: string, handled?: boolean): RemoteAuthorityResolverError;
		static TemporarilyNotAvailable(message?: string): RemoteAuthorityResolverError;

		constructor(message?: string);
	}

A
Alex Dima 已提交
45
	export interface RemoteAuthorityResolver {
46
		resolve(authority: string, context: RemoteAuthorityResolverContext): ResolverResult | Thenable<ResolverResult>;
A
Alex Dima 已提交
47 48
	}

49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
	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 已提交
64 65
	export namespace workspace {
		export function registerRemoteAuthorityResolver(authorityPrefix: string, resolver: RemoteAuthorityResolver): Disposable;
66
		export function registerResourceLabelFormatter(formatter: ResourceLabelFormatter): Disposable;
67
	}
68

69 70
	//#endregion

A
WIP  
Alexandru Dima 已提交
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
	//#region Alex - semantic coloring

	export class SemanticColoringLegend {
		public readonly tokenTypes: string[];
		public readonly tokenModifiers: string[];

		constructor(tokenTypes: string[], tokenModifiers: string[]);
	}

	export class SemanticColoringArea {
		/**
		 * The zero-based line value where this token block begins.
		 */
		public readonly line: number;
		/**
		 * The actual token block encoded data.
A
Alex Dima 已提交
87 88 89 90 91 92
		 * A certain token (at index `i` is encoded using 5 uint32 integers):
		 *  - at index `5*i`   - `deltaLine`: token line number, relative to `SemanticColoringArea.line`
		 *  - at index `5*i+1` - `startCharacter`: token start character offset inside the line (inclusive)
		 *  - at index `5*i+2` - `endCharacter`: token end character offset inside the line (exclusive)
		 *  - at index `5*i+3` - `tokenType`: will be looked up in `SemanticColoringLegend.tokenTypes`
		 *  - at index `5*i+4` - `tokenModifiers`: each set bit will be looked up in `SemanticColoringLegend.tokenModifiers`
A
WIP  
Alexandru Dima 已提交
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
		 */
		public readonly data: Uint32Array;

		constructor(line: number, data: Uint32Array);
	}

	export class SemanticColoring {
		public readonly areas: SemanticColoringArea[];

		constructor(areas: SemanticColoringArea[]);
	}

	/**
	 * The semantic coloring provider interface defines the contract between extensions and
	 * semantic coloring.
	 *
	 *
	 */
	export interface SemanticColoringProvider {

		provideSemanticColoring(document: TextDocument, token: CancellationToken): ProviderResult<SemanticColoring>;
	}

	export namespace languages {
		/**
		 * Register a semantic coloring provider.
		 *
		 * Multiple providers can be registered for a language. In that case providers are sorted
		 * by their [score](#languages.match) and the best-matching provider is used. Failure
		 * of the selected provider will cause a failure of the whole operation.
		 *
		 * @param selector A selector that defines the documents this provider is applicable to.
		 * @param provider A semantic coloring provider.
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
		 */
128
		export function registerSemanticColoringProvider(selector: DocumentSelector, provider: SemanticColoringProvider, legend: SemanticColoringLegend): Disposable;
A
WIP  
Alexandru Dima 已提交
129 130 131
	}

	//#endregion
132 133 134

	// #region Joh - code insets

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

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

	//#endregion

150 151 152
	//#region Joh - read/write in chunks

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

161
	//#region Rob: search provider
162

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

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

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

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

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

193 194 195 196 197 198 199 200 201 202
	/**
	 * 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 已提交
203
	export interface SearchOptions {
204 205 206
		/**
		 * The root folder to search within.
		 */
207
		folder: Uri;
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222

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

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

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

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

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

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

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

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

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

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

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

291 292 293 294 295 296 297 298 299 300 301 302 303 304
	/**
	 * 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;
	}

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

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

		/**
		 * 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;
329 330
	}

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

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

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

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

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

388 389
	export type TextSearchResult = TextSearchMatch | TextSearchContext;

390
	/**
R
Rob Lourens 已提交
391 392 393 394 395 396 397
	 * 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.
398
	 */
399
	export interface FileSearchProvider {
400 401 402 403 404 405
		/**
		 * 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.
		 */
406
		provideFileSearchResults(query: FileSearchQuery, options: FileSearchOptions, token: CancellationToken): ProviderResult<Uri[]>;
407
	}
408

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

423 424 425
	/**
	 * Options that can be set on a findTextInFiles search.
	 */
R
Rob Lourens 已提交
426
	export interface FindTextInFilesOptions {
427 428 429 430 431
		/**
		 * 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).
		 */
432
		include?: GlobPattern;
433 434 435 436 437 438 439 440 441 442 443

		/**
		 * 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 已提交
444
		maxResults?: number;
445 446 447 448 449

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

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

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

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

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

		/**
		 * 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 已提交
484 485
	}

486
	export namespace workspace {
487 488 489 490 491 492 493 494 495
		/**
		 * 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 已提交
496
		export function registerFileSearchProvider(scheme: string, provider: FileSearchProvider): Disposable;
497

498
		/**
R
Rob Lourens 已提交
499
		 * Register a text search provider.
500 501 502 503 504 505 506
		 *
		 * 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 已提交
507
		export function registerTextSearchProvider(scheme: string, provider: TextSearchProvider): Disposable;
508 509 510 511 512 513 514 515

		/**
		 * 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.
		 */
516
		export function findTextInFiles(query: TextSearchQuery, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
517 518 519 520 521 522 523 524 525

		/**
		 * 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.
		 */
526
		export function findTextInFiles(query: TextSearchQuery, options: FindTextInFilesOptions, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
527 528
	}

J
Johannes Rieken 已提交
529
	//#endregion
530

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

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

543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560
	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;
	}
561

J
Johannes Rieken 已提交
562 563 564
	//#endregion

	//#region Joh: decorations
565

566
	export class Decoration {
567
		letter?: string;
568 569 570
		title?: string;
		color?: ThemeColor;
		priority?: number;
571
		bubble?: boolean;
572 573
	}

574
	export interface DecorationProvider {
575
		onDidChangeDecorations: Event<undefined | Uri | Uri[]>;
576
		provideDecoration(uri: Uri, token: CancellationToken): ProviderResult<Decoration>;
577 578 579
	}

	export namespace window {
580
		export function registerDecorationProvider(provider: DecorationProvider): Disposable;
581 582 583
	}

	//#endregion
584

J
Johannes Rieken 已提交
585 586
	//#region André: debug

587
	/**
A
Andre Weinand 已提交
588
	 * A DebugSource is an opaque stand-in type for the [Source](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Source) type defined in the Debug Adapter Protocol.
589 590
	 */
	export interface DebugSource {
A
Andre Weinand 已提交
591
		// Properties: see details [here](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Source).
592 593 594 595 596
	}

	export namespace debug {

		/**
A
Andre Weinand 已提交
597 598 599
		 * Converts a "Source" descriptor object received via the Debug Adapter Protocol into a Uri that can be used to load its contents.
		 * If the source descriptor is based on a path, a file Uri is returned.
		 * If the source descriptor uses a reference number, a specific debug Uri (scheme 'debug') is constructed that requires a corresponding VS Code ContentProvider and a running debug session
600
		 *
A
Andre Weinand 已提交
601
		 * If the "Source" descriptor has insufficient information for creating the Uri, an error is thrown.
602 603
		 *
		 * @param source An object conforming to the [Source](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Source) type defined in the Debug Adapter Protocol.
A
Andre Weinand 已提交
604
		 * @param session An optional debug session that will be used when the source descriptor uses a reference number to load the contents from an active debug session.
605 606
		 * @return A uri that can be used to load the contents of the source.
		 */
A
Andre Weinand 已提交
607
		export function asDebugSourceUri(source: DebugSource, session?: DebugSession): Uri;
608 609
	}

A
Andre Weinand 已提交
610 611
	// deprecated

612
	export interface DebugConfigurationProvider {
613
		/**
A
Andre Weinand 已提交
614 615
		 * Deprecated, use DebugAdapterDescriptorFactory.provideDebugAdapter instead.
		 * @deprecated Use DebugAdapterDescriptorFactory.createDebugAdapterDescriptor instead
616 617
		 */
		debugAdapterExecutable?(folder: WorkspaceFolder | undefined, token?: CancellationToken): ProviderResult<DebugAdapterExecutable>;
618 619
	}

J
Johannes Rieken 已提交
620 621 622 623
	//#endregion

	//#region Rob, Matt: logging

624 625 626 627 628 629 630 631 632 633 634 635 636
	/**
	 * 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 已提交
637 638 639 640 641
	export namespace env {
		/**
		 * Current logging level.
		 */
		export const logLevel: LogLevel;
642 643 644 645 646

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

J
Johannes Rieken 已提交
649 650 651
	//#endregion

	//#region Joao: SCM validation
652

J
Joao Moreno 已提交
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 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697
	/**
	 * 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 已提交
698

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

701 702 703 704 705 706 707 708 709 710 711 712 713
	//#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>;
714 715 716 717
	}

	//#endregion

718 719 720 721 722 723 724 725
	//#region Joao: SCM Input Box

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

		/**
J
Joao Moreno 已提交
726 727
			* Controls whether the input box is visible (default is `true`).
			*/
728 729 730 731 732
		visible: boolean;
	}

	//#endregion

733

734 735
	//#region Terminal

736 737 738 739 740 741 742 743 744 745 746 747 748 749
	/**
	 * 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;
	}

750 751 752 753 754 755 756 757 758 759 760
	export interface TerminalDataWriteEvent {
		/**
		 * The [terminal](#Terminal) for which the data was written.
		 */
		readonly terminal: Terminal;
		/**
		 * The data being written.
		 */
		readonly data: string;
	}

D
Daniel Imms 已提交
761 762 763 764 765 766 767 768 769 770 771
	export interface TerminalExitStatus {
		/**
		 * The exit code that a terminal exited with, it can have the following values:
		 * - Zero: the terminal process or custom execution succeeded.
		 * - Non-zero: the terminal process or custom execution failed.
		 * - `undefined`: the user forcefully closed the terminal or a custom execution exited
		 *   without providing an exit code.
		 */
		readonly code: number | undefined;
	}

772 773 774 775 776
	namespace window {
		/**
		 * An event which fires when the [dimensions](#Terminal.dimensions) of the terminal change.
		 */
		export const onDidChangeTerminalDimensions: Event<TerminalDimensionsChangeEvent>;
777 778 779 780 781 782 783

		/**
		 * An event which fires when the terminal's pty slave pseudo-device is written to. In other
		 * words, this provides access to the raw data stream from the process running within the
		 * terminal, including VT sequences.
		 */
		export const onDidWriteTerminalData: Event<TerminalDataWriteEvent>;
784 785
	}

D
Daniel Imms 已提交
786
	export interface Terminal {
787 788 789 790 791 792 793
		/**
		 * The object used to initialize the terminal, this is useful for things like detecting the
		 * shell type of shells not launched by the extension or detecting what folder the shell was
		 * launched in.
		 */
		readonly creationOptions: Readonly<TerminalOptions | ExtensionTerminalOptions>;

794
		/**
795 796 797
		 * 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.
798
		 */
799
		readonly dimensions: TerminalDimensions | undefined;
D
Daniel Imms 已提交
800 801 802 803 804 805 806 807 808 809 810 811 812 813 814

		/**
		 * The exit status of the terminal, this will be undefined while the terminal is active.
		 *
		 * **Example:** Show a notification with the exit code when the terminal exits with a
		 * non-zero exit code.
		 * ```typescript
		 * window.onDidCloseTerminal(t => {
		 *   if (t.exitStatus && t.exitStatus.code) {
		 *   	vscode.window.showInformationMessage(`Exit code: ${t.exitStatus.code}`);
		 *   }
		 * });
		 * ```
		 */
		readonly exitStatus: TerminalExitStatus | undefined;
D
Daniel Imms 已提交
815 816
	}

817 818
	//#endregion

819 820 821 822 823 824 825
	//#region Joh -> exclusive document filters

	export interface DocumentFilter {
		exclusive?: boolean;
	}

	//#endregion
C
Christof Marti 已提交
826

J
Johannes Rieken 已提交
827
	//#region mjbvz,joh: https://github.com/Microsoft/vscode/issues/43768
828 829

	export interface FileCreateEvent {
830 831 832 833 834

		/**
		 * The files that got created.
		 */
		readonly files: ReadonlyArray<Uri>;
835 836 837
	}

	export interface FileWillCreateEvent {
838 839 840 841 842 843

		/**
		 * The files that are going to be created.
		 */
		readonly files: ReadonlyArray<Uri>;

844
		waitUntil(thenable: Thenable<WorkspaceEdit>): void;
845
		waitUntil(thenable: Thenable<any>): void;
846 847 848
	}

	export interface FileDeleteEvent {
849 850 851 852 853

		/**
		 * The files that got deleted.
		 */
		readonly files: ReadonlyArray<Uri>;
854 855 856
	}

	export interface FileWillDeleteEvent {
857 858 859 860 861 862

		/**
		 * The files that are going to be deleted.
		 */
		readonly files: ReadonlyArray<Uri>;

863
		waitUntil(thenable: Thenable<WorkspaceEdit>): void;
864
		waitUntil(thenable: Thenable<any>): void;
865 866
	}

867
	export interface FileRenameEvent {
868 869 870 871 872

		/**
		 * The files that got renamed.
		 */
		readonly files: ReadonlyArray<{ oldUri: Uri, newUri: Uri }>;
C
Christof Marti 已提交
873 874
	}

875
	export interface FileWillRenameEvent {
876 877 878 879 880 881

		/**
		 * The files that are going to be renamed.
		 */
		readonly files: ReadonlyArray<{ oldUri: Uri, newUri: Uri }>;

882
		waitUntil(thenable: Thenable<WorkspaceEdit>): void;
883
		waitUntil(thenable: Thenable<any>): void;
884 885
	}

886
	export namespace workspace {
887

J
Johannes Rieken 已提交
888 889 890
		/**
		 * An event that is emitted when files are being created.
		 *
891
		 * *Note:* This event is triggered by user gestures, like creating a file from the
J
Johannes Rieken 已提交
892 893 894 895
		 * explorer, or from the [`workspace.applyEdit`](#workspace.applyEdit)-api. This event is *not* fired when
		 * files change on disk, e.g triggered by another application, or when using the
		 * [`workspace.fs`](#FileSystem)-api.
		 */
J
Johannes Rieken 已提交
896
		export const onWillCreateFiles: Event<FileWillCreateEvent>;
J
Johannes Rieken 已提交
897

898 899 900 901 902 903 904 905 906 907
		/**
		 * An event that is emitted when files have been created.
		 *
		 * *Note:* This event is triggered by user gestures, like creating a file from the
		 * explorer, or from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
		 * files change on disk, e.g triggered by another application, or when using the
		 * [`workspace.fs`](#FileSystem)-api.
		 */
		export const onDidCreateFiles: Event<FileCreateEvent>;

J
Johannes Rieken 已提交
908 909 910
		/**
		 * An event that is emitted when files are being deleted.
		 *
911 912
		 * *Note 1:* This event is triggered by user gestures, like deleting a file from the
		 * explorer, or from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
J
Johannes Rieken 已提交
913 914
		 * files change on disk, e.g triggered by another application, or when using the
		 * [`workspace.fs`](#FileSystem)-api.
915 916
		 *
		 * *Note 2:* When deleting a folder with children only one event is fired.
J
Johannes Rieken 已提交
917
		 */
J
Johannes Rieken 已提交
918
		export const onWillDeleteFiles: Event<FileWillDeleteEvent>;
J
Johannes Rieken 已提交
919

920 921 922 923 924 925 926 927 928 929 930 931
		/**
		 * An event that is emitted when files have been deleted.
		 *
		 * *Note 1:* This event is triggered by user gestures, like deleting a file from the
		 * explorer, or from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
		 * files change on disk, e.g triggered by another application, or when using the
		 * [`workspace.fs`](#FileSystem)-api.
		 *
		 * *Note 2:* When deleting a folder with children only one event is fired.
		 */
		export const onDidDeleteFiles: Event<FileDeleteEvent>;

J
Johannes Rieken 已提交
932 933 934
		/**
		 * An event that is emitted when files are being renamed.
		 *
935 936
		 * *Note 1:* This event is triggered by user gestures, like renaming a file from the
		 * explorer, and from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
J
Johannes Rieken 已提交
937 938
		 * files change on disk, e.g triggered by another application, or when using the
		 * [`workspace.fs`](#FileSystem)-api.
939 940
		 *
		 * *Note 2:* When renaming a folder with children only one event is fired.
J
Johannes Rieken 已提交
941
		 */
J
Johannes Rieken 已提交
942
		export const onWillRenameFiles: Event<FileWillRenameEvent>;
943

944 945 946 947 948 949 950 951 952 953
		/**
		 * An event that is emitted when files have been renamed.
		 *
		 * *Note 1:* This event is triggered by user gestures, like renaming a file from the
		 * explorer, and from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
		 * files change on disk, e.g triggered by another application, or when using the
		 * [`workspace.fs`](#FileSystem)-api.
		 *
		 * *Note 2:* When renaming a folder with children only one event is fired.
		 */
954
		export const onDidRenameFiles: Event<FileRenameEvent>;
955 956
	}
	//#endregion
957

958 959 960 961 962 963 964 965
	//#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
966

967 968
	//#region Tree View

S
Sandeep Somavarapu 已提交
969
	export interface TreeView<T> {
970
		/**
A
Alex Ross 已提交
971 972
		 * The tree view title is initially taken from the extension package.json
		 * Changes to the title property will be properly reflected in the UI in the title of the view.
973 974
		 */
		title?: string;
S
Sandeep Somavarapu 已提交
975 976
	}

977 978 979 980 981 982 983 984 985 986 987
	/**
	 * Label describing the [Tree item](#TreeItem)
	 */
	export interface TreeItemLabel {

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

		/**
S
Sandeep Somavarapu 已提交
988
		 * Ranges in the label to highlight. A range is defined as a tuple of two number where the
S
Sandeep Somavarapu 已提交
989
		 * first is the inclusive start index and the second the exclusive end index
990
		 */
S
Sandeep Somavarapu 已提交
991
		highlights?: [number, number][];
992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006

	}

	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);
	}
1007
	//#endregion
1008

1009
	//#region CustomExecution
1010 1011


1012 1013 1014
	/**
	 * A task to execute
	 */
G
Gabriel DeBacker 已提交
1015
	export class Task2 extends Task {
1016
		detail?: string;
1017
	}
G
Gabriel DeBacker 已提交
1018

1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030
	export class CustomExecution2 extends CustomExecution {
		/**
		 * Constructs a CustomExecution task object. The callback will be executed the task is run, at which point the
		 * extension should return the Pseudoterminal it will "run in". The task should wait to do further execution until
		 * [Pseudoterminal.open](#Pseudoterminal.open) is called. Task cancellation should be handled using
		 * [Pseudoterminal.close](#Pseudoterminal.close). When the task is complete fire
		 * [Pseudoterminal.onDidClose](#Pseudoterminal.onDidClose).
		 * @param callback The callback that will be called when the task is started by a user.
		 */
		constructor(callback: (resolvedDefinition?: TaskDefinition) => Thenable<Pseudoterminal>);
	}

1031 1032 1033 1034 1035 1036 1037
	export interface TaskPresentationOptions {
		/**
		 * Controls whether the task is executed in a specific terminal group using split panes.
		 */
		group?: string;
	}
	//#endregion
1038

1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085
	// #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
1086

1087 1088
	// #region Ben - extension auth flow (desktop+web)

1089 1090 1091 1092 1093 1094 1095
	export interface AppUriOptions {
		payload?: {
			path?: string;
			query?: string;
			fragment?: string;
		};
	}
1096

1097
	export namespace env {
1098 1099

		/**
1100
		 * @deprecated use `vscode.env.asExternalUri` instead.
1101 1102 1103 1104 1105
		 */
		export function createAppUri(options?: AppUriOptions): Thenable<Uri>;
	}

	//#endregion
1106

1107
	//#region Custom editors, mjbvz
1108 1109

	/**
1110
	 *
1111
	 */
1112
	interface WebviewEditorCapabilities {
1113
		/**
1114 1115 1116 1117 1118 1119 1120 1121 1122 1123
		 * Invoked when the resource has been renamed in VS Code.
		 *
		 * This is called when the resource's new name also matches the custom editor selector.
		 *
		 * If this is not implemented—or if the new resource name does not match the existing selector—then VS Code
		 * will close and reopen the editor on  rename.
		 *
		 * @param newResource Full path to the resource.
		 *
		 * @return Thenable that signals the save is complete.
1124
		 */
1125
		rename?(newResource: Uri): Thenable<void>;
1126

1127
		readonly editingCapability?: WebviewEditorEditingCapability;
1128 1129
	}

1130
	interface WebviewEditorEditingCapability {
1131
		/**
1132
		 * Persist the resource.
1133
		 */
1134
		save(): Thenable<void>;
1135

M
Matt Bierner 已提交
1136
		/**
1137
		 * Called when the editor exits.
M
Matt Bierner 已提交
1138
		 */
1139
		hotExit(hotExitPath: Uri): Thenable<void>;
M
Matt Bierner 已提交
1140 1141

		/**
1142 1143 1144
		 * Signal to VS Code that an edit has occurred.
		 *
		 * Edits must be a json serilizable object.
M
Matt Bierner 已提交
1145
		 */
1146
		readonly onEdit: Event<any>;
M
Matt Bierner 已提交
1147 1148

		/**
1149 1150 1151 1152 1153 1154
		 * Apply a set of edits.
		 *
		 * This is triggered on redo and when restoring a custom editor after restart. Note that is not invoked
		 * when `onEdit` is called as `onEdit` implies also updating the view to reflect the edit.
		 *
		 * @param edit Array of edits. Sorted from oldest to most recent.
M
Matt Bierner 已提交
1155
		 */
1156
		applyEdits(edits: any[]): Thenable<void>;
1157 1158

		/**
1159
		 * Undo a set of edits.
1160
		 *
1161
		 * This is triggered when a user undoes an edit or when revert is called on a file.
1162
		 *
1163
		 * @param edit Array of edits. Sorted from most recent to oldest.
1164
		 */
1165
		undoEdits(edits: any[]): Thenable<void>;
1166
	}
1167 1168 1169

	export interface WebviewEditorProvider {
		/**
1170 1171 1172 1173 1174 1175 1176 1177 1178
		 * Fills out a `WebviewEditor` for a given resource.
		 *
		 * @param input Information about the resource being resolved.
		 * @param webview Webview being resolved. The provider should take ownership of this webview.
		 *
		 * @return Thenable to a `WebviewEditorCapabilities` indicating that the webview editor has been resolved.
		 *   The `WebviewEditorCapabilities` defines how the custom editor interacts with VS Code.
		 *   **❗️Note**: `WebviewEditorCapabilities` is not actually implemented... yet!
		 */
1179
		resolveWebviewEditor(
1180 1181 1182 1183 1184
			input: {
				readonly resource: Uri
			},
			webview: WebviewPanel,
		): Thenable<WebviewEditorCapabilities>;
1185 1186 1187 1188 1189 1190
	}

	namespace window {
		export function registerWebviewEditorProvider(
			viewType: string,
			provider: WebviewEditorProvider,
1191
			options?: WebviewPanelOptions,
1192 1193 1194 1195
		): Disposable;
	}

	//#endregion
1196

1197 1198 1199
	//#region joh, insert/replace completions: https://github.com/microsoft/vscode/issues/10266

	export interface CompletionItem {
1200 1201

		/**
1202
		 * A range or a insert and replace range selecting the text that should be replaced by this completion item.
1203
		 *
1204 1205 1206
		 * When omitted, the range of the [current word](#TextDocument.getWordRangeAtPosition) is used as replace-range
		 * and as insert-range the start of the [current word](#TextDocument.getWordRangeAtPosition) to the
		 * current position is used.
1207
		 *
1208 1209 1210
		 * *Note 1:* A range must be a [single line](#Range.isSingleLine) and it must
		 * [contain](#Range.contains) the position at which completion has been [requested](#CompletionItemProvider.provideCompletionItems).
		 * *Note 2:* A insert range must be a prefix of a replace range, that means it must be contained and starting at the same position.
1211
		 */
1212
		range2?: Range | { inserting: Range; replacing: Range; };
1213 1214 1215
	}

	//#endregion
P
Peter Elmers 已提交
1216

1217
	//#region chrmarti, pelmers - allow QuickPicks to skip sorting: https://github.com/microsoft/vscode/issues/73904
P
Peter Elmers 已提交
1218 1219 1220 1221 1222 1223 1224 1225 1226

	export interface QuickPick<T extends QuickPickItem> extends QuickInput {
		/**
		* An optional flag to sort the final results by index of first query match in label. Defaults to true.
		*/
		sortByLabel: boolean;
	}

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