Vinzent03 / obsidian-advanced-uri

Advanced modes for Obsidian URI
MIT License
765 stars 44 forks source link

fix: detect sections correctly #175

Closed luckman212 closed 5 months ago

luckman212 commented 5 months ago

Abstract

I noticed today that I was getting JS errors in the console when trying to use the Copy URI for current block command under certain conditions:

A section with no text in it e.g.

# Section I haven't written yet

{cursor here} <==

# Another section
...

image

Cursor at very end of file

image

File empty / contains no sections

image

Here's a PR I came up with that resolves these cases. I did some testing and seems fine, but please comment with any more changes needed.

Screenshots from this fork

empty section

end of file

empty file

luckman212 commented 5 months ago

Anyone who wants to test without setting up the nodeJS dev environment can grab the compiled main.js here and replace the one in .obsidian/plugins

main.js.zip

luckman212 commented 5 months ago

@Vinzent03 I squashed the multiple commits, and pushed an updated version. Can you please take a look when you have a moment? 🙏

luckman212 commented 5 months ago

N.B. still working after Electron 30 / Obsidian 1.6.5 update

Vinzent03 commented 5 months ago

LGTM thanks for your contribution!