Skip to content

Commit

Permalink
fix: #70
Browse files Browse the repository at this point in the history
  • Loading branch information
lazyloong committed Dec 5, 2024
1 parent 7a154c2 commit aceb171
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 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.10"
"version": "2.27.11"
}
39 changes: 18 additions & 21 deletions src/modal/fileModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,17 @@ export default class FileModal extends FuzzyModal<Item> {
key: "Enter",
func: async (e: KeyboardEvent) => {
e.preventDefault();
const modKey = e.ctrlKey || e.metaKey;
const altKey = e.altKey;
const shiftKey = e.shiftKey;
if (shiftKey && this.inputEl.value == "") return;
this.close();

let leaf: WorkspaceLeaf;
let getKey = (key: keyof typeof openFileKeyMap) =>
openFileKeyMap[this.plugin.settings.file[key]];
if (modKey && altKey) leaf = getKey("keyCtrlAltEnter")();
else if (modKey) leaf = getKey("keyCtrlEnter")();
else if (altKey) leaf = getKey("keyAltEnter")();
else leaf = getKey("keyEnter")();
if (shiftKey) {
let newFile = await createFile(this.inputEl.value);
const leaf = this.getLeaf(e);
const newFile = await createFile(this.inputEl.value);
leaf.openFile(newFile);
} else {
let item = this.getChoosenItem();
openItem(leaf, item);
const matchData = this.getChoosenMatchData();
this.onChooseSuggestion(matchData, e);
}
},
};
Expand Down Expand Up @@ -335,18 +327,11 @@ export default class FileModal extends FuzzyModal<Item> {
this.resolve(matchData.item);
return;
}

if (matchData.score == -1 || matchData.item.type == "unresolvedLink")
matchData.item.file = await this.getChoosenItemFile(matchData);

const modKey = e.ctrlKey || e.metaKey;
const altKey = e.altKey;
let leaf: WorkspaceLeaf;
let getKey = (key: keyof typeof openFileKeyMap) =>
openFileKeyMap[this.plugin.settings.file[key]];
if (modKey && altKey) leaf = getKey("keyCtrlAltEnter")();
else if (modKey) leaf = getKey("keyCtrlEnter")();
else if (altKey) leaf = getKey("keyAltEnter")();
else leaf = getKey("keyEnter")();
const leaf = this.getLeaf(e);
openItem(leaf, matchData.item);
}
onNoSuggestion(): void {
Expand All @@ -362,6 +347,18 @@ export default class FileModal extends FuzzyModal<Item> {
? await createFile(matchData.item.name)
: matchData.item.file;
}
getLeaf(e: MouseEvent | KeyboardEvent): WorkspaceLeaf {
const modKey = e.ctrlKey || e.metaKey;
const altKey = e.altKey;
let leaf: WorkspaceLeaf;
let getKey = (key: keyof typeof openFileKeyMap) =>
openFileKeyMap[this.plugin.settings.file[key]];
if (modKey && altKey) leaf = getKey("keyCtrlAltEnter")();
else if (modKey) leaf = getKey("keyCtrlEnter")();
else if (altKey) leaf = getKey("keyAltEnter")();
else leaf = getKey("keyEnter")();
return leaf;
}
}

// If there is only one leaf, create a new split and return it.
Expand Down

0 comments on commit aceb171

Please sign in to comment.