mirror of
https://github.com/quorafind/Obsidian-Float-Search.git
synced 2026-07-22 07:30:25 +00:00
feat: support double tab to focus on file
This commit is contained in:
parent
3147cb28c7
commit
9f2d6d2884
1 changed files with 27 additions and 4 deletions
|
|
@ -276,6 +276,8 @@ class FloatSearchModal extends Modal {
|
|||
private cb: (state: any)=> void;
|
||||
private state: any;
|
||||
|
||||
private fileState: any;
|
||||
|
||||
private searchCtnEl: HTMLElement;
|
||||
private instructionsEl: HTMLElement;
|
||||
private fileEl: HTMLElement;
|
||||
|
|
@ -561,9 +563,21 @@ class FloatSearchModal extends Modal {
|
|||
active: false,
|
||||
eState: state
|
||||
});
|
||||
setTimeout(() => {
|
||||
(this.searchLeaf.view as SearchView).searchComponent.inputEl.focus();
|
||||
}, 0);
|
||||
|
||||
if(this.fileState?.match?.matches[0] === state.match?.matches[0] && state && this.fileState) {
|
||||
setTimeout(()=>{
|
||||
if(this.fileLeaf) {
|
||||
app.workspace.setActiveLeaf(this.fileLeaf, {
|
||||
focus: true,
|
||||
});
|
||||
}
|
||||
}, 0);
|
||||
} else {
|
||||
this.fileState = state;
|
||||
setTimeout(() => {
|
||||
(this.searchLeaf.view as SearchView).searchComponent.inputEl.focus();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -575,11 +589,19 @@ class FloatSearchModal extends Modal {
|
|||
if(e.ctrlKey && e.key === "g") {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
(this.searchLeaf.view as SearchView).searchComponent.inputEl.focus();
|
||||
}
|
||||
|
||||
if(e.key === "Tab" && e.ctrlKey) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
(this.searchLeaf.view as SearchView).searchComponent.inputEl.focus();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const [createdLeaf, embeddedView] = spawnLeafView(this.plugin, this.fileEl);
|
||||
this.fileLeaf = createdLeaf;
|
||||
this.fileEmbeddedView = embeddedView;
|
||||
|
|
@ -589,6 +611,7 @@ class FloatSearchModal extends Modal {
|
|||
active: false,
|
||||
eState: state
|
||||
});
|
||||
this.fileState = state;
|
||||
|
||||
(this.searchLeaf.view as SearchView).searchComponent.inputEl.focus();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue