Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FilePath + Line navigation does not work when Obsidian is in Reading viewmode #91

Closed
gplusplus314 opened this issue Nov 23, 2022 · 16 comments

Comments

@gplusplus314
Copy link

Great plugin! I'm working on integrating this with Obsidian.nvim and have run into a snag.

This URI works perfectly when Obsidian is already in the Editing viewmode:

obsidian://advanced-uri?vault=main&filepath=test_note.md&line=42

However, if Obsidian is already in the Reading viewmode, the file does open successfully, but it doesn't scroll to the correct position in the file. It just stays wherever it is, or otherwise stays at the top if the file wasn't open to begin with.

Thanks for putting this plugin together!

@Vinzent03
Copy link
Owner

I'm switching to source mode now correctly.

@gplusplus314
Copy link
Author

Thanks for the speedy response, wow!

This is a pretty decent workaround. But is there any chance we could make it work while remaining in the Reading/viewing mode? The issue with the change is that it won't respect a user's current view state. It does scroll as expected, though, so that's good.

@Vinzent03
Copy link
Owner

I see, but I don't know if that's possible.

@gplusplus314
Copy link
Author

OK, no worries. This is good enough!

@pidgeon777
Copy link

Hello everyone, any update about this issue?

I see it is possible to specify view mode with URI, see:

https://vinzent03.github.io/obsidian-advanced-uri/concepts/navigation_parameters

But how can we exactly specify the view mode in the obsidian://advanced-uri?vault=%s&filepath=%s&line=%i URL, also?

@pidgeon777
Copy link

Would it be possible to add a setting to specify the default view mode and open mode to the already existing settings?

image

@Vinzent03
Copy link
Owner

@pidgeon777 You should be able to specify the line for live and source view mode.

@pidgeon777
Copy link

@Vinzent03 the fact is that unfortunately, I don't know how to specify the viewmode values when doing the URI request. Also, could I specify the preview mode?

Finally, what about doing something as follows, if the issue with preview mode still exists:

  1. Receive the URI request
  2. Go to the wished line in live or source mode
  3. Automatically switch to the preview mode.

This could be done plugin-side in two ways.

  1. Add an option to enable an automatic switch to the preview mode when the URI request is received.
  2. Switch to the preview mode only when the URI contains the viewmode=preview parameter.

What do you think?

Still, it would be much much better if the currently active mode (live/source/preview) was preserved when the URI request is received.

@Vinzent03
Copy link
Owner

viewmode is just a parameter like filepath. An example is obsidian://advanced-uri?vault=%s&filepath=%s&line=10&viewmode=live. You can use the preview mode, but it currently doesn't work with the parameter line.

Switching temporarily to another mode is actually a good idea.

@pidgeon777
Copy link

Switching temporarily to another mode is actually a good idea.

Eventually, this switch could be enabled in the Obsidian plugin panel with a new option, if users want to preserve the old behaviour until the preview mode will finally work with the line parameter.

I could beta-test your implementation once if done if you wish.

@pidgeon777
Copy link

viewmode is just a parameter like filepath. An example is obsidian://advanced-uri?vault=%s&filepath=%s&line=10&viewmode=live. You can use the preview mode, but it currently doesn't work with the parameter line.

Switching temporarily to another mode is actually a good idea.

Hello @Vinzent03, any update?

@Vinzent03
Copy link
Owner

Thanks for the reminder, available in new release!

@pidgeon777
Copy link

pidgeon777 commented Apr 3, 2023

I tested but unfortunately doesn't seem to work, my test:

  1. Open the Notes.md file.

  2. Move to line x in preview mode.

  3. Execute:

obsidian://advanced-uri?vault=VaultName&filepath=c%3A%5CPath%5CNotes.md&line=117&viewmode=preview

As a result, Obsidian switches very quickly to line 117 (allegedly in edit mode), and then it goes back to line x in preview mode.

@pidgeon777
Copy link

pidgeon777 commented Apr 3, 2023

Now, don't know what happened I think after the plugin update, it also reports:

image

When executing:

obsidian://advanced-uri?vault=VaultName&filepath=c%3A%5CPath%5CNotes.md&line=117

no matter if viewmode is specified or not.

EDIT: This happens when the file is not already opened in Obsidian. If the file is already opened, the cursor moves but that black warning popup still appears (and the scroll is still done at the wrong position as described in my previous post).

@Vinzent03
Copy link
Owner

After doing some more test, I notice it's not always working. Sometimes it does, sometimes not. I found no way to solve this, so I'm for now not supporting it.

@pidgeon777
Copy link

Hello, I would like to ask if this problem still persists, or it has been fixed

Greetings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants