Skip to content

Commit e793b4f

Browse files
committed
Improve sketch run command and add TODOs
Added a TODO for sketch management in extension.ts and included additional TODOs in setupCommands.ts for using VSCode contexts. Updated the runSketch command to dispose of existing 'Sketch' terminals before creating a new one, ensuring only one active terminal per sketch run.
1 parent b254d95 commit e793b4f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

client/src/extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export async function activate(context: ExtensionContext) {
2727
// TODO: Detect other Processing extensions and warn the user
2828
// TODO: Add a open contribution manager action (Needs Processing integration)
2929
// TODO: Add checks for if a required Processing version is met (e.g, this specific feature works with 4.4.6+)
30+
// TODO: Sketch management (open folder as sketch, create new sketch, etc)
3031

3132
// Set up the selected Processing version, awaiting because we don't want to continue until we have a version
3233
await setupSelectedVersion(context);

client/src/setupCommands.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { dirname, join } from 'path';
22
import { ExtensionContext, commands, Uri, window, workspace } from 'vscode';
33
import { state } from './extension';
4-
import { tmpdir } from 'os';
54

65
export function setupCommands(context: ExtensionContext) {
76
const runSketch = commands.registerCommand('processing.sketch.run', (resource: Uri) => {
7+
// TODO: Use VScode contexts to highlight run button when sketch is running, blocked until we do not run the sketch in a terminal
8+
// https://code.visualstudio.com/api/references/when-clause-contexts
9+
810
const autosave = workspace
911
.getConfiguration('processing')
1012
.get<boolean>('autosave');
@@ -28,6 +30,11 @@ export function setupCommands(context: ExtensionContext) {
2830
let terminal = state.terminal;
2931
// Create a new terminal
3032
if (terminal === undefined || terminal.exitStatus) {
33+
window.terminals.forEach(t => {
34+
if (t.name === "Sketch") {
35+
t.dispose();
36+
}
37+
});
3138
state.terminal = window.createTerminal("Sketch");
3239
terminal = state.terminal;
3340
}

0 commit comments

Comments
 (0)