Skip to content

Commit 65248ba

Browse files
Fix renaming current Termux URI file whilst viewing/editing it (#1347)
Co-authored-by: 1Code-JS <196545093+1Code-JS@users.noreply.github.com>
1 parent d84508f commit 65248ba

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/lib/commands.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,17 @@ export default {
353353
if (uri) {
354354
const fs = fsOperation(uri);
355355
try {
356-
const newUri = await fs.renameTo(newname);
356+
let newUri;
357+
if (uri.startsWith("content://com.termux.documents/tree/")) {
358+
// Special handling for Termux content files
359+
const newFilePath = Url.join(Url.dirname(url), newname);
360+
const content = await fs.readFile();
361+
await fsOperation(Url.dirname(url)).createFile(newname, content);
362+
await fs.delete();
363+
newUrl = newFilePath;
364+
} else {
365+
newUri = await fs.renameTo(newname);
366+
}
357367
const stat = await fsOperation(newUri).stat();
358368

359369
newname = stat.name;

0 commit comments

Comments
 (0)