Preserve previous code cell's language when creating a new code cell from an existing context. (#18646)

This commit is contained in:
Cory Rivera
2022-03-06 21:35:57 -08:00
committed by GitHub
parent 5d0f0afdc6
commit eccb77aca3
6 changed files with 41 additions and 11 deletions

View File

@@ -75,7 +75,7 @@ export class SplitCellAction extends CellActionBase {
doRun(context: CellContext): Promise<void> {
let model = context.model;
let index = model.cells.findIndex((cell) => cell.id === context.cell.id);
context.model?.splitCell(context.cell.cellType, this.notebookService, index);
context.model?.splitCell(context.cell.cellType, this.notebookService, index, context.cell.metadata?.language);
return Promise.resolve();
}
public setListener(context: CellContext) {
@@ -246,7 +246,7 @@ export class AddCellFromContextAction extends CellActionBase {
if (index !== undefined && this.isAfter) {
index += 1;
}
model.addCell(this.cellType, index);
model.addCell(this.cellType, index, context.cell.metadata?.language);
} catch (error) {
let message = getErrorMessage(error);

View File

@@ -74,7 +74,7 @@ export class AddCellAction extends Action {
}
}
if (context?.model) {
context.model.addCell(this.cellType, index);
context.model.addCell(this.cellType, index, context.cell.metadata?.language);
context.model.sendNotebookTelemetryActionEvent(TelemetryKeys.NbTelemetryAction.AddCell, { cell_type: this.cellType });
}
} else {