Skip to content

Commit

Permalink
feat: show modal on tab key release
Browse files Browse the repository at this point in the history
close #25
  • Loading branch information
Vinzent03 committed Aug 21, 2023
1 parent 53a1bdb commit f598eaa
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,9 @@ export default class CycleThroughPanes extends Plugin {
name: "Go to previous tab",
callback: async () => {
this.setLeaves();
const leaves = this.leaves;
if (this.settings.showModal) {
this.modal = new GeneralModal(leaves, this);
this.leafIndex = await this.modal.open();
} else {
this.leafIndex = this.leafIndex + 1;
if (this.leafIndex >= this.leaves.length)
this.leafIndex = 0;
}
const leaf = leaves[this.leafIndex];

this.leafIndex = (this.leafIndex + 1) % this.leaves.length;
const leaf = this.leaves[this.leafIndex];

if (leaf) {
this.queueFocusLeaf(leaf);
Expand All @@ -209,15 +202,10 @@ export default class CycleThroughPanes extends Plugin {
name: "Go to next tab",
callback: async () => {
this.setLeaves();
const leaves = this.leaves;
if (this.settings.showModal) {
this.modal = new GeneralModal(leaves, this);
this.leafIndex = await this.modal.open();
} else {
this.leafIndex = this.leafIndex - 1;
if (this.leafIndex < 0) this.leafIndex = leaves.length - 1;
}
const leaf = leaves[this.leafIndex];
this.leafIndex =
(this.leafIndex - 1 + this.leaves.length) %
this.leaves.length;
const leaf = this.leaves[this.leafIndex];

if (leaf) {
this.queueFocusLeaf(leaf);
Expand Down Expand Up @@ -290,6 +278,17 @@ export default class CycleThroughPanes extends Plugin {

this.modal = undefined;
}

if (
e.code == "Tab" &&
this.ctrlPressedTimestamp &&
this.settings.showModal &&
!this.modal &&
this.leaves
) {
this.modal = new GeneralModal(this.leaves, this);
this.modal.open();
}
}

onunload() {
Expand Down

0 comments on commit f598eaa

Please sign in to comment.