From dcc972dbfe301da1df36c36eaff51ee3b843adaf Mon Sep 17 00:00:00 2001 From: lazyloong <2950449004@qq.com> Date: Sun, 28 Apr 2024 17:07:38 +0800 Subject: [PATCH] feat: #47 --- manifest.json | 2 +- src/modal/fileModal.ts | 15 ++++++++++++++- src/settingTab.ts | 17 ++++++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index b78d1da..c4d2a38 100644 --- a/manifest.json +++ b/manifest.json @@ -5,5 +5,5 @@ "author": "lazyloong", "minAppVersion": "1.0.0", - "version": "2.22.0" + "version": "2.22.1" } diff --git a/src/modal/fileModal.ts b/src/modal/fileModal.ts index 13ac6a1..e9b6f2e 100644 --- a/src/modal/fileModal.ts +++ b/src/modal/fileModal.ts @@ -34,6 +34,7 @@ export type Item = FileItem | AliasItem | UnresolvedLinkItem | LinkItem; export interface MatchData extends uMatchData { usePath?: boolean; ignore?: boolean; + history?: boolean; } export default class FuzzyFileModal extends FuzzyModal { @@ -147,6 +148,7 @@ export default class FuzzyFileModal extends FuzzyModal { score: 0, range: null, usePath: false, + history: true, })); return lastOpenFiles; } else { @@ -178,7 +180,7 @@ export default class FuzzyFileModal extends FuzzyModal { 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]); @@ -277,6 +279,17 @@ export default class FuzzyFileModal extends FuzzyModal { 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) { diff --git a/src/settingTab.ts b/src/settingTab.ts index 1fa02ee..0ac6211 100644 --- a/src/settingTab.ts +++ b/src/settingTab.ts @@ -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("只显示这些后缀的附件") @@ -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; @@ -375,6 +389,7 @@ export const DEFAULT_SETTINGS: FuzyyChinesePinyinSettings = { showAllFileTypes: false, showUnresolvedLink: false, quicklySelectHistoryFiles: false, + quicklySelectHistoryFilesHint: "asdfjklgh", attachmentExtensions: [ "bmp", "png",