Skip to content

Commit

Permalink
Use current selection instead of range for refactoring
Browse files Browse the repository at this point in the history
Fixes #34481
  • Loading branch information
mjbvz committed Nov 10, 2017
1 parent 82b13bc commit 006b379
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions extensions/typescript/src/features/refactorProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,25 @@ export default class TypeScriptRefactorProvider implements vscode.CodeActionProv

public async provideCodeActions2(
document: vscode.TextDocument,
range: vscode.Range,
_range: vscode.Range,
_context: vscode.CodeActionContext,
token: vscode.CancellationToken
): Promise<vscode.CodeAction[]> {
if (!this.client.apiVersion.has240Features()) {
return [];
}

if (!vscode.window.activeTextEditor) {
return [];
}

const editor = vscode.window.activeTextEditor;
const file = this.client.normalizePath(document.uri);
if (!file) {
if (!file || editor.document.uri.fsPath !== document.uri.fsPath) {
return [];
}

const range = editor.selection;
const args: Proto.GetApplicableRefactorsRequestArgs = vsRangeToTsFileRange(file, range);
try {
const response = await this.client.execute('getApplicableRefactors', args, token);
Expand Down Expand Up @@ -158,7 +164,7 @@ export default class TypeScriptRefactorProvider implements vscode.CodeActionProv
}
}
return actions;
} catch (err) {
} catch {
return [];
}
}
Expand Down

0 comments on commit 006b379

Please sign in to comment.