Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/api/test/browser/extHostDocumentsAndEditors.test.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import assert from 'assert';
7
import { URI } from '../../../../base/common/uri.js';
8
import { ExtHostDocumentsAndEditors } from '../../common/extHostDocumentsAndEditors.js';
9
import { TestRPCProtocol } from '../common/testRPCProtocol.js';
10
import { NullLogService } from '../../../../platform/log/common/log.js';
11
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js';
12
13
suite('ExtHostDocumentsAndEditors', () => {
14
15
let editors: ExtHostDocumentsAndEditors;
16
17
setup(function () {
18
editors = new ExtHostDocumentsAndEditors(new TestRPCProtocol(), new NullLogService());
19
});
20
21
ensureNoDisposablesAreLeakedInTestSuite();
22
23
test('The value of TextDocument.isClosed is incorrect when a text document is closed, #27949', () => {
24
25
editors.$acceptDocumentsAndEditorsDelta({
26
addedDocuments: [{
27
EOL: '\n',
28
isDirty: true,
29
languageId: 'fooLang',
30
uri: URI.parse('foo:bar'),
31
versionId: 1,
32
lines: [
33
'first',
34
'second'
35
],
36
encoding: 'utf8'
37
}]
38
});
39
40
return new Promise((resolve, reject) => {
41
42
const d = editors.onDidRemoveDocuments(e => {
43
try {
44
45
for (const data of e) {
46
assert.strictEqual(data.document.isClosed, true);
47
}
48
resolve(undefined);
49
} catch (e) {
50
reject(e);
51
} finally {
52
d.dispose();
53
}
54
});
55
56
editors.$acceptDocumentsAndEditorsDelta({
57
removedDocuments: [URI.parse('foo:bar')]
58
});
59
60
});
61
});
62
63
});
64
65