diff --git a/extensions/typescript-language-features/src/languageFeatures/mappedCodeEditProvider.ts b/extensions/typescript-language-features/src/languageFeatures/mappedCodeEditProvider.ts index 0d04d2dc808..06ce5557b6c 100644 --- a/extensions/typescript-language-features/src/languageFeatures/mappedCodeEditProvider.ts +++ b/extensions/typescript-language-features/src/languageFeatures/mappedCodeEditProvider.ts @@ -27,8 +27,8 @@ class TsMappedEditsProvider implements vscode.MappedEditsProvider { } const response = await this.client.execute('mapCode', { - mappings: [{ - file, + file, + mapping: { contents: codeBlocks, focusLocations: context.documents.map(documents => { return documents.flatMap((contextItem): FileSpan[] => { @@ -39,7 +39,7 @@ class TsMappedEditsProvider implements vscode.MappedEditsProvider { return contextItem.ranges.map((range): FileSpan => ({ file, ...Range.toTextSpan(range) })); }); }), - }], + } }, token); if (response.type !== 'response' || !response.body) { return; diff --git a/extensions/typescript-language-features/src/tsServer/protocol/protocol.d.ts b/extensions/typescript-language-features/src/tsServer/protocol/protocol.d.ts index 45e09d63481..aa9b0589d2d 100644 --- a/extensions/typescript-language-features/src/tsServer/protocol/protocol.d.ts +++ b/extensions/typescript-language-features/src/tsServer/protocol/protocol.d.ts @@ -20,42 +20,36 @@ declare module '../../../../node_modules/typescript/lib/typescript' { readonly _serverType?: ServerType; } - export interface MapCodeRequestArgs { - /// The files and changes to try and apply/map. - mappings: MapCodeRequestDocumentMapping[]; - - /// Edits to apply to the current workspace before performing the mapping. - updates?: FileCodeEdits[] + export interface MapCodeRequestArgs extends FileRequestArgs { + /** + * The files and changes to try and apply/map. + */ + mapping: MapCodeRequestDocumentMapping; } export interface MapCodeRequestDocumentMapping { - /// The file for the request (absolute pathname required). Null/undefined - /// if specific file is unknown. - file?: string; - - /// Optional name of project that contains file - projectFileName?: string; - - /// The specific code to map/insert/replace in the file. + /** + * The specific code to map/insert/replace in the file. + */ contents: string[]; - /// Areas of "focus" to inform the code mapper with. For example, cursor - /// location, current selection, viewport, etc. Nested arrays denote - /// priority: toplevel arrays are more important than inner arrays, and - /// inner array priorities are based on items within that array. Items - /// earlier in the arrays have higher priority. - focusLocations?: FileSpan[][]; + /** + * Areas of "focus" to inform the code mapper with. For example, cursor + * location, current selection, viewport, etc. Nested arrays denote + * priority: toplevel arrays are more important than inner arrays, and + * inner array priorities are based on items within that array. Items + * earlier in the arrays have higher priority. + */ + focusLocations?: TextSpan[][]; } - export interface MapCodeRequest extends Request { - command: 'mapCode', + export interface MapCodeRequest extends FileRequest { + command: 'mapCode'; arguments: MapCodeRequestArgs; } export interface MapCodeResponse extends Response { - body: FileCodeEdits[] + body: readonly FileCodeEdits[]; } } } - -