Skip to content

Commit 42d626d

Browse files
authored
Merge branch 'main' into feat/protect-options-formatting
2 parents a48b0dd + 8ee12b5 commit 42d626d

File tree

6 files changed

+93
-55
lines changed

6 files changed

+93
-55
lines changed

.github/workflows/publish.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@ jobs:
2222
node-version: latest
2323
- run: yarn install --immutable --immutable-cache --check-cache
2424

25-
- name: Publish to Open VSX Registry
26-
uses: HaaLeo/publish-vscode-extension@v2
27-
with:
28-
pat: ${{ secrets.OPEN_VSX_TOKEN }}
29-
yarn: true
30-
packagePath: apps/vscode
31-
3225
- name: Publish to Visual Studio Marketplace
3326
uses: HaaLeo/publish-vscode-extension@v2
3427
id: publish_extension
@@ -38,6 +31,13 @@ jobs:
3831
yarn: true
3932
packagePath: apps/vscode
4033

34+
- name: Publish to Open VSX Registry
35+
uses: HaaLeo/publish-vscode-extension@v2
36+
with:
37+
pat: ${{ secrets.OPEN_VSX_TOKEN }}
38+
yarn: true
39+
packagePath: apps/vscode
40+
4141
- name: Get version of VS Code extension to publish
4242
id: extension-version
4343
uses: 'euberdeveloper/ga-project-version@main'

apps/vscode/CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
# Changelog
22

3-
## 1.119.0 (unreleased)
3+
## 1.120.0 (unreleased)
4+
5+
- Protect code cell options from formatting (<https://github.com/quarto-dev/quarto/pull/655>).
6+
7+
## 1.119.0 (Release on 2025-03-21)
48

59
- 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>).
610
- Fix behavior in Positron when running a cell containing invalid/incomplete code (<https://github.com/quarto-dev/quarto/pull/664>).
7-
- Protect code cell options from formatting (<https://github.com/quarto-dev/quarto/pull/655>).
11+
- Ensure `#|` is added only at the beginning of a new line (<https://github.com/quarto-dev/quarto/pull/649>).
812
- Fix `language` typos throughout the codebase (<https://github.com/quarto-dev/quarto/pull/650>)
13+
- Update cell background configuration to add the ability to use the appropriate theme color. The `quarto.cells.background` settings have changed names so you may need to update your configuration (<https://github.com/quarto-dev/quarto/pull/679>).
14+
- Use new command to switch between source and visual editors in Positron (<https://github.com/quarto-dev/quarto/pull/684>).
915

1016
## 1.118.0 (Release on 2024-11-26)
1117

apps/vscode/package.json

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"pandoc",
1212
"quarto"
1313
],
14-
"version": "1.119.0",
14+
"version": "1.120.0",
1515
"repository": {
1616
"type": "git",
1717
"url": "https://github.com/quarto-dev/quarto/tree/main/apps/vscode"
@@ -938,27 +938,38 @@
938938
"markdownDescription": "Show parameter help when editing function calls."
939939
},
940940
"quarto.cells.background.enabled": {
941+
"type": "boolean",
942+
"description": "Enable coloring the background of executable code cells.",
943+
"deprecationMessage": "Deprecated: Please use quarto.cells.background.color instead."
944+
},
945+
"quarto.cells.background.color": {
941946
"order": 19,
942947
"scope": "window",
943-
"type": "boolean",
944-
"default": true,
945-
"markdownDescription": "Enable coloring the background of executable code cells."
948+
"type": "string",
949+
"markdownDescription": "Control the background coloring of executable code cells.",
950+
"default": "default",
951+
"enum": ["default", "useTheme", "off"],
952+
"markdownEnumDescriptions": [
953+
"Use the default light and dark background colors. Specify these colors with `quarto.cells.background.lightDefault` and `quarto.cells.background.darkDefault`.",
954+
"Use the `notebook.selectedCellBackground` color from the current VS Code theme.",
955+
"Disable background coloring of executable code cells."
956+
]
946957
},
947-
"quarto.cells.background.light": {
958+
"quarto.cells.background.lightDefault": {
948959
"order": 20,
949960
"scope": "window",
950961
"type": "string",
951962
"format": "color",
952963
"default": "#E1E1E166",
953-
"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.*"
964+
"markdownDescription": "CSS color for background of executable code cells on light themes.\n\n*Note that this color should include an alpha channel, like #RRGGBBAA, so that selections show up against the background.*"
954965
},
955-
"quarto.cells.background.dark": {
966+
"quarto.cells.background.darkDefault": {
956967
"order": 21,
957968
"scope": "window",
958969
"type": "string",
959970
"format": "color",
960971
"default": "#40404066",
961-
"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.*"
972+
"markdownDescription": "CSS color for background of executable code cells on dark themes.\n\n*Note that this color should include an alpha channel, like #RRGGBBAA, so that selections show up against the background.*"
962973
},
963974
"quarto.cells.background.delay": {
964975
"order": 22,

apps/vscode/src/providers/background.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ function clearEditorHighlightDecorations(editor: vscode.TextEditor) {
192192
editor.setDecorations(highlightingConfig.backgroundDecoration(), []);
193193
}
194194

195+
enum CellBackgroundColor {
196+
default = "default",
197+
off = "off",
198+
useTheme = "useTheme",
199+
}
200+
195201
class HiglightingConfig {
196202
constructor() { }
197203

@@ -213,10 +219,18 @@ class HiglightingConfig {
213219

214220
public sync() {
215221
const config = vscode.workspace.getConfiguration("quarto");
216-
const light = config.get("cells.background.light", "#E1E1E166");
217-
const dark = config.get("cells.background.dark", "#40404066");
222+
const backgroundOption = config.get<CellBackgroundColor>("cells.background.color", CellBackgroundColor.default);
223+
let light, dark;
224+
if (backgroundOption === CellBackgroundColor.useTheme) {
225+
const activeCellBackgroundThemeColor = new vscode.ThemeColor('notebook.selectedCellBackground');
226+
light = activeCellBackgroundThemeColor;
227+
dark = activeCellBackgroundThemeColor;
228+
} else {
229+
light = config.get<string>("cells.background.lightDefault", "#E1E1E166");
230+
dark = config.get<string>("cells.background.darkDefault", "#40404066");
231+
}
218232

219-
this.enabled_ = config.get("cells.background.enabled", true);
233+
this.enabled_ = backgroundOption !== CellBackgroundColor.off;
220234
this.delayMs_ = config.get("cells.background.delay", 250);
221235

222236

apps/vscode/src/providers/editor/toggle.ts

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { Command } from "../../core/command";
1919
import { isQuartoDoc, kQuartoLanguageId } from "../../core/doc";
2020
import { VisualEditorProvider } from "./editor";
2121
import { Uri } from "vscode";
22+
import { hasHooks } from "../../host/hooks";
2223

2324
export function determineMode(text: string, uri: Uri): string | undefined {
2425
let editorOpener = undefined;
@@ -100,47 +101,53 @@ export async function reopenEditorInVisualMode(
100101
document: TextDocument,
101102
viewColumn?: ViewColumn
102103
) {
103-
104-
// save then close
105-
await commands.executeCommand("workbench.action.files.save");
106-
await commands.executeCommand('workbench.action.closeActiveEditor');
107-
VisualEditorProvider.recordPendingSwitchToVisual(document);
108-
// open in visual mode
109-
await commands.executeCommand("vscode.openWith",
110-
document.uri,
111-
VisualEditorProvider.viewType,
112-
{
113-
viewColumn
114-
}
115-
);
104+
if (hasHooks()) {
105+
commands.executeCommand('positron.reopenWith', document.uri, 'quarto.visualEditor');
106+
} else {
107+
// save then close
108+
await commands.executeCommand("workbench.action.files.save");
109+
await commands.executeCommand('workbench.action.closeActiveEditor');
110+
VisualEditorProvider.recordPendingSwitchToVisual(document);
111+
// open in visual mode
112+
await commands.executeCommand("vscode.openWith",
113+
document.uri,
114+
VisualEditorProvider.viewType,
115+
{
116+
viewColumn
117+
}
118+
);
119+
}
116120
}
117121

118122
export async function reopenEditorInSourceMode(
119123
document: TextDocument,
120124
untitledContent?: string,
121125
viewColumn?: ViewColumn
122126
) {
123-
if (!document.isUntitled) {
124-
await commands.executeCommand("workbench.action.files.save");
125-
}
126-
127-
// note pending switch to source
128-
VisualEditorProvider.recordPendingSwitchToSource(document);
129-
130-
// close editor (return immediately as if we don't then any
131-
// rpc method that calls this wil result in an error b/c the webview
132-
// has been torn down by the time we return)
133-
commands.executeCommand('workbench.action.closeActiveEditor').then(async () => {
134-
if (document.isUntitled) {
135-
const doc = await workspace.openTextDocument({
136-
language: kQuartoLanguageId,
137-
content: untitledContent || '',
138-
});
139-
await window.showTextDocument(doc, viewColumn, false);
140-
} else {
141-
const doc = await workspace.openTextDocument(document.uri);
142-
await window.showTextDocument(doc, viewColumn, false);
127+
if (hasHooks()) {
128+
commands.executeCommand('positron.reopenWith', document.uri, 'default');
129+
} else {
130+
if (!document.isUntitled) {
131+
await commands.executeCommand("workbench.action.files.save");
143132
}
144-
});
145133

134+
// note pending switch to source
135+
VisualEditorProvider.recordPendingSwitchToSource(document);
136+
137+
// close editor (return immediately as if we don't then any
138+
// rpc method that calls this wil result in an error b/c the webview
139+
// has been torn down by the time we return)
140+
commands.executeCommand('workbench.action.closeActiveEditor').then(async () => {
141+
if (document.isUntitled) {
142+
const doc = await workspace.openTextDocument({
143+
language: kQuartoLanguageId,
144+
content: untitledContent || '',
145+
});
146+
await window.showTextDocument(doc, viewColumn, false);
147+
} else {
148+
const doc = await workspace.openTextDocument(document.uri);
149+
await window.showTextDocument(doc, viewColumn, false);
150+
}
151+
});
152+
}
146153
}

apps/vscode/src/providers/option.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function handleOptionEnter(editor: TextEditor, comment: string) {
8484
});
8585
} else if (currentLine.startsWith(optionComment)) {
8686
editor.edit((builder) => {
87-
builder.insert(editor.selection.start.translate(1, 0), optionComment);
87+
builder.insert(editor.selection.start.translate(1, -editor.selection.active.character), optionComment);
8888
});
8989
}
9090
}

0 commit comments

Comments
 (0)