From 6e77c36c0c5419a0dc1da918556cd3afec91f299 Mon Sep 17 00:00:00 2001 From: Johnson Chu Date: Sun, 7 Apr 2024 20:04:03 +0800 Subject: [PATCH] feat(vscode): add `vue.codeActions.askNewComponentName` setting close #4217 --- extensions/vscode/package.json | 5 +++++ extensions/vscode/src/config.ts | 1 + extensions/vscode/src/middleware.ts | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index c1d48a371b..5664a2b064 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -313,6 +313,11 @@ "default": true, "description": "Enabled code actions." }, + "vue.codeActions.askNewComponentName": { + "type": "boolean", + "default": true, + "description": "Ask for new component name when extract component." + }, "vue.codeLens.enabled": { "type": "boolean", "default": true, diff --git a/extensions/vscode/src/config.ts b/extensions/vscode/src/config.ts index f2b5b6b132..5a2848c3fa 100644 --- a/extensions/vscode/src/config.ts +++ b/extensions/vscode/src/config.ts @@ -37,6 +37,7 @@ export const config = { }, get codeActions(): Readonly<{ enabled: boolean; + askNewComponentName: boolean; }> { return _config().get('codeActions')!; }, diff --git a/extensions/vscode/src/middleware.ts b/extensions/vscode/src/middleware.ts index 2ae213f6eb..00b75ff5ae 100644 --- a/extensions/vscode/src/middleware.ts +++ b/extensions/vscode/src/middleware.ts @@ -2,11 +2,12 @@ import { AttrNameCasing, TagNameCasing } from '@vue/language-server'; import * as vscode from 'vscode'; import * as lsp from '@volar/vscode'; import { attrNameCasings, tagNameCasings } from './features/nameCasing'; +import { config } from './config'; export const middleware: lsp.Middleware = { ...lsp.middleware, async resolveCodeAction(item, token, next) { - if (item.kind?.value === 'refactor.move.newFile.dumb') { + if (item.kind?.value === 'refactor.move.newFile.dumb' && config.codeActions.askNewComponentName) { const inputName = await vscode.window.showInputBox({ value: (item as any).data.original.data.newName }); if (!inputName) { return item; // cancel