File tree Expand file tree Collapse file tree 3 files changed +31
-7
lines changed
Expand file tree Collapse file tree 3 files changed +31
-7
lines changed Original file line number Diff line number Diff line change 15271527 "command" : " swift.coverAllTests" ,
15281528 "when" : " view == projectPanel && viewItem == 'test_runnable'" ,
15291529 "group" : " inline@3"
1530+ },
1531+ {
1532+ "command" : " swift.play" ,
1533+ "when" : " view == projectPanel && viewItem == 'playground'" ,
1534+ "group" : " inline@1"
15301535 }
15311536 ]
15321537 },
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ import { switchPlatform } from "./commands/switchPlatform";
5151import { extractTestItemsAndCount , runTestMultipleTimes } from "./commands/testMultipleTimes" ;
5252import { SwiftLogger } from "./logging/SwiftLogger" ;
5353import { SwiftToolchain } from "./toolchain/toolchain" ;
54- import { PackageNode } from "./ui/ProjectPanelProvider" ;
54+ import { PackageNode , PlaygroundNode } from "./ui/ProjectPanelProvider" ;
5555import { showToolchainSelectionQuickPick } from "./ui/ToolchainSelection" ;
5656
5757/**
@@ -153,7 +153,11 @@ export function register(ctx: WorkspaceContext): vscode.Disposable[] {
153153 if ( ! folder || ! target ) {
154154 return false ;
155155 }
156- return await runPlayground ( folder , ctx . tasks , target ) ;
156+ return await runPlayground (
157+ folder ,
158+ ctx . tasks ,
159+ PlaygroundNode . isPlaygroundNode ( target ) ? target . playground : target
160+ ) ;
157161 } ) ,
158162 vscode . commands . registerCommand ( Commands . CLEAN_BUILD , async ( ) => await cleanBuild ( ctx ) ) ,
159163 vscode . commands . registerCommand (
Original file line number Diff line number Diff line change @@ -400,21 +400,36 @@ class TargetNode {
400400 }
401401}
402402
403- class PlaygroundNode {
403+ export class PlaygroundNode {
404404 constructor (
405405 public playground : Playground ,
406406 private folder : FolderContext ,
407407 private activeTasks : Set < string >
408408 ) { }
409409
410+ /**
411+ * "instanceof" has a bad effect in our nightly tests when the VSIX
412+ * bundled source is used. For example:
413+ *
414+ * ```
415+ * vscode.commands.registerCommand(Commands.PLAY, async (item, folder) => {
416+ * if (item instanceof PlaygroundNode) {
417+ * return await runPlayground(item.playground);
418+ * }
419+ * }),
420+ * ```
421+ *
422+ * So instead we'll check for this set boolean property. Even if the implementation of the
423+ * {@link PlaygroundNode} class changes, this property should not need to change
424+ */
425+ static isPlaygroundNode = ( item : { __isPlaygroundNode ?: boolean } ) =>
426+ item . __isPlaygroundNode ?? false ;
427+ __isPlaygroundNode = true ;
428+
410429 get name ( ) : string {
411430 return this . playground . label ?? this . playground . id ;
412431 }
413432
414- get args ( ) : string [ ] {
415- return [ this . name ] ;
416- }
417-
418433 toTreeItem ( ) : vscode . TreeItem {
419434 const name = this . name ;
420435 const item = new vscode . TreeItem ( this . name , vscode . TreeItemCollapsibleState . None ) ;
You can’t perform that action at this time.
0 commit comments