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

6 7 8 9 10 11 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 Alex - resolvers, AlexR - ports
A
Alex Dima 已提交
20

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 37 38 39 40 41
	export interface TunnelOptions {
		remote: { port: number, host: string };
		localPort?: number;
		name?: string;
	}

42
	export interface Tunnel {
43
		remote: { port: number, host: string };
A
Alex Ross 已提交
44
		localAddress: string;
45 46
		onDispose: Event<void>;
		dispose(): void;
47 48 49 50 51 52 53 54 55 56 57
	}

	/**
	 * Used as part of the ResolverResult if the extension has any candidate, published, or forwarded ports.
	 */
	export interface TunnelInformation {
		/**
		 * Tunnels that are detected by the extension. The remotePort is used for display purposes.
		 * The localAddress should be the complete local address(ex. localhost:1234) for connecting to the port. Tunnels provided through
		 * detected are read-only from the forwarded ports UI.
		 */
A
Alex Ross 已提交
58
		detectedTunnels?: { remote: { port: number, host: string }, localAddress: string }[];
59 60 61
	}

	export type ResolverResult = ResolvedAuthority & ResolvedOptions & TunnelInformation;
62

A
Tweaks  
Alex Dima 已提交
63 64 65 66 67 68 69
	export class RemoteAuthorityResolverError extends Error {
		static NotAvailable(message?: string, handled?: boolean): RemoteAuthorityResolverError;
		static TemporarilyNotAvailable(message?: string): RemoteAuthorityResolverError;

		constructor(message?: string);
	}

A
Alex Dima 已提交
70
	export interface RemoteAuthorityResolver {
71
		resolve(authority: string, context: RemoteAuthorityResolverContext): ResolverResult | Thenable<ResolverResult>;
72 73 74 75 76
		/**
		 * Can be optionally implemented if the extension can forward ports better than the core.
		 * When not implemented, the core will use its default forwarding logic.
		 * When implemented, the core will use this to forward ports.
		 */
77
		forwardPort?(tunnelOptions: TunnelOptions): Thenable<Tunnel> | undefined;
78 79 80 81
	}

	export namespace workspace {
		/**
A
Alex Ross 已提交
82
		 * Forwards a port. Currently only works for a remote host of localhost.
83 84 85
		 * @param forward The `localPort` is a suggestion only. If that port is not available another will be chosen.
		 */
		export function makeTunnel(forward: TunnelOptions): Thenable<Tunnel>;
A
Alex Dima 已提交
86 87
	}

88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
	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 已提交
103 104
	export namespace workspace {
		export function registerRemoteAuthorityResolver(authorityPrefix: string, resolver: RemoteAuthorityResolver): Disposable;
105
		export function registerResourceLabelFormatter(formatter: ResourceLabelFormatter): Disposable;
106
	}
107

108 109
	//#endregion

A
Alexandru Dima 已提交
110
	//#region Semantic tokens: https://github.com/microsoft/vscode/issues/86415
A
WIP  
Alexandru Dima 已提交
111

112
	export class SemanticTokensLegend {
A
WIP  
Alexandru Dima 已提交
113 114 115 116 117 118
		public readonly tokenTypes: string[];
		public readonly tokenModifiers: string[];

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

119 120 121 122 123 124 125
	export class SemanticTokensBuilder {
		constructor();
		push(line: number, char: number, length: number, tokenType: number, tokenModifiers: number): void;
		build(): Uint32Array;
	}

	export class SemanticTokens {
A
Alexandru Dima 已提交
126 127 128 129 130 131
		/**
		 * The result id of the tokens.
		 *
		 * On a next call to `provideSemanticTokens`, if VS Code still holds in memory this result,
		 * the result id will be passed in as `SemanticTokensRequestOptions.previousResultId`.
		 */
132 133 134 135 136 137 138
		readonly resultId?: string;
		readonly data: Uint32Array;

		constructor(data: Uint32Array, resultId?: string);
	}

	export class SemanticTokensEdits {
A
Alexandru Dima 已提交
139 140 141 142 143 144
		/**
		 * The result id of the tokens.
		 *
		 * On a next call to `provideSemanticTokens`, if VS Code still holds in memory this result,
		 * the result id will be passed in as `SemanticTokensRequestOptions.previousResultId`.
		 */
145 146
		readonly resultId?: string;
		readonly edits: SemanticTokensEdit[];
A
WIP  
Alexandru Dima 已提交
147

148
		constructor(edits: SemanticTokensEdit[], resultId?: string);
A
WIP  
Alexandru Dima 已提交
149 150
	}

151 152 153 154
	export class SemanticTokensEdit {
		readonly start: number;
		readonly deleteCount: number;
		readonly data?: Uint32Array;
A
WIP  
Alexandru Dima 已提交
155

156 157 158 159 160
		constructor(start: number, deleteCount: number, data?: Uint32Array);
	}

	export interface SemanticTokensRequestOptions {
		readonly ranges?: readonly Range[];
A
Alexandru Dima 已提交
161 162 163 164 165
		/**
		 * The previous result id that the editor still holds in memory.
		 *
		 * Only when this is set it is safe for a `SemanticTokensProvider` to return `SemanticTokensEdits`.
		 */
166
		readonly previousResultId?: string;
A
WIP  
Alexandru Dima 已提交
167 168 169
	}

	/**
170 171
	 * The semantic tokens provider interface defines the contract between extensions and
	 * semantic tokens.
A
WIP  
Alexandru Dima 已提交
172
	 */
173
	export interface SemanticTokensProvider {
A
Alex Dima 已提交
174
		/**
A
Alexandru Dima 已提交
175 176 177 178 179
		 * A file can contain many tokens, perhaps even hundreds of thousands of tokens. Therefore, to improve
		 * the memory consumption around describing semantic tokens, we have decided to avoid allocating an object
		 * for each token and we represent tokens from a file as an array of integers. Furthermore, the position
		 * of each token is expressed relative to the token before it because most tokens remain stable relative to
		 * each other when edits are made in a file.
A
Alex Dima 已提交
180 181
		 *
		 *
A
Alexandru Dima 已提交
182 183
		 * ---
		 * In short, each token takes 5 integers to represent, so a specific token `i` in the file consists of the following fields:
A
Alex Dima 已提交
184 185 186 187 188 189 190
		 *  - at index `5*i`   - `deltaLine`: token line number, relative to the previous token
		 *  - at index `5*i+1` - `deltaStart`: token start character, relative to the previous token (relative to 0 or the previous token's start if they are on the same line)
		 *  - at index `5*i+2` - `length`: the length of the token. A token cannot be multiline.
		 *  - at index `5*i+3` - `tokenType`: will be looked up in `SemanticTokensLegend.tokenTypes`
		 *  - at index `5*i+4` - `tokenModifiers`: each set bit will be looked up in `SemanticTokensLegend.tokenModifiers`
		 *
		 *
A
Alexandru Dima 已提交
191 192 193 194
		 *
		 * ---
		 * ### How to encode tokens
		 *
A
Alex Dima 已提交
195 196
		 * Here is an example for encoding a file with 3 tokens:
		 * ```
A
Alexandru Dima 已提交
197
		 *    { line: 2, startChar:  5, length: 3, tokenType: "properties", tokenModifiers: ["private", "static"] },
A
Alex Dima 已提交
198
		 *    { line: 2, startChar: 10, length: 4, tokenType: "types",      tokenModifiers: [] },
A
Alexandru Dima 已提交
199
		 *    { line: 5, startChar:  2, length: 7, tokenType: "classes",    tokenModifiers: [] }
A
Alex Dima 已提交
200 201 202
		 * ```
		 *
		 * 1. First of all, a legend must be devised. This legend must be provided up-front and capture all possible token types.
A
Alexandru Dima 已提交
203
		 * For this example, we will choose the following legend which must be passed in when registering the provider:
A
Alex Dima 已提交
204
		 * ```
A
Alexandru Dima 已提交
205 206
		 *    tokenTypes: ['properties', 'types', 'classes'],
		 *    tokenModifiers: ['private', 'static']
A
Alex Dima 已提交
207 208
		 * ```
		 *
A
Alexandru Dima 已提交
209
		 * 2. The first transformation step is to encode `tokenType` and `tokenModifiers` as integers using the legend. Token types are looked
210
		 * up by index, so a `tokenType` value of `1` means `tokenTypes[1]`. Multiple token modifiers can be set by using bit flags,
A
Alexandru Dima 已提交
211 212
		 * so a `tokenModifier` value of `3` is first viewed as binary `0b00000011`, which means `[tokenModifiers[0], tokenModifiers[1]]` because
		 * bits 0 and 1 are set. Using this legend, the tokens now are:
A
Alex Dima 已提交
213
		 * ```
A
Alexandru Dima 已提交
214 215 216
		 *    { line: 2, startChar:  5, length: 3, tokenType: 0, tokenModifiers: 3 },
		 *    { line: 2, startChar: 10, length: 4, tokenType: 1, tokenModifiers: 0 },
		 *    { line: 5, startChar:  2, length: 7, tokenType: 2, tokenModifiers: 0 }
A
Alex Dima 已提交
217 218
		 * ```
		 *
A
Alexandru Dima 已提交
219 220 221 222
		 * 3. The next steps is to encode each token relative to the previous token in the file. In this case, the second token
		 * is on the same line as the first token, so the `startChar` of the second token is made relative to the `startChar`
		 * of the first token, so it will be `10 - 5`. The third token is on a different line than the second token, so the
		 * `startChar` of the third token will not be altered:
A
Alex Dima 已提交
223
		 * ```
A
Alexandru Dima 已提交
224 225 226
		 *    { deltaLine: 2, deltaStartChar: 5, length: 3, tokenType: 0, tokenModifiers: 3 },
		 *    { deltaLine: 0, deltaStartChar: 5, length: 4, tokenType: 1, tokenModifiers: 0 },
		 *    { deltaLine: 3, deltaStartChar: 2, length: 7, tokenType: 2, tokenModifiers: 0 }
A
Alex Dima 已提交
227 228
		 * ```
		 *
A
Alexandru Dima 已提交
229
		 * 4. Finally, the last step is to inline each of the 5 fields for a token in a single array, which is a memory friendly representation:
A
Alex Dima 已提交
230 231
		 * ```
		 *    // 1st token,  2nd token,  3rd token
A
Alexandru Dima 已提交
232
		 *    [  2,5,3,0,3,  0,5,4,1,0,  3,2,7,2,0 ]
A
Alex Dima 已提交
233 234 235 236
		 * ```
		 *
		 *
		 *
A
Alexandru Dima 已提交
237 238 239 240 241 242 243
		 * ---
		 * ### How tokens change when the document changes
		 *
		 * Let's look at how tokens might change.
		 *
		 * Continuing with the above example, suppose a new line was inserted at the top of the file.
		 * That would make all the tokens move down by one line (notice how the line has changed for each one):
A
Alex Dima 已提交
244
		 * ```
A
Alexandru Dima 已提交
245
		 *    { line: 3, startChar:  5, length: 3, tokenType: "properties", tokenModifiers: ["private", "static"] },
A
Alex Dima 已提交
246
		 *    { line: 3, startChar: 10, length: 4, tokenType: "types",      tokenModifiers: [] },
A
Alexandru Dima 已提交
247
		 *    { line: 6, startChar:  2, length: 7, tokenType: "classes",    tokenModifiers: [] }
A
Alex Dima 已提交
248
		 * ```
A
Alexandru Dima 已提交
249
		 * The integer encoding of the tokens does not change substantially because of the delta-encoding of positions:
A
Alex Dima 已提交
250
		 * ```
A
Alexandru Dima 已提交
251 252
		 *    // 1st token,  2nd token,  3rd token
		 *    [  3,5,3,0,3,  0,5,4,1,0,  3,2,7,2,0 ]
A
Alex Dima 已提交
253
		 * ```
A
Alexandru Dima 已提交
254 255 256 257
		 * It is possible to express these new tokens in terms of an edit applied to the previous tokens:
		 * ```
		 *    [  2,5,3,0,3,  0,5,4,1,0,  3,2,7,2,0 ]
		 *    [  3,5,3,0,3,  0,5,4,1,0,  3,2,7,2,0 ]
A
Alex Dima 已提交
258
		 *
A
Alexandru Dima 已提交
259 260
		 *    edit: { start:  0, deleteCount: 1, data: [3] } // replace integer at offset 0 with 3
		 * ```
A
Alexandru Dima 已提交
261
		 *
A
Alexandru Dima 已提交
262 263 264 265 266 267 268 269
		 * Furthermore, let's assume that a new token has appeared on line 4:
		 * ```
		 *    { line: 3, startChar:  5, length: 3, tokenType: "properties", tokenModifiers: ["private", "static"] },
		 *    { line: 3, startChar: 10, length: 4, tokenType: "types",      tokenModifiers: [] },
		 *    { line: 4, startChar:  3, length: 5, tokenType: "properties", tokenModifiers: ["static"] },
		 *    { line: 6, startChar:  2, length: 7, tokenType: "classes",    tokenModifiers: [] }
		 * ```
		 * The integer encoding of the tokens is:
A
Alex Dima 已提交
270
		 * ```
A
Alexandru Dima 已提交
271 272
		 *    // 1st token,  2nd token,  3rd token,  4th token
		 *    [  3,5,3,0,3,  0,5,4,1,0,  1,3,5,0,2,  2,2,7,2,0, ]
A
Alex Dima 已提交
273
		 * ```
A
Alexandru Dima 已提交
274
		 * Again, it is possible to express these new tokens in terms of an edit applied to the previous tokens:
A
Alex Dima 已提交
275
		 * ```
A
Alexandru Dima 已提交
276 277 278 279
		 *    [  3,5,3,0,3,  0,5,4,1,0,  3,2,7,2,0 ]
		 *    [  3,5,3,0,3,  0,5,4,1,0,  1,3,5,0,2,  2,2,7,2,0, ]
		 *
		 *    edit: { start: 10, deleteCount: 1, data: [1,3,5,0,2,2] } // replace integer at offset 10 with [1,3,5,0,2,2]
A
Alex Dima 已提交
280
		 * ```
A
Alexandru Dima 已提交
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
		 *
		 *
		 *
		 * ---
		 * ### When to return `SemanticTokensEdits`
		 *
		 * When doing edits, it is possible that multiple edits occur until VS Code decides to invoke the semantic tokens provider.
		 * In principle, each call to `provideSemanticTokens` can return a full representations of the semantic tokens, and that would
		 * be a perfectly reasonable semantic tokens provider implementation.
		 *
		 * However, when having a language server running in a separate process, transferring all the tokens between processes
		 * might be slow, so VS Code allows to return the new tokens expressed in terms of multiple edits applied to the previous
		 * tokens.
		 *
		 * To clearly define what "previous tokens" means, it is possible to return a `resultId` with the semantic tokens. If the
		 * editor still has in memory the previous result, the editor will pass in options the previous `resultId` at
		 * `SemanticTokensRequestOptions.previousResultId`. Only when the editor passes in the previous `resultId`, it is allowed
		 * that a semantic tokens provider returns the new tokens expressed as edits to be applied to the previous result. Even in this
		 * case, the semantic tokens provider needs to return a new `resultId` that will identify these new tokens as a basis
		 * for the next request.
		 *
		 * *NOTE 1*: It is illegal to return `SemanticTokensEdits` if `options.previousResultId` is not set.
		 * *NOTE 2*: All edits in `SemanticTokensEdits` contain indices in the old integers array, so they all refer to the previous result state.
A
Alex Dima 已提交
304
		 */
305
		provideSemanticTokens(document: TextDocument, options: SemanticTokensRequestOptions, token: CancellationToken): ProviderResult<SemanticTokens | SemanticTokensEdits>;
A
WIP  
Alexandru Dima 已提交
306 307 308 309
	}

	export namespace languages {
		/**
310
		 * Register a semantic tokens provider.
A
WIP  
Alexandru Dima 已提交
311 312 313 314 315 316
		 *
		 * 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.
317
		 * @param provider A semantic tokens provider.
A
WIP  
Alexandru Dima 已提交
318 319
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
		 */
320
		export function registerSemanticTokensProvider(selector: DocumentSelector, provider: SemanticTokensProvider, legend: SemanticTokensLegend): Disposable;
A
WIP  
Alexandru Dima 已提交
321 322 323
	}

	//#endregion
324

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

327 328
	export interface WebviewEditorInset {
		readonly editor: TextEditor;
329 330
		readonly line: number;
		readonly height: number;
331 332 333
		readonly webview: Webview;
		readonly onDidDispose: Event<void>;
		dispose(): void;
334 335
	}

336
	export namespace window {
337
		export function createWebviewTextEditorInset(editor: TextEditor, line: number, height: number, options?: WebviewOptions): WebviewEditorInset;
A
Alex Dima 已提交
338 339 340 341
	}

	//#endregion

J
Johannes Rieken 已提交
342
	//#region read/write in chunks: https://github.com/microsoft/vscode/issues/84515
343 344

	export interface FileSystemProvider {
J
Johannes Rieken 已提交
345
		open?(resource: Uri, options: { create: boolean }): number | Thenable<number>;
346 347 348 349 350 351 352
		close?(fd: number): void | Thenable<void>;
		read?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): number | Thenable<number>;
		write?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): number | Thenable<number>;
	}

	//#endregion

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

355 356 357
	/**
	 * The parameters of a query for text search.
	 */
358
	export interface TextSearchQuery {
359 360 361
		/**
		 * The text pattern to search for.
		 */
362
		pattern: string;
363

R
Rob Lourens 已提交
364 365 366 367 368
		/**
		 * Whether or not `pattern` should match multiple lines of text.
		 */
		isMultiline?: boolean;

369 370 371
		/**
		 * Whether or not `pattern` should be interpreted as a regular expression.
		 */
R
Rob Lourens 已提交
372
		isRegExp?: boolean;
373 374 375 376

		/**
		 * Whether or not the search should be case-sensitive.
		 */
R
Rob Lourens 已提交
377
		isCaseSensitive?: boolean;
378 379 380 381

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

385 386 387 388 389 390 391 392 393 394
	/**
	 * 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 已提交
395
	export interface SearchOptions {
396 397 398
		/**
		 * The root folder to search within.
		 */
399
		folder: Uri;
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414

		/**
		 * 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 已提交
415
		useIgnoreFiles: boolean;
416 417 418 419 420

		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
421
		followSymlinks: boolean;
P
pkoushik 已提交
422 423 424 425 426 427

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

R
Rob Lourens 已提交
430 431
	/**
	 * Options to specify the size of the result text preview.
R
Rob Lourens 已提交
432
	 * These options don't affect the size of the match itself, just the amount of preview text.
R
Rob Lourens 已提交
433
	 */
434
	export interface TextSearchPreviewOptions {
435
		/**
R
Rob Lourens 已提交
436
		 * The maximum number of lines in the preview.
R
Rob Lourens 已提交
437
		 * Only search providers that support multiline search will ever return more than one line in the match.
438
		 */
R
Rob Lourens 已提交
439
		matchLines: number;
R
Rob Lourens 已提交
440 441 442 443

		/**
		 * The maximum number of characters included per line.
		 */
R
Rob Lourens 已提交
444
		charsPerLine: number;
445 446
	}

447 448 449
	/**
	 * Options that apply to text search.
	 */
R
Rob Lourens 已提交
450
	export interface TextSearchOptions extends SearchOptions {
451
		/**
452
		 * The maximum number of results to be returned.
453
		 */
454 455
		maxResults: number;

R
Rob Lourens 已提交
456 457 458
		/**
		 * Options to specify the size of the result text preview.
		 */
459
		previewOptions?: TextSearchPreviewOptions;
460 461 462 463

		/**
		 * Exclude files larger than `maxFileSize` in bytes.
		 */
464
		maxFileSize?: number;
465 466 467 468 469

		/**
		 * Interpret files using this encoding.
		 * See the vscode setting `"files.encoding"`
		 */
470
		encoding?: string;
471 472 473 474 475 476 477 478 479 480

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

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

483 484 485 486 487 488 489 490 491 492 493 494 495 496
	/**
	 * Information collected when text search is complete.
	 */
	export interface TextSearchComplete {
		/**
		 * Whether the search hit the limit on the maximum number of search results.
		 * `maxResults` on [`TextSearchOptions`](#TextSearchOptions) specifies the max number of results.
		 * - If exactly that number of matches exist, this should be false.
		 * - If `maxResults` matches are returned and more exist, this should be true.
		 * - If search hits an internal limit which is less than `maxResults`, this should be true.
		 */
		limitHit?: boolean;
	}

R
Rob Lourens 已提交
497 498 499
	/**
	 * A preview of the text result.
	 */
500
	export interface TextSearchMatchPreview {
501
		/**
R
Rob Lourens 已提交
502
		 * The matching lines of text, or a portion of the matching line that contains the match.
503 504 505 506 507
		 */
		text: string;

		/**
		 * The Range within `text` corresponding to the text of the match.
508
		 * The number of matches must match the TextSearchMatch's range property.
509
		 */
510
		matches: Range | Range[];
511 512 513 514 515
	}

	/**
	 * A match from a text search
	 */
516
	export interface TextSearchMatch {
517 518 519
		/**
		 * The uri for the matching document.
		 */
520
		uri: Uri;
521 522

		/**
523
		 * The range of the match within the document, or multiple ranges for multiple matches.
524
		 */
525
		ranges: Range | Range[];
R
Rob Lourens 已提交
526

527
		/**
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549
		 * 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.
550
		 */
551
		lineNumber: number;
552 553
	}

554 555
	export type TextSearchResult = TextSearchMatch | TextSearchContext;

R
Rob Lourens 已提交
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599
	/**
	 * A TextSearchProvider provides search results for text results inside files in the workspace.
	 */
	export interface TextSearchProvider {
		/**
		 * Provide results that match the given text pattern.
		 * @param query The parameters for this query.
		 * @param options A set of options to consider while searching.
		 * @param progress A progress callback that must be invoked for all results.
		 * @param token A cancellation token.
		 */
		provideTextSearchResults(query: TextSearchQuery, options: TextSearchOptions, progress: Progress<TextSearchResult>, token: CancellationToken): ProviderResult<TextSearchComplete>;
	}

	//#endregion

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

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

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

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

600
	/**
R
Rob Lourens 已提交
601 602 603 604 605 606 607
	 * 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.
608
	 */
609
	export interface FileSearchProvider {
610 611 612 613 614 615
		/**
		 * 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.
		 */
616
		provideFileSearchResults(query: FileSearchQuery, options: FileSearchOptions, token: CancellationToken): ProviderResult<Uri[]>;
617
	}
618

R
Rob Lourens 已提交
619
	export namespace workspace {
620
		/**
R
Rob Lourens 已提交
621 622 623 624 625 626 627
		 * 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.
628
		 */
R
Rob Lourens 已提交
629 630 631 632 633 634 635 636 637 638 639 640
		export function registerFileSearchProvider(scheme: string, provider: FileSearchProvider): Disposable;

		/**
		 * Register a text search provider.
		 *
		 * Only one provider can be registered per scheme.
		 *
		 * @param scheme The provider will be invoked for workspace folders that have this file scheme.
		 * @param provider The provider.
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
		 */
		export function registerTextSearchProvider(scheme: string, provider: TextSearchProvider): Disposable;
641 642
	}

R
Rob Lourens 已提交
643 644 645 646
	//#endregion

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

647 648 649
	/**
	 * Options that can be set on a findTextInFiles search.
	 */
R
Rob Lourens 已提交
650
	export interface FindTextInFilesOptions {
651 652 653 654 655
		/**
		 * 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).
		 */
656
		include?: GlobPattern;
657 658 659 660 661 662 663 664 665 666 667

		/**
		 * 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 已提交
668
		maxResults?: number;
669 670 671 672 673

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

P
pkoushik 已提交
676 677 678 679
		/**
		 * Whether global files that exclude files, like .gitignore, should be respected.
		 * See the vscode setting `"search.useGlobalIgnoreFiles"`.
		 */
680
		useGlobalIgnoreFiles?: boolean;
P
pkoushik 已提交
681

682 683 684 685
		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
686
		followSymlinks?: boolean;
687 688 689 690 691

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

R
Rob Lourens 已提交
694 695 696
		/**
		 * Options to specify the size of the result text preview.
		 */
697
		previewOptions?: TextSearchPreviewOptions;
698 699 700 701 702 703 704 705 706 707

		/**
		 * 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 已提交
708 709
	}

710
	export namespace workspace {
711 712 713 714 715 716 717
		/**
		 * 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.
		 */
718
		export function findTextInFiles(query: TextSearchQuery, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
719 720 721 722 723 724 725 726 727

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

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

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

J
Joao Moreno 已提交
735 736 737
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
738 739 740 741 742 743 744
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762
	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;
	}
763

J
Johannes Rieken 已提交
764 765
	//#endregion

J
Johannes Rieken 已提交
766
	//#region file-decorations: https://github.com/microsoft/vscode/issues/54938
767

768
	export class Decoration {
769
		letter?: string;
770 771 772
		title?: string;
		color?: ThemeColor;
		priority?: number;
773
		bubble?: boolean;
774 775
	}

776
	export interface DecorationProvider {
777
		onDidChangeDecorations: Event<undefined | Uri | Uri[]>;
778
		provideDecoration(uri: Uri, token: CancellationToken): ProviderResult<Decoration>;
779 780 781
	}

	export namespace window {
782
		export function registerDecorationProvider(provider: DecorationProvider): Disposable;
783 784 785
	}

	//#endregion
786

787
	//#region André: debug API for inline debug adapters https://github.com/microsoft/vscode/issues/85544
J
Johannes Rieken 已提交
788

789 790 791
	/**
	 * A DebugProtocolMessage is an opaque stand-in type for the [ProtocolMessage](https://microsoft.github.io/debug-adapter-protocol/specification#Base_Protocol_ProtocolMessage) type defined in the Debug Adapter Protocol.
	 */
A
Andre Weinand 已提交
792
	export interface DebugProtocolMessage {
793 794 795 796
		// Properties: see details [here](https://microsoft.github.io/debug-adapter-protocol/specification#Base_Protocol_ProtocolMessage).
	}

	/**
797
	 * A debug adapter that implements the Debug Adapter Protocol can be registered with VS Code if it implements the DebugAdapter interface.
798
	 */
799
	export interface DebugAdapter extends Disposable {
800

801
		/**
802
		 * An event which fires after the debug adapter has sent a Debug Adapter Protocol message to VS Code.
803 804
		 * Messages can be requests, responses, or events.
		 */
805
		readonly onDidSendMessage: Event<DebugProtocolMessage>;
806

807 808 809 810 811 812
		/**
		 * Handle a Debug Adapter Protocol message.
		 * Messages can be requests, responses, or events.
		 * Results or errors are returned via onSendMessage events.
		 * @param message A Debug Adapter Protocol message
		 */
813 814 815 816 817 818 819 820 821 822 823 824 825 826
		handleMessage(message: DebugProtocolMessage): void;
	}

	/**
	 * A debug adapter descriptor for an inline implementation.
	 */
	export class DebugAdapterInlineImplementation {

		/**
		 * Create a descriptor for an inline implementation of a debug adapter.
		 */
		constructor(implementation: DebugAdapter);
	}

A
Andre Weinand 已提交
827 828
	// deprecated

829
	export interface DebugConfigurationProvider {
830
		/**
A
Andre Weinand 已提交
831 832
		 * Deprecated, use DebugAdapterDescriptorFactory.provideDebugAdapter instead.
		 * @deprecated Use DebugAdapterDescriptorFactory.createDebugAdapterDescriptor instead
833 834
		 */
		debugAdapterExecutable?(folder: WorkspaceFolder | undefined, token?: CancellationToken): ProviderResult<DebugAdapterExecutable>;
835 836
	}

J
Johannes Rieken 已提交
837 838
	//#endregion

R
Rob Lourens 已提交
839
	//#region LogLevel: https://github.com/microsoft/vscode/issues/85992
J
Johannes Rieken 已提交
840

841 842 843 844 845 846 847 848 849 850 851 852 853
	/**
	 * 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 已提交
854 855 856 857 858
	export namespace env {
		/**
		 * Current logging level.
		 */
		export const logLevel: LogLevel;
859 860 861 862 863

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

J
Johannes Rieken 已提交
866 867 868
	//#endregion

	//#region Joao: SCM validation
869

J
Joao Moreno 已提交
870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914
	/**
	 * 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 已提交
915

J
Johannes Rieken 已提交
916 917
	//#endregion

918 919 920 921 922 923 924 925 926 927 928 929 930
	//#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>;
931 932 933 934
	}

	//#endregion

935 936 937 938 939 940 941 942
	//#region Joao: SCM Input Box

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

		/**
J
Joao Moreno 已提交
943 944
			* Controls whether the input box is visible (default is `true`).
			*/
945 946 947 948 949
		visible: boolean;
	}

	//#endregion

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

952 953 954 955 956 957 958 959 960 961 962
	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 已提交
963 964 965 966 967 968 969 970 971 972 973 974 975
	namespace window {
		/**
		 * 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>;
	}

	//#endregion

	//#region Terminal exit status https://github.com/microsoft/vscode/issues/62103

D
Daniel Imms 已提交
976 977 978 979 980 981 982 983 984 985 986
	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;
	}

D
Daniel Imms 已提交
987
	export interface Terminal {
988
		/**
D
Daniel Imms 已提交
989 990 991 992 993 994 995 996 997 998 999
		 * 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}`);
		 *   }
		 * });
		 * ```
1000
		 */
D
Daniel Imms 已提交
1001
		readonly exitStatus: TerminalExitStatus | undefined;
1002 1003
	}

D
Daniel Imms 已提交
1004 1005 1006 1007
	//#endregion

	//#region Terminal creation options https://github.com/microsoft/vscode/issues/63052

D
Daniel Imms 已提交
1008
	export interface Terminal {
1009 1010 1011 1012 1013 1014
		/**
		 * 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>;
D
Daniel Imms 已提交
1015 1016
	}

J
Johannes Rieken 已提交
1017
	//#endregion
D
Daniel Imms 已提交
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033

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

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

D
Daniel Imms 已提交
1035 1036 1037 1038 1039 1040 1041 1042
	namespace window {
		/**
		 * An event which fires when the [dimensions](#Terminal.dimensions) of the terminal change.
		 */
		export const onDidChangeTerminalDimensions: Event<TerminalDimensionsChangeEvent>;
	}

	export interface Terminal {
1043
		/**
1044 1045 1046
		 * 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.
1047
		 */
1048
		readonly dimensions: TerminalDimensions | undefined;
D
Daniel Imms 已提交
1049 1050
	}

1051 1052
	//#endregion

1053 1054 1055 1056 1057 1058 1059
	//#region Joh -> exclusive document filters

	export interface DocumentFilter {
		exclusive?: boolean;
	}

	//#endregion
C
Christof Marti 已提交
1060

1061 1062 1063 1064 1065 1066 1067 1068
	//#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
1069

1070
	//#region Tree View: https://github.com/microsoft/vscode/issues/61313
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081
	/**
	 * Label describing the [Tree item](#TreeItem)
	 */
	export interface TreeItemLabel {

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

		/**
S
Sandeep Somavarapu 已提交
1082
		 * Ranges in the label to highlight. A range is defined as a tuple of two number where the
S
Sandeep Somavarapu 已提交
1083
		 * first is the inclusive start index and the second the exclusive end index
1084
		 */
S
Sandeep Somavarapu 已提交
1085
		highlights?: [number, number][];
1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100

	}

	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);
	}
1101
	//#endregion
1102

1103
	//#region CustomExecution: https://github.com/microsoft/vscode/issues/81007
1104 1105 1106
	/**
	 * A task to execute
	 */
G
Gabriel DeBacker 已提交
1107
	export class Task2 extends Task {
1108
		detail?: string;
1109
	}
G
Gabriel DeBacker 已提交
1110

1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121
	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>);
	}
1122
	//#endregion
1123

1124
	//#region Task presentation group: https://github.com/microsoft/vscode/issues/47265
1125 1126 1127 1128 1129 1130 1131
	export interface TaskPresentationOptions {
		/**
		 * Controls whether the task is executed in a specific terminal group using split panes.
		 */
		group?: string;
	}
	//#endregion
1132

1133
	//#region Status bar item with ID and Name: https://github.com/microsoft/vscode/issues/74972
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179

	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
1180

J
Johannes Rieken 已提交
1181
	//#region Custom editors: https://github.com/microsoft/vscode/issues/77131
1182

M
Matt Bierner 已提交
1183 1184 1185
	/**
	 * Defines the editing functionality of a webview editor. This allows the webview editor to hook into standard
	 * editor events such as `undo` or `save`.
1186 1187
	 *
	 * @param EditType Type of edits. Edit objects must be json serializable.
M
Matt Bierner 已提交
1188
	 */
1189
	interface WebviewCustomEditorEditingDelegate<EditType> {
1190
		/**
1191
		 * Save a resource.
M
Matt Bierner 已提交
1192
		 *
1193
		 * @param resource Resource being saved.
M
Matt Bierner 已提交
1194 1195
		 *
		 * @return Thenable signaling that the save has completed.
1196
		 */
1197
		save(resource: Uri): Thenable<void>;
1198

1199
		/**
1200
		 * Save an existing resource at a new path.
1201 1202 1203
		 *
		 * @param resource Resource being saved.
		 * @param targetResource Location to save to.
1204 1205
		 *
		 * @return Thenable signaling that the save has completed.
1206 1207 1208
		 */
		saveAs(resource: Uri, targetResource: Uri): Thenable<void>;

M
Matt Bierner 已提交
1209
		/**
M
Matt Bierner 已提交
1210
		 * Event triggered by extensions to signal to VS Code that an edit has occurred.
M
Matt Bierner 已提交
1211
		 */
1212
		readonly onEdit: Event<{ readonly resource: Uri, readonly edit: EditType }>;
M
Matt Bierner 已提交
1213 1214

		/**
1215 1216
		 * Apply a set of edits.
		 *
1217
		 * Note that is not invoked when `onEdit` is called as `onEdit` implies also updating the view to reflect the edit.
1218
		 *
1219
		 * @param resource Resource being edited.
1220
		 * @param edit Array of edits. Sorted from oldest to most recent.
1221 1222
		 *
		 * @return Thenable signaling that the change has completed.
M
Matt Bierner 已提交
1223
		 */
1224
		applyEdits(resource: Uri, edits: readonly EditType[]): Thenable<void>;
1225 1226

		/**
1227
		 * Undo a set of edits.
1228
		 *
1229
		 * This is triggered when a user undoes an edit or when revert is called on a file.
1230
		 *
1231
		 * @param resource Resource being edited.
1232
		 * @param edit Array of edits. Sorted from most recent to oldest.
1233 1234
		 *
		 * @return Thenable signaling that the change has completed.
1235
		 */
1236
		undoEdits(resource: Uri, edits: readonly EditType[]): Thenable<void>;
1237
	}
1238

1239
	export interface WebviewCustomEditorProvider {
1240
		/**
M
Matt Bierner 已提交
1241 1242 1243 1244
		 * Resolve a webview editor for a given resource.
		 *
		 * To resolve a webview editor, a provider must fill in its initial html content and hook up all
		 * the event listeners it is interested it. The provider should also take ownership of the passed in `WebviewPanel`.
1245
		 *
1246
		 * @param resource Resource being resolved.
1247 1248
		 * @param webview Webview being resolved. The provider should take ownership of this webview.
		 *
1249
		 * @return Thenable indicating that the webview editor has been resolved.
1250
		 */
1251
		resolveWebviewEditor(
1252
			resource: Uri,
1253
			webview: WebviewPanel,
1254 1255 1256 1257 1258 1259 1260 1261 1262 1263
		): Thenable<void>;

		/**
		 * Controls the editing functionality of a webview editor. This allows the webview editor to hook into standard
		 * editor events such as `undo` or `save`.
		 *
		 * WebviewEditors that do not have `editingCapability` are considered to be readonly. Users can still interact
		 * with readonly editors, but these editors will not integrate with VS Code's standard editor functionality.
		 */
		readonly editingDelegate?: WebviewCustomEditorEditingDelegate<unknown>;
1264 1265 1266
	}

	namespace window {
M
Matt Bierner 已提交
1267 1268 1269 1270 1271 1272 1273
		/**
		 * Register a new provider for webview editors of a given type.
		 *
		 * @param viewType  Type of the webview editor provider.
		 * @param provider Resolves webview editors.
		 * @param options Content settings for a webview panels the provider is given.
		 *
1274
		 * @return Disposable that unregisters the `WebviewCustomEditorProvider`.
M
Matt Bierner 已提交
1275
		 */
1276
		export function registerWebviewCustomEditorProvider(
1277
			viewType: string,
1278
			provider: WebviewCustomEditorProvider,
1279
			options?: WebviewPanelOptions,
1280 1281 1282 1283
		): Disposable;
	}

	//#endregion
1284

J
Johannes Rieken 已提交
1285
	//#region insert/replace completions: https://github.com/microsoft/vscode/issues/10266
1286 1287

	export interface CompletionItem {
1288 1289

		/**
1290
		 * A range or a insert and replace range selecting the text that should be replaced by this completion item.
1291
		 *
1292 1293 1294
		 * 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.
1295
		 *
1296 1297 1298
		 * *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.
1299
		 */
1300
		range2?: Range | { inserting: Range; replacing: Range; };
1301 1302 1303
	}

	//#endregion
P
Peter Elmers 已提交
1304

J
Johannes Rieken 已提交
1305
	//#region allow QuickPicks to skip sorting: https://github.com/microsoft/vscode/issues/73904
P
Peter Elmers 已提交
1306 1307 1308 1309 1310 1311 1312 1313 1314

	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
M
Matt Bierner 已提交
1315

J
Johannes Rieken 已提交
1316
	//#region Surfacing reasons why a code action cannot be applied to users: https://github.com/microsoft/vscode/issues/85160
M
Matt Bierner 已提交
1317 1318 1319 1320 1321

	export interface CodeAction {
		/**
		 * Marks that the code action cannot currently be applied.
		 *
M
Matt Bierner 已提交
1322
		 * Disabled code actions will be surfaced in the refactor UI but cannot be applied.
M
Matt Bierner 已提交
1323
		 */
M
Matt Bierner 已提交
1324 1325 1326 1327 1328 1329 1330 1331
		disabled?: {
			/**
			 * Human readable description of why the code action is currently disabled.
			 *
			 * This is displayed in the UI.
			 */
			reason: string;
		};
M
Matt Bierner 已提交
1332 1333 1334
	}

	//#endregion
E
Eric Amodio 已提交
1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346

	//#region Allow theme icons in hovers: https://github.com/microsoft/vscode/issues/84695

	export interface MarkdownString {

		/**
		 * Indicates that this markdown string can contain [ThemeIcons](#ThemeIcon), e.g. `$(zap)`.
		 */
		readonly supportThemeIcons?: boolean;
	}

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