Skip to content

Commit db6023f

Browse files
committed
Reorganize to avoid passing undefined selections
1 parent 57f1090 commit db6023f

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/features/codeActionProvider.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,29 @@ export default class CodeActionProvider extends AbstractProvider implements vsco
3232

3333
let line = range.start.line;
3434
let column = range.start.character;
35-
let selection: protocol.V2.Range | undefined;
35+
36+
let request: protocol.V2.GetCodeActionsRequest = {
37+
FileName: document.fileName,
38+
Line: line,
39+
Column: column,
40+
};
3641

3742
// Only suggest selection-based refactorings when a selection exists.
3843
// If there is no selection and the editor isn't focused,
3944
// VS Code will pass us an empty Selection rather than a Range,
4045
// hence the extra range.isEmpty check.
4146
if (range instanceof vscode.Selection && !range.isEmpty) {
42-
selection = {
47+
request.Selection = {
4348
Start: { Line: range.start.line, Column: range.start.character },
4449
End: { Line: range.end.line, Column: range.end.character }
4550
};
4651
}
4752

48-
let request: protocol.V2.GetCodeActionsRequest = {
49-
FileName: document.fileName,
50-
Line: line,
51-
Column: column,
52-
Selection: selection
53-
};
54-
5553
try {
5654
let response = await serverUtils.getCodeActions(this._server, request, token);
5755
return response.CodeActions.map(codeAction => {
5856
let runRequest: protocol.V2.RunCodeActionRequest = {
59-
FileName: document.fileName,
60-
Line: line,
61-
Column: column,
62-
Selection: selection,
57+
...request,
6358
Identifier: codeAction.Identifier,
6459
WantsTextChanges: true,
6560
WantsAllCodeActionOperations: true,

0 commit comments

Comments
 (0)