diff --git a/src/events/handleRename.ts b/src/events/handleRename.ts index a8d2f5e..c509452 100644 --- a/src/events/handleRename.ts +++ b/src/events/handleRename.ts @@ -88,7 +88,7 @@ export function handleFileRename(file: TFile, oldPath: string, plugin: FolderNot excludedFolder.disableSync = true; updateExcludedFolder(plugin, excludedFolder, excludedFolder); } - return plugin.app.vault.rename(file, oldPath).then(() => { + return plugin.app.fileManager.renameFile(file, oldPath).then(() => { if (!excludedFolder) { return; } if (!excludedFolderExisted) { deleteExcludedFolder(plugin, excludedFolder); @@ -147,8 +147,8 @@ async function renameFolderOnFileRename(file: TFile, oldPath: string, oldFolder: } } if (plugin.app.vault.getAbstractFileByPath(newFolderPath) || plugin.app.vault.getAbstractFileByPath(newFolderName || '')) { - await plugin.app.vault.rename(file, oldPath); + await plugin.app.fileManager.renameFile(file, oldPath); return new Notice('A folder with the same name already exists'); } - await plugin.app.vault.rename(oldFolder, newFolderPath); + plugin.app.fileManager.renameFile(oldFolder, newFolderPath); } diff --git a/src/functions/folderNoteFunctions.ts b/src/functions/folderNoteFunctions.ts index 5c6080c..3997b5d 100644 --- a/src/functions/folderNoteFunctions.ts +++ b/src/functions/folderNoteFunctions.ts @@ -73,7 +73,7 @@ tags: [excalidraw] file = await plugin.app.vault.create(path, content); } else { file = existingNote; - plugin.app.vault.rename(existingNote, path); + plugin.app.fileManager.renameFile(existingNote, path); } if (openFile) { await leaf.openFile(file); @@ -112,7 +112,7 @@ export async function turnIntoFolderNote(plugin: FolderNotesPlugin, file: TFile, updateExcludedFolder(plugin, excludedFolder, excludedFolder); } const newPath = `${folder.path}/${folder.name} (${file.stat.ctime.toString().slice(10) + Math.floor(Math.random() * 1000)}).${extension}`; - plugin.app.vault.rename(folderNote, newPath).then(() => { + plugin.app.fileManager.renameFile(folderNote, newPath).then(() => { if (!excludedFolder) { return; } if (!excludedFolderExisted) { deleteExcludedFolder(plugin, excludedFolder); @@ -136,7 +136,7 @@ export async function turnIntoFolderNote(plugin: FolderNotesPlugin, file: TFile, } } - await plugin.app.vault.rename(file, path); + await plugin.app.fileManager.renameFile(file, path); plugin.addCSSClassToTitleEL(path, 'is-folder-note', true); plugin.addCSSClassToTitleEL(folder.path, 'has-folder-note'); } diff --git a/src/modals/FolderName.ts b/src/modals/FolderName.ts index e822e46..77f6c1c 100644 --- a/src/modals/FolderName.ts +++ b/src/modals/FolderName.ts @@ -27,7 +27,7 @@ export default class FolderNameModal extends Modal { .onChange(async (value) => { if (value.trim() !== '') { if (!this.app.vault.getAbstractFileByPath(this.folder.path.slice(0, this.folder.path.lastIndexOf('/') + 1) + value.trim())) { - this.app.vault.rename(this.folder, this.folder.path.slice(0, this.folder.path.lastIndexOf('/') + 1) + value.trim()); + this.plugin.app.fileManager.renameFile(this.folder, this.folder.path.slice(0, this.folder.path.lastIndexOf('/') + 1) + value.trim()); } } }) diff --git a/src/settings/SettingsTab.ts b/src/settings/SettingsTab.ts index 1aadef8..b2f9024 100644 --- a/src/settings/SettingsTab.ts +++ b/src/settings/SettingsTab.ts @@ -189,7 +189,7 @@ export class SettingsTab extends PluginSettingTab { const folderNoteName = newTemplate.replace('{{folder_name}}', folder.name) const newPath = `${folder.path}/${folderNoteName}.${folderNote.extension}`; if (this.plugin.app.vault.getAbstractFileByPath(newPath)) { continue } - this.app.vault.rename(folderNote, newPath); + this.plugin.app.fileManager.renameFile(folderNote, newPath); } } this.plugin.settings.folderNoteName = newTemplate; @@ -210,13 +210,13 @@ export class SettingsTab extends PluginSettingTab { } else { newPath = `${this.plugin.getFolderPathFromString(file.path)}/${folderNote.name}`; } - this.app.vault.rename(folderNote, newPath); + this.plugin.app.fileManager.renameFile(folderNote, newPath); } else if (this.plugin.settings.storageLocation === 'insideFolder') { if (this.plugin.getFolderPathFromString(folderNote.path) === file.path) { return; } else { const newPath = `${file.path}/${folderNote.name}`; - this.app.vault.rename(folderNote, newPath); + this.plugin.app.fileManager.renameFile(folderNote, newPath); } } }