Skip to content

Commit ebcdbac

Browse files
authored
Close button on notebooks is broken (fix microsoft#221582) (microsoft#224147)
1 parent 77565bd commit ebcdbac

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/vs/workbench/browser/parts/editor/editorCommandsContext.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function moveCurrentEditorContextToFront(editorContext: IEditorCommandsContext,
102102
return multiEditorContext;
103103
}
104104

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

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

126126
// If there is no context in the arguments, try to find the context from the focused list
127127
// if the action was executed from a list
128-
if (isListAcion) {
128+
if (isListAction) {
129129
const list = listService.lastFocusedList as List<unknown>;
130130
for (const focusedElement of list.getFocusedElements()) {
131131
if (isGroupOrEditor(focusedElement)) {
@@ -147,6 +147,15 @@ function getMultiSelectContext(editorContext: IEditorCommandsContext, isListActi
147147
if (selection.length > 1) {
148148
return selection.map(e => groupOrEditorToEditorContext(e, editorContext.preserveFocus, editorGroupsService));
149149
}
150+
151+
if (selection.length === 0) {
152+
// TODO@benibenj workaround for https://github.com/microsoft/vscode/issues/224050
153+
// Explainer: the `isListAction` flag can be a false positive in certain cases because
154+
// it will be `true` if the active element is a `List` even if it is part of the editor
155+
// area. The workaround here is to fallback to `isListAction: false` if the list is not
156+
// having any editor or group selected.
157+
return getMultiSelectContext(editorContext, false, editorService, editorGroupsService, listService);
158+
}
150159
}
151160
// Check editors selected in the group (tabs)
152161
else {

0 commit comments

Comments
 (0)