Skip to content

Commit

Permalink
#216922 do not auto restart when there is an open notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jul 29, 2024
1 parent 546567a commit 41aabbf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,23 @@ export class NotebookEditorInput extends AbstractResourceEditorInput {
return;
}

const reason = e.auto
? localize('vetoAutoExtHostRestart', "One of the opened editors is a notebook editor.")
: localize('vetoExtHostRestart', "Notebook '{0}' could not be saved.", this.resource.path);

e.veto((async () => {
const editors = editorService.findEditors(this);
if (e.auto) {
return true;
}
if (editors.length > 0) {
const result = await editorService.save(editors[0]);
if (result.success) {
return false; // Don't Veto
}
}
return true; // Veto
})(), localize('vetoExtHostRestart', "Notebook '{0}' could not be saved.", this.resource.path));
})(), reason);
}));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,12 +687,13 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
}
}

private async _doStopExtensionHostsWithVeto(reason: string, auto?: boolean): Promise<boolean> {
private async _doStopExtensionHostsWithVeto(reason: string, auto: boolean = false): Promise<boolean> {
const vetos: (boolean | Promise<boolean>)[] = [];
const vetoReasons = new Set<string>();

this._onWillStop.fire({
reason,
auto,
veto(value, reason) {
vetos.push(value);

Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/services/extensions/common/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@ export interface WillStopExtensionHostsEvent {
*/
readonly reason: string;

/**
* A flag to indicate if the operation was triggered automatically
*/
readonly auto: boolean;

/**
* Allows to veto the stopping of extension hosts. The veto can be a long running
* operation.
Expand Down

0 comments on commit 41aabbf

Please sign in to comment.