obsidian-remember-cursor-position icon indicating copy to clipboard operation
obsidian-remember-cursor-position copied to clipboard

fix: Do not jump the cursor when having documents already open

Open akinasu1932 opened this issue 1 year ago • 3 comments

I am using this fix locally for Issue #54, but am looking for a better fix.

The outline is as follows.

  • Get a combined string of id and filename in a list for all opened leafs.
  • If a newly activated leaf is included in the list, abort the process.

However, id property is not exposed.

https://docs.obsidian.md/Reference/TypeScript+API/WorkspaceLeaf

I look forward to better suggestions from contributors.

akinasu1932 avatar Feb 18 '24 08:02 akinasu1932

This looks pretty smart. Thank you for your effort! I'm not familiar enough with the API to add more functional input I'm afraid. But am I correct that file-open is the event that is triggered for both the first opening of a file and focussing a file (in a pane)?

Does the event not bring any meta data to the context of event? Seems like there should be some way to abort based on that. The documentation doesn't actually document that much it looks like :/

SerafinDinges avatar Mar 28 '24 16:03 SerafinDinges

Can I merge this fix if there is no better solution?

dy-sh avatar Apr 21 '24 17:04 dy-sh

@SerafinDinges Thank you. I have looked for the metadata you suggested but could not find it.

@dy-sh Perhaps the current implementation will cause minor unintended behavior due to this.lastLoadedFileName not being updated. I have looked for a workaround, but it seems to be difficult to find right away.

In response to the discussion in Issue #54, I removed the Draft notation. Please merge if you are okay with this.

akinasu1932 avatar Apr 29 '24 02:04 akinasu1932

Merged. Thank you for the fix!

dy-sh avatar May 31 '24 00:05 dy-sh

Tested it in 1.0.9 and it appears to be working.

  • Side by Side on the same document (and different scroll positions) ✅
  • Side by Side with different documents ✅
  • Opening the same document in multiple tabs ✅

Great work and so happy that this is now integrated. I had disabled this plugin because of this missing.

chrisspiegl avatar Jun 12 '24 06:06 chrisspiegl

Yes really appreciate the effort. Thank you so much!

SerafinDinges avatar Jun 12 '24 08:06 SerafinDinges