Fix organize import for empty file

Fixes #132637

We should not show the lightbulb when auto applying code actions
This commit is contained in:
Matt Bierner
2021-09-09 15:26:51 -07:00
parent e1cd33dda7
commit 74989b2993
2 changed files with 7 additions and 4 deletions

View File

@@ -29,7 +29,7 @@ class OrganizeImportsCommand implements Command {
private readonly telemetryReporter: TelemetryReporter,
) { }
public async execute(file: string, sortOnly = false): Promise<boolean> {
public async execute(file: string, sortOnly = false): Promise<any> {
/* __GDPR__
"organizeImports.execute" : {
"${include}": [
@@ -50,11 +50,13 @@ class OrganizeImportsCommand implements Command {
};
const response = await this.client.interruptGetErr(() => this.client.execute('organizeImports', args, nulToken));
if (response.type !== 'response' || !response.body) {
return false;
return;
}
const edits = typeConverters.WorkspaceEdit.fromFileCodeEdits(this.client, response.body);
return vscode.workspace.applyEdit(edits);
if (response.body.length) {
const edits = typeConverters.WorkspaceEdit.fromFileCodeEdits(this.client, response.body);
return vscode.workspace.applyEdit(edits);
}
}
}