Skip to content

Add option to use theme provided cell background (#675) #677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions apps/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -960,8 +960,16 @@
"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.useTheme": {
"order": 22,
"scope": "window",
"type": "string",
"format": "color",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"type": "string",
"format": "color",
"type": "boolean",

This is more like true vs. false, not a string formatted as a color, like what is show in this example:
https://code.visualstudio.com/api/references/contribution-points#Configuration-example

An example in this file is "quarto.cells.background.enabled".

"default": false,
"markdownDescription": "Should the background of executable code cells be based on the theme provided color.\n\nThis uses the `notebook.selectedCellBackground` color from the VSCode theme."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"markdownDescription": "Should the background of executable code cells be based on the theme provided color.\n\nThis uses the `notebook.selectedCellBackground` color from the VSCode theme."
"markdownDescription": "Use the `notebook.selectedCellBackground` color from the current theme as the background of executable code cells."

},
"quarto.cells.background.delay": {
"order": 23,
"scope": "window",
"type": "integer",
"default": 250,
Expand Down
12 changes: 10 additions & 2 deletions apps/vscode/src/providers/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,16 @@ 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 useTheme = config.get("cells.background.useTheme", false);
let light, dark;
if (useTheme) {
const activeCellBackgroundThemeColor = new vscode.ThemeColor('notebook.selectedCellBackground');
light = activeCellBackgroundThemeColor;
dark = activeCellBackgroundThemeColor;
} else {
light = config.get("cells.background.light", "#E1E1E166");
dark = config.get("cells.background.dark", "#40404066");
}

this.enabled_ = config.get("cells.background.enabled", true);
this.delayMs_ = config.get("cells.background.delay", 250);
Expand Down