Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cell selection state bugs #223794

Merged
merged 1 commit into from
Jul 25, 2024
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 @@ -250,12 +250,14 @@ export abstract class NotebookMultiCellAction extends Action2 {
// no parsed args, try handle active editor
const editor = getEditorFromArgsOrActivePane(accessor);
if (editor) {
const selectedCellRange: ICellRange[] = editor.getSelections().length === 0 ? [editor.getFocus()] : editor.getSelections();

telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>('workbenchActionExecuted', { id: this.desc.id, from: from });

return this.runWithContext(accessor, {
ui: false,
notebookEditor: editor,
selectedCells: cellRangeToViewCells(editor, editor.getSelections())
selectedCells: cellRangeToViewCells(editor, selectedCellRange)
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,8 @@ registerAction2(class CommentSelectedCellsAction extends NotebookMultiCellAction
keybinding: {
when: ContextKeyExpr.and(
NOTEBOOK_EDITOR_FOCUSED,
NOTEBOOK_CELL_LIST_FOCUSED,
ContextKeyExpr.not(InputFocusedContextKey),
NOTEBOOK_EDITOR_EDITABLE,
NOTEBOOK_CELL_EDITABLE
ContextKeyExpr.not(InputFocusedContextKey),
),
primary: KeyMod.CtrlCmd | KeyCode.Slash,
weight: KeybindingWeight.WorkbenchContrib
Expand All @@ -657,6 +655,7 @@ registerAction2(class CommentSelectedCellsAction extends NotebookMultiCellAction
}
});


selectedCellEditors.forEach(editor => {
if (!editor.hasModel()) {
return;
Expand All @@ -667,6 +666,8 @@ registerAction2(class CommentSelectedCellsAction extends NotebookMultiCellAction
const modelOptions = model.getOptions();
const commentsOptions = editor.getOption(EditorOption.comments);

const selection = editor.getSelection();

commands.push(new LineCommentCommand(
languageConfigurationService,
new Selection(1, 1, model.getLineCount(), model.getLineMaxColumn(model.getLineCount())),
Expand All @@ -680,6 +681,8 @@ registerAction2(class CommentSelectedCellsAction extends NotebookMultiCellAction
editor.pushUndoStop();
editor.executeCommands(COMMENT_SELECTED_CELLS_ID, commands);
editor.pushUndoStop();

editor.setSelection(selection);
});
}

Expand Down
Loading