czottmann / obsidian-mononote

An Obsidian plugin that ensures each note occupies only one tab. If a note is already open, its existing tab will be focussed instead of opening the same file in the current tab.
https://obsidian.md/plugins?id=zottmann
MIT License
75 stars 2 forks source link

[BUG] Mononote 1.2.1 won't switch when normal click (left click) in file explorer #27

Closed l2eused closed 1 month ago

l2eused commented 1 month ago

step to reproduce:

actual behavior: B note in tab will switch to A note tab and switch back...

expected behavior: it should switch to A note tab and shouldn't switch it back.

https://github.com/czottmann/obsidian-mononote/assets/94383254/e8d1c4d9-f9d8-4fca-885b-8fc955a1242a

platforms: windows 10 obsidian 1.6.3 mononote 1.2.1

this is all my plugin...

l2eused commented 1 month ago

for middle click is fine.

l2eused commented 1 month ago

I think it related to this

so the problem is when I load N1 that already open in T2, it should switch to T2 and remains old note in T1. but in my case, tab isn't focused to T2 and loop T1 -> T2 -> T1

l2eused commented 1 month ago

more info: this issue also happens when I left click in wikilinks to...

czottmann commented 1 month ago

Thanks for the report, @l2eused!

I'm quite sure it's a race condition. The way Obsidian signals tab switching internally made it necessary to implement some time-based guess work in Mononote. In a nutshell: For some operations, Mononote simply waits for 100ms before applying its own tab switching rules, to give Obsidian time to work things out. If it isn't enough time, then Mononote will switch tabs from T1 to T2 before Obsidian is done, and once Obsidian is done, the app itself switches back to T1.

I suspected that depending on your machine and your vault size, 100ms might not be enough time. Raising that number too much, however, might be annoying for people with fast machines and small vaults – so I tried to find a good middle ground.

I'll add a settings page in the next release that lets you configure your sweet spot, which should mitigate the issue you're seeing!

czottmann commented 1 month ago

Give Release 1.2.2 · czottmann/obsidian-mononote a spin, and try increasing the delay configuration:

CleanShot 2024-06-24 at 14 31 43@2x

If that doesn't do the trick, please re-open this ticket! 🖖🏼

l2eused commented 1 month ago

Yes, that work for me. I just realize that I only have this problem when I tried to switch to large note that have many embed and online image. so I increase delay to 300ms and it work fine now, little of delay but I can deal with this and it much better than loop switch...

btw, thanks for really fast reply and fix!