Skip to content

Commit 530aa48

Browse files
committed
expose context for cell language
1 parent 69fce35 commit 530aa48

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

apps/vscode/src/vdoc/vdoc.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*/
1515

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

1919
import { isQuartoDoc } from "../core/doc";
@@ -157,8 +157,12 @@ export async function virtualDocUri(
157157
export function languageAtPosition(tokens: Token[], position: Position) {
158158
const block = languageBlockAtPosition(tokens, position);
159159
if (block) {
160-
return languageFromBlock(block);
160+
const language = languageFromBlock(block);
161+
// expose cell language for use in keybindings, etc
162+
commands.executeCommand('setContext', 'quarto.cellLang', language?.extension);
163+
return language;
161164
} else {
165+
commands.executeCommand('setContext', 'quarto.cellLang', undefined);
162166
return undefined;
163167
}
164168
}

0 commit comments

Comments
 (0)