Skip to content

Commit

Permalink
Close button on notebooks is broken (fix #221582)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Jul 29, 2024
1 parent 7e80514 commit a2d5076
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/vs/workbench/browser/parts/editor/editorCommandsContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function moveCurrentEditorContextToFront(editorContext: IEditorCommandsContext,
return multiEditorContext;
}

function getEditorContextFromCommandArgs(commandArgs: unknown[], isListAcion: boolean, editorService: IEditorService, editorGroupsService: IEditorGroupsService, listService: IListService): IEditorCommandsContext | undefined {
function getEditorContextFromCommandArgs(commandArgs: unknown[], isListAction: boolean, editorService: IEditorService, editorGroupsService: IEditorGroupsService, listService: IListService): IEditorCommandsContext | undefined {
// We only know how to extraxt the command context from URI and IEditorCommandsContext arguments
const filteredArgs = commandArgs.filter(arg => isEditorCommandsContext(arg) || URI.isUri(arg));

Expand All @@ -125,7 +125,7 @@ function getEditorContextFromCommandArgs(commandArgs: unknown[], isListAcion: bo

// If there is no context in the arguments, try to find the context from the focused list
// if the action was executed from a list
if (isListAcion) {
if (isListAction) {
const list = listService.lastFocusedList as List<unknown>;
for (const focusedElement of list.getFocusedElements()) {
if (isGroupOrEditor(focusedElement)) {
Expand All @@ -147,6 +147,15 @@ function getMultiSelectContext(editorContext: IEditorCommandsContext, isListActi
if (selection.length > 1) {
return selection.map(e => groupOrEditorToEditorContext(e, editorContext.preserveFocus, editorGroupsService));
}

if (selection.length === 0) {
// TODO@benibenj workaround for https://github.com/microsoft/vscode/issues/224050
// Explainer: the `isListAction` flag can be a false positive in certain cases because
// it will be `true` if the active element is a `List` even if it is part of the editor
// area. The workaround here is to fallback to `isListAction: false` if the list is not
// having any editor or group selected.
return getMultiSelectContext(editorContext, false, editorService, editorGroupsService, listService);
}
}
// Check editors selected in the group (tabs)
else {
Expand Down

0 comments on commit a2d5076

Please sign in to comment.