提交 85a336c8 编写于 作者: M Matt Bierner

Only return single ts-ignore action if there are multiple errors on one line

Fixes #97867
上级 990eb06c
......@@ -17,6 +17,7 @@ import { TelemetryReporter } from '../utils/telemetry';
import * as typeConverters from '../utils/typeConverters';
import { DiagnosticsManager } from './diagnostics';
import FileConfigurationManager from './fileConfigurationManager';
import { equals } from '../utils/objects';
const localize = nls.loadMessageBundle();
......@@ -147,6 +148,11 @@ class CodeActionSet {
}
public addAction(action: VsCodeCodeAction) {
for (const existing of this._actions) {
if (action.tsAction.fixName === existing.tsAction.fixName && equals(action.edit, existing.edit)) {
this._actions.delete(existing);
}
}
this._actions.add(action);
}
......
......@@ -87,6 +87,23 @@ suite('TypeScript Quick Fix', () => {
`foo;`
));
});
test('Only a single ts-ignore should be returned if there are multiple errors on one line #98274', async () => {
const testDocumentUri = workspaceFile('foojs.js');
const editor = await createTestEditor(testDocumentUri,
`//@ts-check`,
`const a = require('./bla');`);
await wait(3000);
const fixes = await vscode.commands.executeCommand<vscode.CodeAction[]>('vscode.executeCodeActionProvider',
testDocumentUri,
editor.document.lineAt(1).range
);
const ignoreFixes = fixes?.filter(x => x.title === 'Ignore this error message');
assert.strictEqual(ignoreFixes?.length, 1);
});
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册