Make sure add all missing imports quick fix comes after individual add missing import quick fixes
Fixes #98613
This commit is contained in:
parent
89b16f2c7c
commit
5f8e6d0b19
|
@ -153,7 +153,17 @@ class CodeActionSet {
|
||||||
this._actions.delete(existing);
|
this._actions.delete(existing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._actions.add(action);
|
this._actions.add(action);
|
||||||
|
|
||||||
|
if (action.tsAction.fixId) {
|
||||||
|
// If we have an existing fix all action, then make sure it follows this action
|
||||||
|
const existingFixAll = this._fixAllActions.get(action.tsAction.fixId);
|
||||||
|
if (existingFixAll) {
|
||||||
|
this._actions.delete(existingFixAll);
|
||||||
|
this._actions.add(existingFixAll);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public addFixAllAction(fixId: {}, action: VsCodeCodeAction) {
|
public addFixAllAction(fixId: {}, action: VsCodeCodeAction) {
|
||||||
|
|
|
@ -122,6 +122,32 @@ suite('TypeScript Quick Fix', () => {
|
||||||
assert.strictEqual(fixes![0].title, `Implement interface 'IFoo'`);
|
assert.strictEqual(fixes![0].title, `Implement interface 'IFoo'`);
|
||||||
assert.strictEqual(fixes![1].title, `Remove unused declaration for: 'Foo'`);
|
assert.strictEqual(fixes![1].title, `Remove unused declaration for: 'Foo'`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Add all missing imports should come after other add import fixes #98613', async () => {
|
||||||
|
await createTestEditor(workspaceFile('foo.ts'),
|
||||||
|
`export const foo = 1;`);
|
||||||
|
|
||||||
|
await createTestEditor(workspaceFile('bar.ts'),
|
||||||
|
`export const foo = 1;`);
|
||||||
|
|
||||||
|
const editor = await createTestEditor(workspaceFile('index.ts'),
|
||||||
|
`export const _ = 1;`,
|
||||||
|
`foo$0;`,
|
||||||
|
`foo$0;`
|
||||||
|
);
|
||||||
|
|
||||||
|
await wait(3000);
|
||||||
|
|
||||||
|
const fixes = await vscode.commands.executeCommand<vscode.CodeAction[]>('vscode.executeCodeActionProvider',
|
||||||
|
workspaceFile('index.ts'),
|
||||||
|
editor.document.lineAt(1).range
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.strictEqual(fixes?.length, 3);
|
||||||
|
assert.strictEqual(fixes![0].title, `Import 'foo' from module "./bar"`);
|
||||||
|
assert.strictEqual(fixes![1].title, `Import 'foo' from module "./foo"`);
|
||||||
|
assert.strictEqual(fixes![2].title, `Add all missing imports`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue