Skip to content

Commit

Permalink
change cell type when selecting markdown as a code cells language (#1…
Browse files Browse the repository at this point in the history
…3933)

Signed-off-by: Jonah Iden <jonah.iden@typefox.io>
  • Loading branch information
jonah-iden authored Jul 17, 2024
1 parent 7f928f2 commit 9e9a9f1
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,22 @@ export class NotebookCellActionContribution implements MenuContribution, Command
execute: async (notebook?: NotebookModel, cell?: NotebookCellModel) => {
const selectedCell = cell ?? this.notebookEditorWidgetService.focusedEditor?.model?.selectedCell;
const activeNotebook = notebook ?? this.notebookEditorWidgetService.focusedEditor?.model;
if (selectedCell && activeNotebook) {
const language = await this.languageQuickPickService.pickEditorLanguage(selectedCell.language);
if (language?.value && language.value !== 'autoDetect') {
this.notebookEditorWidgetService.focusedEditor?.model?.applyEdits([{
editType: CellEditType.CellLanguage,
index: activeNotebook.cells.indexOf(selectedCell),
language: language.value.id
}], true);
}
if (!selectedCell || !activeNotebook) {
return;
}
const language = await this.languageQuickPickService.pickEditorLanguage(selectedCell.language);
if (!language?.value || language.value === 'autoDetect') {
return;
}
if (language.value.id === 'markdown') {
selectedCell.language = 'markdown';
changeCellType(activeNotebook, selectedCell, CellKind.Markup);
} else {
this.notebookEditorWidgetService.focusedEditor?.model?.applyEdits([{
editType: CellEditType.CellLanguage,
index: activeNotebook.cells.indexOf(selectedCell),
language: language.value.id
}], true);
}
}
});
Expand Down

0 comments on commit 9e9a9f1

Please sign in to comment.