diff --git a/apps/vscode/CHANGELOG.md b/apps/vscode/CHANGELOG.md index fda7a419..1e824179 100644 --- a/apps/vscode/CHANGELOG.md +++ b/apps/vscode/CHANGELOG.md @@ -4,6 +4,7 @@ - Use `QUARTO_VISUAL_EDITOR_CONFIRMED` > `PW_TEST` > `CI` to bypass (`true`) or force (`false`) the Visual Editor confirmation dialogue (). - Fix behavior in Positron when running a cell containing invalid/incomplete code (). +- Ensure `#|` is added only at the beginning of a new line (). - Fix `language` typos throughout the codebase () ## 1.118.0 (Release on 2024-11-26) diff --git a/apps/vscode/package.json b/apps/vscode/package.json index 5aa0cd1f..462a9b50 100644 --- a/apps/vscode/package.json +++ b/apps/vscode/package.json @@ -937,22 +937,32 @@ "default": true, "markdownDescription": "Show parameter help when editing function calls." }, - "quarto.cells.background.enabled": { + "quarto.cells.background": { "order": 19, "scope": "window", - "type": "boolean", - "default": true, - "markdownDescription": "Enable coloring the background of executable code cells." + "type": "string", + "default": "default", + "enum": [ + "default", + "useTheme", + "off" + ], + "markdownDescription": "Controls the background coloring of executable code cells.", + "enumDescriptions": [ + "Use the default light and dark background colors. Can specify colors in `quarto.cells.background.lightDefault` and `quarto.cells.background.darkDefault`", + "Use the `notebook.selectedCellBackground` color from the VS Code theme.", + "Disable background coloring of executable code cells." + ] }, - "quarto.cells.background.light": { + "quarto.cells.background.lightDefault": { "order": 20, "scope": "window", "type": "string", "format": "color", "default": "#E1E1E166", - "markdownDescription": "CSS color for background of executable code cells on light themes.\n\n*Note that this color should include an alpha channel so that selections show up against the background.*" + "markdownDescription": "CSS color for background of executable code cells on light themes. Only used when `quarto.cells.background: \"default\"`.\n\n*Note that this color should include an alpha channel so that selections show up against the background.*" }, - "quarto.cells.background.dark": { + "quarto.cells.background.darkDefault": { "order": 21, "scope": "window", "type": "string", @@ -960,8 +970,8 @@ "default": "#40404066", "markdownDescription": "CSS color for background of executable code cells on dark themes.\n\n*Note that this color should include an alpha channel so that selections show up against the background.*" }, - "quarto.cells.background.delay": { - "order": 22, + "quarto.cells.background.delay": { + "order": 23, "scope": "window", "type": "integer", "default": 250, diff --git a/apps/vscode/src/providers/background.ts b/apps/vscode/src/providers/background.ts index 2aae39d7..c234636b 100644 --- a/apps/vscode/src/providers/background.ts +++ b/apps/vscode/src/providers/background.ts @@ -192,6 +192,12 @@ function clearEditorHighlightDecorations(editor: vscode.TextEditor) { editor.setDecorations(highlightingConfig.backgroundDecoration(), []); } +enum CellBackground { + default = "default", + off = "off", + useTheme = "useTheme", +} + class HiglightingConfig { constructor() { } @@ -213,10 +219,18 @@ class HiglightingConfig { public sync() { const config = vscode.workspace.getConfiguration("quarto"); - const light = config.get("cells.background.light", "#E1E1E166"); - const dark = config.get("cells.background.dark", "#40404066"); + const backgroundOption = config.get("cells.background", CellBackground.default); + let light, dark; + if (backgroundOption === CellBackground.useTheme) { + const activeCellBackgroundThemeColor = new vscode.ThemeColor('notebook.selectedCellBackground'); + light = activeCellBackgroundThemeColor; + dark = activeCellBackgroundThemeColor; + } else { + light = config.get("cells.background.lightDefault", "#E1E1E166"); + dark = config.get("cells.background.darkDefault", "#40404066"); + } - this.enabled_ = config.get("cells.background.enabled", true); + this.enabled_ = backgroundOption !== CellBackground.off; this.delayMs_ = config.get("cells.background.delay", 250); diff --git a/apps/vscode/src/providers/option.ts b/apps/vscode/src/providers/option.ts index 32335087..eff92603 100644 --- a/apps/vscode/src/providers/option.ts +++ b/apps/vscode/src/providers/option.ts @@ -84,7 +84,7 @@ function handleOptionEnter(editor: TextEditor, comment: string) { }); } else if (currentLine.startsWith(optionComment)) { editor.edit((builder) => { - builder.insert(editor.selection.start.translate(1, 0), optionComment); + builder.insert(editor.selection.start.translate(1, -editor.selection.active.character), optionComment); }); } }