Skip to content

Commit

Permalink
Fix Diff Editor Model Refs (#696)
Browse files Browse the repository at this point in the history
* Fix diff model refs
* Update test to verify diff model refs
  • Loading branch information
zgbpr committed Jul 2, 2024
1 parent d80b0bc commit 3c1c0ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/wrapper/src/editorAppBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,18 @@ export abstract class EditorAppBase {
}

async buildModelRefs(codeResources?: CodeResources): Promise<ModelRefs> {
const modelRef = await this.buildModelRef(codeResources?.main);
const modelRefOriginal = await this.buildModelRef(codeResources?.original);
const modelRef = await this.buildModelRef(codeResources?.main, false);
const modelRefOriginal = await this.buildModelRef(codeResources?.original, true);

return {
modelRef,
modelRefOriginal
};
}

private async buildModelRef(code?: CodePlusUri | CodePlusFileExt): Promise<IReference<ITextFileEditorModel> | undefined> {
private async buildModelRef(code?: CodePlusUri | CodePlusFileExt, original?: boolean): Promise<IReference<ITextFileEditorModel> | undefined> {
if (code) {
const uri = getEditorUri(this.id, false, code);
const uri = getEditorUri(this.id, original ?? false, code);
const modelRef = await createModelReference(uri, code.text);
this.checkEnforceLanguageId(modelRef, code.enforceLanguageId);
return modelRef;
Expand Down
7 changes: 7 additions & 0 deletions packages/wrapper/test/wrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ describe('Test MonacoEditorLanguageClientWrapper', () => {
const modelRefs = app?.getModelRefs();
expect(modelRefs?.modelRef).toBeDefined();
expect(modelRefs?.modelRefOriginal).toBeDefined();

const name = modelRefs?.modelRef?.object.name;
const nameOriginal = modelRefs?.modelRefOriginal?.object.name;
expect(name).toBeDefined();
expect(nameOriginal).toBeDefined();
expect(name).not.toEqual(nameOriginal);

app?.disposeApp();
});

Expand Down

0 comments on commit 3c1c0ac

Please sign in to comment.