Skip to content
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

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions apps/vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Use `QUARTO_VISUAL_EDITOR_CONFIRMED` > `PW_TEST` > `CI` to bypass (`true`) or force (`false`) the Visual Editor confirmation dialogue (<https://github.com/quarto-dev/quarto/pull/654>).
- Fix behavior in Positron when running a cell containing invalid/incomplete code (<https://github.com/quarto-dev/quarto/pull/664>).
- Ensure `#|` is added only at the beginning of a new line (<https://github.com/quarto-dev/quarto/pull/649>).
- Fix `language` typos throughout the codebase (<https://github.com/quarto-dev/quarto/pull/650>)

## 1.118.0 (Release on 2024-11-26)
Expand Down
28 changes: 19 additions & 9 deletions apps/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -937,31 +937,41 @@
"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",
"format": "color",
"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,
Expand Down
20 changes: 17 additions & 3 deletions apps/vscode/src/providers/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ function clearEditorHighlightDecorations(editor: vscode.TextEditor) {
editor.setDecorations(highlightingConfig.backgroundDecoration(), []);
}

enum CellBackground {
default = "default",
off = "off",
useTheme = "useTheme",
}

class HiglightingConfig {
constructor() { }

Expand All @@ -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<CellBackground>("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<string>("cells.background.lightDefault", "#E1E1E166");
dark = config.get<string>("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);


Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/src/providers/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}
Expand Down