Skip to content

Commit

Permalink
fix: open existing tab if possible
Browse files Browse the repository at this point in the history
close #98
  • Loading branch information
Vinzent03 committed Feb 4, 2023
1 parent d6edfbd commit e98b03d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,11 @@ export default class Handlers {
async handleOpen(parameters: Parameters) {
let fileIsAlreadyOpened = false;
app.workspace.iterateAllLeaves(leaf => {
if (leaf.view.file?.path === parameters.filepath && leaf.width > 0) {
if (leaf.view.file?.path === parameters.filepath) {
if (fileIsAlreadyOpened && leaf.width == 0) return;
fileIsAlreadyOpened = true;
app.workspace.setActiveLeaf(leaf, true, true);

app.workspace.setActiveLeaf(leaf, { focus: true });
}
});
if (fileIsAlreadyOpened) {
Expand Down

0 comments on commit e98b03d

Please sign in to comment.