@@ -71,8 +71,8 @@ function openFolder(_path, opts = {}) {
7171
7272 const $root = collapsableList ( title , "folder" , {
7373 tail : < Tail target = { ( ) => $root . $title } /> ,
74- allCaps : true ,
75- ontoggle : ( ) => expandList ( $root ) ,
74+ allCaps : true ,
75+ ontoggle : ( ) => expandList ( $root ) ,
7676 } ) ;
7777 const $text = $root . $title . get ( ":scope>span.text" ) ;
7878
@@ -85,10 +85,10 @@ function openFolder(_path, opts = {}) {
8585 $root . $title . dataset . name = title ;
8686
8787 $root . $ul . onclick =
88- $root . $ul . oncontextmenu =
89- $root . $title . onclick =
90- $root . $title . oncontextmenu =
91- handleItems ;
88+ $root . $ul . oncontextmenu =
89+ $root . $title . onclick =
90+ $root . $title . oncontextmenu =
91+ handleItems ;
9292
9393 recents . addFolder ( _path , opts ) ;
9494 sidebarApps . get ( "files" ) . append ( $root ) ;
@@ -182,24 +182,24 @@ async function expandList($list) {
182182 startLoading ( ) ;
183183 const entries = await fsOperation ( url ) . lsDir ( ) ;
184184 helpers
185- . sortDir ( entries , {
186- sortByName : true ,
187- showHiddenFiles : true ,
188- } )
189- . map ( ( entry ) => {
190- const name = entry . name || Path . basename ( entry . url ) ;
191- if ( entry . isDirectory ) {
192- const $list = createFolderTile ( name , entry . url ) ;
193- $ul . appendChild ( $list ) ;
194-
195- if ( listState [ entry . url ] ) {
196- $list . expand ( ) ;
197- }
198- } else {
199- const $item = createFileTile ( name , entry . url ) ;
200- $ul . append ( $item ) ;
185+ . sortDir ( entries , {
186+ sortByName : true ,
187+ showHiddenFiles : true ,
188+ } )
189+ . map ( ( entry ) => {
190+ const name = entry . name || Path . basename ( entry . url ) ;
191+ if ( entry . isDirectory ) {
192+ const $list = createFolderTile ( name , entry . url ) ;
193+ $ul . appendChild ( $list ) ;
194+
195+ if ( listState [ entry . url ] ) {
196+ $list . expand ( ) ;
201197 }
202- } ) ;
198+ } else {
199+ const $item = createFileTile ( name , entry . url ) ;
200+ $ul . append ( $item ) ;
201+ }
202+ } ) ;
203203 } catch ( err ) {
204204 $list . collapse ( ) ;
205205 helpers . error ( err ) ;
@@ -388,7 +388,7 @@ function execOperation(type, action, url, $target, name) {
388388 $target . dataset . name = newName ;
389389 if ( helpers . isFile ( type ) ) {
390390 $target . querySelector ( ":scope>span" ) . className =
391- helpers . getIconForFile ( newName ) ;
391+ helpers . getIconForFile ( newName ) ;
392392 let file = editorManager . getFile ( url , "uri" ) ;
393393 if ( file ) {
394394 file . uri = newUrl ;
@@ -406,9 +406,9 @@ function execOperation(type, action, url, $target, name) {
406406
407407 async function createNew ( ) {
408408 const msg =
409- action === "new file"
410- ? strings [ "enter file name" ]
411- : strings [ "enter folder name" ] ;
409+ action === "new file"
410+ ? strings [ "enter file name" ]
411+ : strings [ "enter folder name" ] ;
412412
413413 let newName = await prompt ( msg , "" , "text" , {
414414 match : constants . FILE_NAME_REGEX ,
@@ -425,11 +425,12 @@ function execOperation(type, action, url, $target, name) {
425425 } else {
426426 newUrl = await helpers . createFileStructure ( url , newName , false ) ;
427427 }
428+ if ( ! newUrl ) return ;
428429 newName = Url . basename ( newUrl . uri ) ;
429430 if ( $target . unclasped ) {
430431 if ( newUrl . type == "file" ) {
431432 appendTile ( $target , createFileTile ( newName , newUrl . uri ) ) ;
432- } else {
433+ } else if ( newUrl . type == "folder" ) {
433434 appendList ( $target , createFolderTile ( newName , newUrl . uri ) ) ;
434435 }
435436 }
@@ -635,7 +636,7 @@ function appendList($target, $list) {
635636function createFolderTile ( name , url ) {
636637 const $list = collapsableList ( name , "folder" , {
637638 tail : < Tail target = { ( ) => $list . $title } /> ,
638- ontoggle : ( ) => expandList ( $list ) ,
639+ ontoggle : ( ) => expandList ( $list ) ,
639640 } ) ;
640641 const { $title } = $list ;
641642 $title . dataset . url = url ;
@@ -654,8 +655,8 @@ function createFolderTile(name, url) {
654655function createFileTile ( name , url ) {
655656 const $tile = tile ( {
656657 lead : < span className = { helpers . getIconForFile ( name ) } > </ span > ,
657- text : name ,
658- tail : < Tail target = { ( ) => $tile } /> ,
658+ text : name ,
659+ tail : < Tail target = { ( ) => $tile } /> ,
659660 } ) ;
660661 $tile . dataset . url = url ;
661662 $tile . dataset . name = name ;
@@ -673,16 +674,16 @@ function createFileTile(name, url) {
673674function Tail ( { target } ) {
674675 return (
675676 < span
676- className = "icon more_vert"
677- attr-action = "close"
678- onclick = { ( e ) => {
679- e . stopPropagation ( ) ;
680- e . preventDefault ( ) ;
681- handleItems ( {
682- target : target ( ) ,
683- type : "contextmenu" ,
684- } ) ;
685- } }
677+ className = "icon more_vert"
678+ attr-action = "close"
679+ onclick = { ( e ) => {
680+ e . stopPropagation ( ) ;
681+ e . preventDefault ( ) ;
682+ handleItems ( {
683+ target : target ( ) ,
684+ type : "contextmenu" ,
685+ } ) ;
686+ } }
686687 > </ span >
687688 ) ;
688689}
@@ -725,7 +726,7 @@ openFolder.renameItem = (oldFile, newFile, newFilename) => {
725726 } , 0 ) ;
726727 } else {
727728 $el . querySelector ( ":scope>span" ) . className =
728- helpers . getIconForFile ( newFilename ) ;
729+ helpers . getIconForFile ( newFilename ) ;
729730 }
730731
731732 $el . dataset . url = newFile ;
0 commit comments