Mark extract constant as a preferred refactoring

https://github.com/Microsoft/TypeScript/issues/29587
This commit is contained in:
Matt Bierner
2019-01-25 16:17:38 -08:00
parent cd4a6cebe7
commit ccb5a625c2

View File

@@ -188,6 +188,7 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider {
command: ApplyRefactoringCommand.ID,
arguments: [document, file, info.name, action.name, rangeOrSelection],
};
codeAction.isPreferred = TypeScriptRefactorProvider.isPreferred(action);
return codeAction;
}
@@ -209,6 +210,15 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider {
}
return vscode.CodeActionKind.Refactor;
}
private static isPreferred(
action: Proto.RefactorActionInfo
): boolean {
if (action.name.startsWith('constant_')) {
return action.name.endsWith('scope_0');
}
return false;
}
}
export function register(