Skip to content

Commit

Permalink
expose context for cell language
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelizimm committed Nov 21, 2024
1 parent 69fce35 commit 530aa48
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/vscode/src/vdoc/vdoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

import { Position, TextDocument, Uri, Range } from "vscode";
import { Position, TextDocument, Uri, Range, commands } from "vscode";
import { Token, isExecutableLanguageBlock, languageBlockAtPosition, languageNameFromBlock } from "quarto-core";

import { isQuartoDoc } from "../core/doc";
Expand Down Expand Up @@ -157,8 +157,12 @@ export async function virtualDocUri(
export function languageAtPosition(tokens: Token[], position: Position) {
const block = languageBlockAtPosition(tokens, position);
if (block) {
return languageFromBlock(block);
const language = languageFromBlock(block);
// expose cell language for use in keybindings, etc
commands.executeCommand('setContext', 'quarto.cellLang', language?.extension);
return language;
} else {
commands.executeCommand('setContext', 'quarto.cellLang', undefined);
return undefined;
}
}
Expand Down

0 comments on commit 530aa48

Please sign in to comment.