Skip to content

Commit

Permalink
Only show languages supported by some kernel (microsoft#170269)
Browse files Browse the repository at this point in the history
when a kernel is not selected
Fix microsoft#128338
  • Loading branch information
roblourens authored Dec 30, 2022
1 parent 90277d5 commit a8d3944
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,17 @@ registerAction2(class ChangeCellLanguageAction extends NotebookCellAction<ICellR
const modelService = accessor.get(IModelService);
const quickInputService = accessor.get(IQuickInputService);
const languageDetectionService = accessor.get(ILanguageDetectionService);
const kernelService = accessor.get(INotebookKernelService);

let languages = context.notebookEditor.activeKernel?.supportedLanguages;
if (!languages) {
const matchResult = kernelService.getMatchingKernel(context.notebookEditor.textModel);
const allSupportedLanguages = matchResult.all.flatMap(kernel => kernel.supportedLanguages);
languages = allSupportedLanguages.length > 0 ? allSupportedLanguages : languageService.getRegisteredLanguageIds();
}

const providerLanguages = new Set([
...(context.notebookEditor.activeKernel?.supportedLanguages ?? languageService.getRegisteredLanguageIds()),
...languages,
'markdown'
]);

Expand Down

0 comments on commit a8d3944

Please sign in to comment.