Skip to content

Commit

Permalink
fix: 移动文件命令对文件树中被选择的文件无效
Browse files Browse the repository at this point in the history
  • Loading branch information
lazyloong committed Oct 19, 2024
1 parent 49a3d22 commit a45ac9f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"author": "lazyloong",

"minAppVersion": "1.0.0",
"version": "2.27.4"
"version": "2.27.5"
}
29 changes: 17 additions & 12 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ export default class ThePlugin extends Plugin {
let files = this.fileExplorerHotkey.getFiles();
let file = this.app.workspace.getActiveFile();
if (checking) return Boolean(file) || files.length > 0;
if (this.fileExplorerHotkey.working && files.length > 0)
this.folderModal.openWithFiles(files);
if (files.length > 0) this.folderModal.openWithFiles(files);
else if (file) this.folderModal.open();
},
});
Expand Down Expand Up @@ -227,25 +226,31 @@ class FileExplorerHotkey {
app: App;
leaf: WorkspaceLeaf;
view: View;
working = false;
constructor(app: App, plugin: ThePlugin) {
this.plugin = plugin;
this.app = app;
let leafs = this.app.workspace.getLeavesOfType("file-explorer");
if (leafs.length == 0) return;
this.leaf = leafs[0];
this.working = true;
this.view = this.leaf.view;
this.getView();
}
getFiles(): TFile[] {
// @ts-ignore
if (this.view === undefined || this.view.tree === undefined) {
// core plugin `Files` is disabled
return [];
if (!this.viewIsWorkable()) {
this.getView();
if (!this.viewIsWorkable()) return [];
}
// @ts-ignore
return Array.from(this.view.tree.selectedDoms).map((p: { file: TFile }) => p.file);
}
getView(): View | undefined {
let leaf = this.app.workspace.getLeavesOfType("file-explorer");
if (leaf.length != 0) {
this.leaf = leaf[0];
this.view = this.leaf.view;
}
return this.view;
}
viewIsWorkable(): boolean {
// @ts-ignore
return Boolean(this.view?.tree?.selectedDoms);
}
}

class IndexManager extends Array<PinyinIndex<any>> {
Expand Down

0 comments on commit a45ac9f

Please sign in to comment.