Skip to content

Commit

Permalink
feat(vscode): add vue.codeActions.askNewComponentName setting
Browse files Browse the repository at this point in the history
close #4217
  • Loading branch information
johnsoncodehk committed Apr 7, 2024
1 parent ef1f4bb commit 6e77c36
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions extensions/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions extensions/vscode/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const config = {
},
get codeActions(): Readonly<{
enabled: boolean;
askNewComponentName: boolean;
}> {
return _config().get('codeActions')!;
},
Expand Down
3 changes: 2 additions & 1 deletion extensions/vscode/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6e77c36

Please sign in to comment.