Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ export class SessionChangesEditor extends AbstractEditorWithViewState<IMultiDiff

override async setInput(input: SessionChangesEditorInput, options: IMultiDiffEditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken): Promise<void> {
await super.setInput(input, options, context, token);
if (token.isCancellationRequested) {
return;
}
const sessionResource = this.sessionChangesService.getSessionResource(input.multiDiffSource);
this._inputSessionResource.set(sessionResource, undefined);
const viewModel = await input.getViewModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import assert from 'assert';
import { CancellationTokenSource } from '../../../../../base/common/cancellation.js';
import { Emitter, Event, ValueWithChangeEvent } from '../../../../../base/common/event.js';
import { URI } from '../../../../../base/common/uri.js';
import { mock } from '../../../../../base/test/common/mock.js';
Expand Down Expand Up @@ -112,6 +113,38 @@ suite('SessionChangesEditorInput', () => {
});
});

test('does not resolve a canceled editor input', async () => {
class TestSessionChangesEditorInput extends SessionChangesEditorInput {
viewModelRequested = false;

override async getViewModel(): Promise<MultiDiffEditorViewModel> {
this.viewModelRequested = true;
throw new Error('Canceled input must not be resolved');
}
}

const instantiationService = workbenchInstantiationService(undefined, disposables);
instantiationService.stub(IChangesViewService, {});
instantiationService.stub(IAgentWorkbenchLayoutService, {});
instantiationService.stub(ISessionChangesService, {});
instantiationService.stub(IWorkbenchLayoutService, {
onDidChangePartVisibility: Event.None,
isVisible: () => true,
});

const editor = disposables.add(instantiationService.createInstance(SessionChangesEditor, new TestEditorGroupView(1)));
const input = disposables.add(instantiationService.createInstance(
TestSessionChangesEditorInput,
URI.parse('changes-multi-diff-source:?{"sessionResource":"agent-host-copilotcli:/session"}'),
));
const operation = disposables.add(new CancellationTokenSource());
operation.cancel();

await editor.setInput(input, undefined, {}, operation.token);

assert.deepStrictEqual(input.viewModelRequested, false);
});

test('updates managed Changes editor capabilities with editor area visibility', () => {
const instantiationService = disposables.add(new TestInstantiationService());
let editorVisible = false;
Expand Down
Loading