Skip to content

Commit 6123290

Browse files
AllanWangDonJayamanne
authored andcommitted
Use namespace commands for refactor keys (microsoft#5166)
The constants for both refactor commands were not used. The string literal itself was referenced in the refactor provider, so I changed it to the command constant. I also fixed the typo in `refactor`
1 parent 6a12a25 commit 6123290

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

news/3 Code Health/5204.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix typo and use constants instead of hardcoded command names.
2+
(thanks [Allan Wang](https://github.com/AllanWang))

src/client/common/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export namespace Commands {
3838
export const Tests_Select_And_Run_File = 'python.selectAndRunTestFile';
3939
export const Tests_Run_Current_File = 'python.runCurrentTestFile';
4040
export const Refactor_Extract_Variable = 'python.refactorExtractVariable';
41-
export const Refaactor_Extract_Method = 'python.refactorExtractMethod';
41+
export const Refactor_Extract_Method = 'python.refactorExtractMethod';
4242
export const Update_SparkLibrary = 'python.updateSparkLibrary';
4343
export const Build_Workspace_Symbols = 'python.buildWorkspaceSymbols';
4444
export const Start_REPL = 'python.startREPL';

src/client/providers/simpleRefactorProvider.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as vscode from 'vscode';
2+
import { Commands } from '../common/constants';
23
import { getTextEditsFromPatch } from '../common/editor';
34
import { IConfigurationService, IInstaller, Product } from '../common/types';
45
import { StopWatch } from '../common/utils/stopWatch';
@@ -15,7 +16,7 @@ let installer: IInstaller;
1516

1617
export function activateSimplePythonRefactorProvider(context: vscode.ExtensionContext, outputChannel: vscode.OutputChannel, serviceContainer: IServiceContainer) {
1718
installer = serviceContainer.get<IInstaller>(IInstaller);
18-
let disposable = vscode.commands.registerCommand('python.refactorExtractVariable', () => {
19+
let disposable = vscode.commands.registerCommand(Commands.Refactor_Extract_Variable, () => {
1920
const stopWatch = new StopWatch();
2021
const promise = extractVariable(context.extensionPath,
2122
vscode.window.activeTextEditor!,
@@ -26,7 +27,7 @@ export function activateSimplePythonRefactorProvider(context: vscode.ExtensionCo
2627
});
2728
context.subscriptions.push(disposable);
2829

29-
disposable = vscode.commands.registerCommand('python.refactorExtractMethod', () => {
30+
disposable = vscode.commands.registerCommand(Commands.Refactor_Extract_Method, () => {
3031
const stopWatch = new StopWatch();
3132
const promise = extractMethod(context.extensionPath,
3233
vscode.window.activeTextEditor!,

0 commit comments

Comments
 (0)