@@ -19,6 +19,13 @@ import openFile from "./openFile";
1919import recents from "./recents" ;
2020import appSettings from "./settings" ;
2121
22+ const isTermuxSafUri = ( value = "" ) =>
23+ value . startsWith ( "content://com.termux.documents/tree/" ) ;
24+ const isAcodeTerminalPublicSafUri = ( value = "" ) =>
25+ value . startsWith ( "content://com.foxdebug.acode.documents/tree/" ) ;
26+ const isTerminalSafUri = ( value = "" ) =>
27+ isTermuxSafUri ( value ) || isAcodeTerminalPublicSafUri ( value ) ;
28+
2229/**
2330 * @typedef {import('../components/collapsableList').Collapsible } Collapsible
2431 */
@@ -401,7 +408,7 @@ function execOperation(type, action, url, $target, name) {
401408 editorManager . onupdate ( "delete-file" ) ;
402409 editorManager . emit ( "update" , "delete-file" ) ;
403410 } else {
404- if ( url . startsWith ( "content://com.termux.documents/tree/" ) ) {
411+ if ( isTerminalSafUri ( url ) ) {
405412 const fs = fsOperation ( url ) ;
406413 const entries = await fs . lsDir ( ) ;
407414 if ( entries . length === 0 ) {
@@ -436,10 +443,7 @@ function execOperation(type, action, url, $target, name) {
436443 }
437444
438445 async function renameFile ( ) {
439- if (
440- url . startsWith ( "content://com.termux.documents/tree/" ) &&
441- ! helpers . isFile ( type )
442- ) {
446+ if ( isTermuxSafUri ( url ) && ! helpers . isFile ( type ) ) {
443447 alert ( strings . warning , strings [ "rename not supported" ] ) ;
444448 return ;
445449 }
@@ -455,11 +459,8 @@ function execOperation(type, action, url, $target, name) {
455459 const fs = fsOperation ( url ) ;
456460 let newUrl ;
457461
458- if (
459- url . startsWith ( "content://com.termux.documents/tree/" ) &&
460- helpers . isFile ( type )
461- ) {
462- // Special handling for Termux content files
462+ if ( isTermuxSafUri ( url ) && helpers . isFile ( type ) ) {
463+ // Special handling for Termux SAF content files
463464 const newFilePath = Url . join ( Url . dirname ( url ) , newName ) ;
464465 const content = await fs . readFile ( ) ;
465466 await fsOperation ( Url . dirname ( url ) ) . createFile ( newName , content ) ;
@@ -581,11 +582,8 @@ function execOperation(type, action, url, $target, name) {
581582 }
582583 let newUrl ;
583584 if ( clipBoard . action === "cut" ) {
584- // Special handling for Termux SAF folders - move manually due to SAF limitations
585- if (
586- clipBoard . url . startsWith ( "content://com.termux.documents/tree/" ) &&
587- IS_DIR
588- ) {
585+ // Special handling for SAF folders backed by terminal providers - move manually due to SAF limitations
586+ if ( isTerminalSafUri ( clipBoard . url ) && IS_DIR ) {
589587 const moveRecursively = async ( sourceUrl , targetParentUrl ) => {
590588 const sourceFs = fsOperation ( sourceUrl ) ;
591589 const sourceName = Url . basename ( sourceUrl ) ;
0 commit comments