Skip to content

Commit

Permalink
feat: #47
Browse files Browse the repository at this point in the history
  • Loading branch information
lazyloong committed Apr 28, 2024
1 parent d905d82 commit dcc972d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Expand Up @@ -5,5 +5,5 @@
"author": "lazyloong",

"minAppVersion": "1.0.0",
"version": "2.22.0"
"version": "2.22.1"
}
15 changes: 14 additions & 1 deletion src/modal/fileModal.ts
Expand Up @@ -34,6 +34,7 @@ export type Item = FileItem | AliasItem | UnresolvedLinkItem | LinkItem;
export interface MatchData<T = Item> extends uMatchData<T> {
usePath?: boolean;
ignore?: boolean;
history?: boolean;
}

export default class FuzzyFileModal extends FuzzyModal<Item> {
Expand Down Expand Up @@ -147,6 +148,7 @@ export default class FuzzyFileModal extends FuzzyModal<Item> {
score: 0,
range: null,
usePath: false,
history: true,
}));
return lastOpenFiles;
} else {
Expand Down Expand Up @@ -178,7 +180,7 @@ export default class FuzzyFileModal extends FuzzyModal<Item> {
return items;
case 2:
let index = max([
"asdfghjkl;".indexOf(query[1]),
"asdfjklgh".indexOf(query[1]),
"1234567890".indexOf(query[1]),
]);
index = min([index, items.length - 1]);
Expand Down Expand Up @@ -277,6 +279,17 @@ export default class FuzzyFileModal extends FuzzyModal<Item> {
if (matchData.item.file) renderer.setNote(matchData.item.path);
if (matchData.usePath) renderer.setToHighlightEl("note");
if (matchData.ignore) renderer.setIgnore();
if (matchData.history && this.plugin.settings.file.quicklySelectHistoryFiles) {
let auxEl = el.createEl("span", { cls: "fz-suggestion-aux" });
auxEl.createEl("kbd", {
cls: "suggestion-command",
text: this.plugin.settings.file.quicklySelectHistoryFilesHint[
this.getEmptyInputSuggestions().findIndex(
(p) => p.item.path == matchData.item.path
)
],
});
}
renderer.render(matchData);

if (this.plugin.settings.file.showTags && matchData.item.file) {
Expand Down
17 changes: 16 additions & 1 deletion src/settingTab.ts
Expand Up @@ -146,15 +146,28 @@ export default class SettingTab extends PluginSettingTab {
);
new Setting(this.containerEl)
.setName("快速选择历史文件")
.setDesc("输入栏为空时,空格加 asdfgh... 或 12345... 快速选择历史文件")
.setDesc("输入栏为空时,空格加 asdf... 或 1234... 快速选择历史文件")
.addToggle((cb) => {
cb.setValue(this.plugin.settings.file.quicklySelectHistoryFiles).onChange(
async (value) => {
this.plugin.settings.file.quicklySelectHistoryFiles = value;
await this.plugin.saveSettings();
this.display();
}
);
});
if (this.plugin.settings.file.quicklySelectHistoryFiles)
new Setting(this.containerEl).setName("快速选择历史文件提示").addDropdown((cb) => {
cb.addOptions({
asdfjklgh: "asdfjklgh",
"1234567890": "1234567890",
})
.setValue(this.plugin.settings.file.quicklySelectHistoryFilesHint)
.onChange(async (value) => {
this.plugin.settings.file.quicklySelectHistoryFilesHint = value;
await this.plugin.saveSettings();
});
});
new Setting(this.containerEl)
.setName("附件后缀")
.setDesc("只显示这些后缀的附件")
Expand Down Expand Up @@ -345,6 +358,7 @@ export interface FuzyyChinesePinyinSettings {
showTags: boolean;
searchWithTag: boolean;
quicklySelectHistoryFiles: boolean;
quicklySelectHistoryFilesHint: string;
keyEnter: keyof typeof openFileKeyMap;
keyCtrlEnter: keyof typeof openFileKeyMap;
keyAltEnter: keyof typeof openFileKeyMap;
Expand Down Expand Up @@ -375,6 +389,7 @@ export const DEFAULT_SETTINGS: FuzyyChinesePinyinSettings = {
showAllFileTypes: false,
showUnresolvedLink: false,
quicklySelectHistoryFiles: false,
quicklySelectHistoryFilesHint: "asdfjklgh",
attachmentExtensions: [
"bmp",
"png",
Expand Down

0 comments on commit dcc972d

Please sign in to comment.