@@ -13,7 +13,6 @@ import { CommandRegistry } from '@theia/core/lib/common/command';
1313
1414@injectable ( )
1515export class SketchbookTreeModel extends FileTreeModel {
16- 1716 @inject ( FileService )
1817 protected readonly fileService : FileService ;
1918
@@ -34,43 +33,50 @@ export class SketchbookTreeModel extends FileTreeModel {
3433
3534 async updateRoot ( ) : Promise < void > {
3635 const config = await this . configService . getConfiguration ( ) ;
37- const fileStat = await this . fileService . resolve ( new URI ( config . sketchDirUri ) ) ;
38- const showAllFiles = this . arduinoPreferences [ 'arduino.sketchbook.showAllFiles' ] ;
36+ const fileStat = await this . fileService . resolve (
37+ new URI ( config . sketchDirUri )
38+ ) ;
39+ const showAllFiles =
40+ this . arduinoPreferences [ 'arduino.sketchbook.showAllFiles' ] ;
3941 this . tree . root = SketchbookTree . RootNode . create ( fileStat , showAllFiles ) ;
4042 }
4143
4244 // selectNode gets called when the user single-clicks on an item
4345 // when this happens, we want to open the file if it belongs to the currently open sketch
4446 async selectNode ( node : Readonly < SelectableTreeNode > ) : Promise < void > {
45- 4647 super . selectNode ( node ) ;
4748 if ( FileNode . is ( node ) ) {
48- open ( this . openerService , node . uri ) ;
49+ this . open ( node . uri ) ;
4950 }
51+ }
5052
53+ protected open ( uri : URI ) : void {
54+ open ( this . openerService , uri ) ;
5155 }
5256
5357 protected async doOpenNode ( node : TreeNode ) : Promise < void > {
5458 // if it's a sketch dir, or a file from another sketch, open in new window
5559 if ( ! ( await this . isFileInsideCurrentSketch ( node ) ) ) {
5660 const sketchRoot = this . recursivelyFindSketchRoot ( node ) ;
5761 if ( sketchRoot ) {
58- this . commandRegistry . executeCommand ( SketchbookCommands . OPEN_NEW_WINDOW . id , { node : sketchRoot } )
62+ this . commandRegistry . executeCommand (
63+ SketchbookCommands . OPEN_NEW_WINDOW . id ,
64+ { node : sketchRoot }
65+ ) ;
5966 }
6067 return ;
6168 }
6269
6370 if ( node . visible === false ) {
6471 return ;
6572 } else if ( FileNode . is ( node ) ) {
66- open ( this . openerService , node . uri ) ;
73+ this . open ( node . uri ) ;
6774 } else {
6875 super . doOpenNode ( node ) ;
6976 }
7077 }
7178
7279 private async isFileInsideCurrentSketch ( node : TreeNode ) : Promise < boolean > {
73- 7480 // it's a directory, not a file
7581 if ( ! FileNode . is ( node ) ) {
7682 return false ;
@@ -85,7 +91,6 @@ export class SketchbookTreeModel extends FileTreeModel {
8591 }
8692
8793 protected recursivelyFindSketchRoot ( node : TreeNode ) : TreeNode | false {
88- 8994 if ( node && SketchbookTree . SketchDirNode . is ( node ) ) {
9095 return node ;
9196 }
@@ -97,5 +102,4 @@ export class SketchbookTreeModel extends FileTreeModel {
97102 // can't find a root, return false
98103 return false ;
99104 }
100- 101105}
0 commit comments