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

fix: detect sections correctly #175

Merged
merged 1 commit into from
Jun 29, 2024

Conversation

luckman212
Copy link
Contributor

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
Copy link
Contributor Author

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

src/block_utils.ts Outdated Show resolved Hide resolved
src/block_utils.ts Outdated Show resolved Hide resolved
@luckman212 luckman212 changed the title Small fix for block_utils.ts Small fixes for block_utils.ts Jun 22, 2024
@luckman212
Copy link
Contributor Author

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

@luckman212
Copy link
Contributor Author

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

@Vinzent03
Copy link
Owner

LGTM thanks for your contribution!

@Vinzent03 Vinzent03 merged commit a869f27 into Vinzent03:master Jun 29, 2024
@Vinzent03 Vinzent03 changed the title Small fixes for block_utils.ts fix: detect sections correctly Jun 29, 2024
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

Successfully merging this pull request may close these issues.

2 participants