|
6 | 6 | import * as assert from 'assert';
|
7 | 7 | import { MarkerService } from 'vs/platform/markers/common/markerService';
|
8 | 8 | import { MainThreadDiagnostics } from 'vs/workbench/api/browser/mainThreadDiagnostics';
|
9 |
| -import { URI } from 'vs/base/common/uri'; |
| 9 | +import { URI, UriComponents } from 'vs/base/common/uri'; |
10 | 10 | import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
11 | 11 | import { mock } from 'vs/workbench/test/common/workbenchTestServices';
|
12 | 12 | import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
|
13 | 13 | import { ExtensionHostKind } from 'vs/workbench/services/extensions/common/extensions';
|
| 14 | +import { IMarkerData } from 'vs/platform/markers/common/markers'; |
| 15 | +import { runWithFakedTimers } from 'vs/base/test/common/timeTravelScheduler'; |
| 16 | +import { timeout } from 'vs/base/common/async'; |
14 | 17 |
|
15 | 18 |
|
16 | 19 | suite('MainThreadDiagnostics', function () {
|
@@ -57,4 +60,54 @@ suite('MainThreadDiagnostics', function () {
|
57 | 60 | diag.dispose();
|
58 | 61 | assert.strictEqual(markerService.read().length, 0);
|
59 | 62 | });
|
| 63 | + |
| 64 | + test('OnDidChangeDiagnostics triggers twice on same diagnostics #136434', function () { |
| 65 | + |
| 66 | + return runWithFakedTimers({}, async () => { |
| 67 | + |
| 68 | + const changedData: [UriComponents, IMarkerData[]][][] = []; |
| 69 | + |
| 70 | + let diag = new MainThreadDiagnostics( |
| 71 | + new class implements IExtHostContext { |
| 72 | + remoteAuthority = ''; |
| 73 | + extensionHostKind = ExtensionHostKind.LocalProcess; |
| 74 | + assertRegistered() { } |
| 75 | + set(v: any): any { return null; } |
| 76 | + getProxy(): any { |
| 77 | + return { |
| 78 | + $acceptMarkersChange(data: [UriComponents, IMarkerData[]][]) { |
| 79 | + changedData.push(data); |
| 80 | + } |
| 81 | + }; |
| 82 | + } |
| 83 | + drain(): any { return null; } |
| 84 | + }, |
| 85 | + markerService, |
| 86 | + new class extends mock<IUriIdentityService>() { |
| 87 | + override asCanonicalUri(uri: URI) { return uri; } |
| 88 | + } |
| 89 | + ); |
| 90 | + |
| 91 | + const markerDataStub = { |
| 92 | + code: '666', |
| 93 | + startLineNumber: 1, |
| 94 | + startColumn: 1, |
| 95 | + endLineNumber: 1, |
| 96 | + endColumn: 1, |
| 97 | + severity: 1, |
| 98 | + source: 'me' |
| 99 | + }; |
| 100 | + const target = URI.file('a'); |
| 101 | + diag.$changeMany('foo', [[target, [{ ...markerDataStub, message: 'same_owner' }]]]); |
| 102 | + markerService.changeOne('bar', target, [{ ...markerDataStub, message: 'forgein_owner' }]); |
| 103 | + |
| 104 | + // added one marker via the API and one via the ext host. the latter must not |
| 105 | + // trigger an event to the extension host |
| 106 | + |
| 107 | + await timeout(0); |
| 108 | + assert.strictEqual(markerService.read().length, 2); |
| 109 | + assert.strictEqual(changedData.length, 1); |
| 110 | + assert.strictEqual(changedData[0][0][1][0].message, 'forgein_owner'); |
| 111 | + }); |
| 112 | + }); |
60 | 113 | });
|
0 commit comments