Skip to content

Commit 68b53b0

Browse files
committed
Fix "move file" command
1 parent 121a21a commit 68b53b0

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "Quick Explorer",
44
"author": "PJ Eby",
55
"authorUrl": "https://github.com/pjeby",
6-
"version": "0.2.12",
6+
"version": "0.2.13",
77
"description": "Perform file explorer operations (and see your current file path) from the title bar, using the mouse or keyboard",
88
"minAppVersion": "1.5.8",
99
"isDesktopOnly": true

src/ContextMenu.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ import { Keymap, Notice, TAbstractFile, TFile, TFolder, View } from "./obsidian.
22
import { PopupMenu, MenuParent } from "./menus.ts";
33

44
declare module "obsidian" {
5+
interface _Commands {
6+
executeCommandById(id: string): void
7+
}
58
interface App {
9+
commands: _Commands
610
setAttachmentFolder(folder: TFolder): void
711
internalPlugins: {
812
plugins: {
913
"file-explorer": {
1014
enabled: boolean
1115
instance: {
1216
revealInFolder(file: TAbstractFile): void
13-
moveFileModal: Modal & {
14-
setCurrentFile(file: TAbstractFile): void
15-
}
1617
}
1718
}
1819
}

src/FolderMenu.ts

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TAbstractFile, TFile, TFolder, Keymap, Notice, HoverParent, debounce, WorkspaceSplit, HoverPopover, FileView, MarkdownView } from "./obsidian.ts";
1+
import { TAbstractFile, TFile, TFolder, Keymap, Notice, HoverParent, debounce, WorkspaceSplit, HoverPopover, FileView, MarkdownView, Modal } from "./obsidian.ts";
22
import { Breadcrumb, hoverSource, startDrag } from "./Explorer.tsx";
33
import { PopupMenu, MenuParent, SearchableMenuItem } from "./menus.ts";
44
import { ContextMenu } from "./ContextMenu.ts";
@@ -152,9 +152,20 @@ export class FolderMenu extends PopupMenu implements HoverParent {
152152
return false;
153153
}
154154
this.rootMenu().hide();
155-
const modal = explorerPlugin.instance.moveFileModal;
156-
modal.setCurrentFile(this.currentFile());
157-
modal.open()
155+
const file = this.currentFile();
156+
const rm = around(Modal.prototype, {
157+
open(next) {
158+
return function () {
159+
rm()
160+
if (this.files && Array.isArray(this.files) && this.files.length && this.files[0] instanceof TFile) {
161+
this.files = [file]
162+
}
163+
return next.call(this)
164+
}
165+
}
166+
})
167+
this.app.commands.executeCommandById("file-explorer:move-file")
168+
rm()
158169
return false;
159170
}
160171

versions.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"0.2.12": "1.5.8",
2+
"0.2.13": "1.5.8",
33
"0.2.8": "0.15.9",
44
"0.1.41": "0.15.9",
55
"0.1.37": "0.14.5",

0 commit comments

Comments
 (0)