From b4e834f6fde16eb7770e48fa5595b2c3e74b8f82 Mon Sep 17 00:00:00 2001 From: Ulugbek Abdullaev Date: Wed, 21 Feb 2024 12:44:54 +0100 Subject: [PATCH] Removed Copilot related code from TypeScript Refactor Provider --- .../src/languageFeatures/refactor.ts | 46 ++----------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/extensions/typescript-language-features/src/languageFeatures/refactor.ts b/extensions/typescript-language-features/src/languageFeatures/refactor.ts index bbc5aef39b7..a61758cc66d 100644 --- a/extensions/typescript-language-features/src/languageFeatures/refactor.ts +++ b/extensions/typescript-language-features/src/languageFeatures/refactor.ts @@ -21,7 +21,7 @@ import { ClientCapability, ITypeScriptServiceClient } from '../typescriptService import { coalesce } from '../utils/arrays'; import { nulToken } from '../utils/cancellation'; import FormattingOptionsManager from './fileConfigurationManager'; -import { CompositeCommand, EditorChatFollowUp, EditorChatFollowUp_Args } from './util/copilot'; +import { CompositeCommand, EditorChatFollowUp } from './util/copilot'; import { conditionalRegistration, requireSomeCapability } from './util/dependentRegistration'; function toWorkspaceEdit(client: ITypeScriptServiceClient, edits: readonly Proto.FileCodeEdits[]): vscode.WorkspaceEdit { @@ -347,14 +347,10 @@ class InlinedCodeAction extends vscode.CodeAction { public readonly refactor: Proto.ApplicableRefactorInfo, public readonly action: Proto.RefactorActionInfo, public readonly range: vscode.Range, - public readonly copilotRename?: (info: Proto.RefactorEditInfo) => vscode.Command, ) { - const title = copilotRename ? action.description + ' and suggest a name with Copilot.' : action.description; + const title = action.description; super(title, InlinedCodeAction.getKind(action)); - if (copilotRename) { - this.isAI = true; - } if (action.notApplicableReason) { this.disabled = { reason: action.notApplicableReason }; } @@ -392,15 +388,12 @@ class InlinedCodeAction extends vscode.CodeAction { if (response.body.renameLocation) { // Disable renames in interactive playground https://github.com/microsoft/vscode/issues/75137 if (this.document.uri.scheme !== fileSchemes.walkThroughSnippet) { - if (this.copilotRename && this.command) { - this.command.title = 'Copilot: ' + this.command.title; - } this.command = { command: CompositeCommand.ID, title: '', arguments: coalesce([ this.command, - this.copilotRename ? this.copilotRename(response.body) : { + { command: 'editor.action.rename', arguments: [[ this.document.uri, @@ -635,38 +628,7 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider vscode.Command) = info => ({ - title: '', - command: EditorChatFollowUp.ID, - arguments: [{ - message: `Rename ${newName} to a better name based on usage.`, - expand: Extract_Constant.matches(action) ? { - kind: 'navtree-function', - pos: typeConverters.Position.fromLocation(info.renameLocation!), - } : { - kind: 'refactor-info', - refactor: info, - }, - action: { type: 'refactor', refactor: action }, - document, - } satisfies EditorChatFollowUp_Args] - }); - codeActions.push(new InlinedCodeAction(this.client, document, refactor, action, rangeOrSelection, copilotRename)); - } - } + codeActions.push(new InlinedCodeAction(this.client, document, refactor, action, rangeOrSelection)); } for (const codeAction of codeActions) { codeAction.isPreferred = TypeScriptRefactorProvider.isPreferred(action, allActions);