Use object for refactor.disabled
For #85160 Using an object is more explict with property names and will let us introduce additional properties in the future if needed
This commit is contained in:
parent
ba2524065b
commit
a4177f50c4
|
@ -314,7 +314,9 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider {
|
|||
private appendInvalidActions(actions: vscode.CodeAction[]): vscode.CodeAction[] {
|
||||
if (!actions.some(action => action.kind && Extract_Constant.kind.contains(action.kind))) {
|
||||
const disabledAction = new vscode.CodeAction('Extract to constant', Extract_Constant.kind);
|
||||
disabledAction.disabled = localize('extract.disabled', "The current selection cannot be extracted");
|
||||
disabledAction.disabled = {
|
||||
reason: localize('extract.disabled', "The current selection cannot be extracted"),
|
||||
};
|
||||
disabledAction.isPreferred = true;
|
||||
actions.push(disabledAction);
|
||||
}
|
||||
|
|
12
src/vs/vscode.proposed.d.ts
vendored
12
src/vs/vscode.proposed.d.ts
vendored
|
@ -1331,10 +1331,16 @@ declare module 'vscode' {
|
|||
/**
|
||||
* Marks that the code action cannot currently be applied.
|
||||
*
|
||||
* This should be a human readable description of why the code action is currently disabled. Disabled code actions
|
||||
* will be surfaced in the refactor UI but cannot be applied.
|
||||
* Disabled code actions will be surfaced in the refactor UI but cannot be applied.
|
||||
*/
|
||||
disabled?: string;
|
||||
disabled?: {
|
||||
/**
|
||||
* Human readable description of why the code action is currently disabled.
|
||||
*
|
||||
* This is displayed in the UI.
|
||||
*/
|
||||
reason: string;
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
|
|
@ -389,7 +389,7 @@ class CodeActionAdapter {
|
|||
edit: candidate.edit && typeConvert.WorkspaceEdit.from(candidate.edit),
|
||||
kind: candidate.kind && candidate.kind.value,
|
||||
isPreferred: candidate.isPreferred,
|
||||
disabled: candidate.disabled
|
||||
disabled: candidate.disabled?.reason
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue