11/**
22 * processing-vscode - Processing Language Support for VSCode
3- * @version 2.0.3
3+ * @version 2.0.5
44 * @copyright (C) 2016 - 2020 Tobiah Zarlez, 2021 Luke Zhang
55 */
66
7- import { dirname } from "path"
7+ import path , { dirname } from "path"
88import { getProcessingCommand } from "../getConfig"
9+ import { isValidProcessingProject } from "../utils"
910import vscode from "vscode"
1011
1112class RunManager {
@@ -24,13 +25,24 @@ class RunManager {
2425 const currentTerminal = ( this . _terminal ??= // Readability 100
2526 vscode . window . terminals . find ( ( terminal ) => terminal . name === "Processing" ) ??
2627 vscode . window . createTerminal ( "Processing" ) )
28+ let sketchName = dirname ( editor . document . fileName )
29+ const isValidProjectName = isValidProcessingProject ( sketchName . split ( path . sep ) . pop ( ) )
30+ const shouldQuotePath = sketchName . includes ( " " )
31+
32+ if ( shouldQuotePath ) {
33+ sketchName = `"${ sketchName } "`
34+ }
2735
2836 currentTerminal . show ( )
2937
38+ if ( ! isValidProjectName ) {
39+ vscode . window . showWarningMessage (
40+ "Warning: Processing project names must be valid Java variable names. Your program may fail to run properly." ,
41+ )
42+ }
43+
3044 // If file is a processing project file
31- const cmd = `${ getProcessingCommand ( ) } --sketch="${ dirname (
32- editor . document . fileName ,
33- ) } " --run`
45+ const cmd = `${ getProcessingCommand ( ) } --sketch=${ sketchName } --run`
3446
3547 currentTerminal . sendText ( cmd )
3648 }
0 commit comments