Only return single ts-ignore action if there are multiple errors on one line
Fixes #97867pull/98340/head
parent
990eb06cfe
commit
85a336c885
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue