Skip to content

Commit

Permalink
Use URI for IDocumentsAndEditorsDelta.removedDocuments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Feb 8, 2018
1 parent 535fc34 commit 5b1d34e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/vs/workbench/api/electron-browser/mainThreadDocuments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
this._proxy.$acceptModelModeChanged(model.uri.toString(), oldModeId, model.getLanguageIdentifier().language);
}

private _onModelRemoved(modelUrl: string): void {

if (!this._modelIsSynced[modelUrl]) {
private _onModelRemoved(modelUrl: URI): void {
let strModelUrl = modelUrl.toString();
if (!this._modelIsSynced[strModelUrl]) {
return;
}
delete this._modelIsSynced[modelUrl];
this._modelToDisposeMap[modelUrl].dispose();
delete this._modelToDisposeMap[modelUrl];
delete this._modelIsSynced[strModelUrl];
this._modelToDisposeMap[strModelUrl].dispose();
delete this._modelToDisposeMap[strModelUrl];
}

// --- from extension host process
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { isCodeEditor, isDiffEditor, ICodeEditor } from 'vs/editor/browser/editorBrowser';
import URI from 'vs/base/common/uri';

namespace mapset {

Expand Down Expand Up @@ -289,12 +290,12 @@ export class MainThreadDocumentsAndEditors {
private _onTextEditorAdd = new Emitter<MainThreadTextEditor[]>();
private _onTextEditorRemove = new Emitter<string[]>();
private _onDocumentAdd = new Emitter<ITextModel[]>();
private _onDocumentRemove = new Emitter<string[]>();
private _onDocumentRemove = new Emitter<URI[]>();

readonly onTextEditorAdd: Event<MainThreadTextEditor[]> = this._onTextEditorAdd.event;
readonly onTextEditorRemove: Event<string[]> = this._onTextEditorRemove.event;
readonly onDocumentAdd: Event<ITextModel[]> = this._onDocumentAdd.event;
readonly onDocumentRemove: Event<string[]> = this._onDocumentRemove.event;
readonly onDocumentRemove: Event<URI[]> = this._onDocumentRemove.event;

constructor(
extHostContext: IExtHostContext,
Expand Down Expand Up @@ -336,12 +337,12 @@ export class MainThreadDocumentsAndEditors {

private _onDelta(delta: DocumentAndEditorStateDelta): void {

let removedDocuments: string[];
let removedDocuments: URI[];
let removedEditors: string[] = [];
let addedEditors: MainThreadTextEditor[] = [];

// removed models
removedDocuments = delta.removedDocuments.map(m => m.uri.toString());
removedDocuments = delta.removedDocuments.map(m => m.uri);

// added editors
for (const apiEditor of delta.addedEditors) {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/node/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ export interface ExtHostEditorsShape {
}

export interface IDocumentsAndEditorsDelta {
removedDocuments?: string[];
removedDocuments?: UriComponents[];
addedDocuments?: IModelAddedData[];
removedEditors?: string[];
addedEditors?: ITextEditorAddData[];
Expand Down
4 changes: 3 additions & 1 deletion src/vs/workbench/api/node/extHostDocumentsAndEditors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
const removedEditors: ExtHostTextEditor[] = [];

if (delta.removedDocuments) {
for (const id of delta.removedDocuments) {
for (const uriComponent of delta.removedDocuments) {
const uri = URI.revive(uriComponent);
const id = uri.toString();
const data = this._documents.get(id);
this._documents.delete(id);
removedDocuments.push(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ suite('ExtHostDocumentsAndEditors', () => {
});

editors.$acceptDocumentsAndEditorsDelta({
removedDocuments: ['foo:bar']
removedDocuments: [URI.parse('foo:bar')]
});

});
Expand Down

0 comments on commit 5b1d34e

Please sign in to comment.