Skip to content

Commit 44da540

Browse files
committed
1 parent 97dc707 commit 44da540

2 files changed

Lines changed: 66 additions & 4 deletions

File tree

src/vs/workbench/api/node/extHostDocumentsAndEditors.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ export class ExtHostDocumentsAndEditors extends ExtHostDocumentsAndEditorsShape
9898
this._activeEditorId = delta.newActiveEditor;
9999
}
100100

101+
dispose(removedDocuments);
102+
dispose(removedEditors);
103+
101104
// now that the internal state is complete, fire events
102105
if (delta.removedDocuments) {
103106
this._onDidRemoveDocuments.fire(removedDocuments);
@@ -112,10 +115,6 @@ export class ExtHostDocumentsAndEditors extends ExtHostDocumentsAndEditorsShape
112115
if (delta.newActiveEditor !== undefined) {
113116
this._onDidChangeActiveTextEditor.fire(this.activeEditor());
114117
}
115-
116-
// now that the events are out, dispose removed documents and editors
117-
dispose(removedDocuments);
118-
dispose(removedEditors);
119118
}
120119

121120
getDocument(strUrl: string): ExtHostDocumentData {
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
'use strict';
7+
8+
import * as assert from 'assert';
9+
import URI from 'vs/base/common/uri';
10+
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/node/extHostDocumentsAndEditors';
11+
import { TPromise } from 'vs/base/common/winjs.base';
12+
13+
14+
suite('ExtHostDocumentsAndEditors', () => {
15+
16+
let editors: ExtHostDocumentsAndEditors;
17+
18+
setup(function () {
19+
editors = new ExtHostDocumentsAndEditors({
20+
_serviceBrand: undefined,
21+
get() { return undefined; },
22+
set() { }
23+
});
24+
});
25+
26+
test('The value of TextDocument.isClosed is incorrect when a text document is closed, #27949', () => {
27+
28+
editors.$acceptDocumentsAndEditorsDelta({
29+
addedDocuments: [{
30+
EOL: '\n',
31+
isDirty: true,
32+
modeId: 'fooLang',
33+
url: URI.parse('foo:bar'),
34+
versionId: 1,
35+
lines: [
36+
'first',
37+
'second'
38+
]
39+
}]
40+
});
41+
42+
return new TPromise((resolve, reject) => {
43+
44+
editors.onDidRemoveDocuments(e => {
45+
try {
46+
47+
for (const data of e) {
48+
assert.equal(data.document.isClosed, true);
49+
}
50+
resolve(undefined);
51+
} catch (e) {
52+
reject(e);
53+
}
54+
});
55+
56+
editors.$acceptDocumentsAndEditorsDelta({
57+
removedDocuments: ['foo:bar']
58+
});
59+
60+
});
61+
});
62+
63+
});

0 commit comments

Comments
 (0)