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

Add ObsidianSetCheckbox (Attempt) #802

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

t-eckert
Copy link

Hi @epwalsh, I just started using your plugin today. It's fantastic!

I wanted to map an ObsidianSetCheckbox x to check off items for my day. Toggle is great, but it's not specifically what I want to use.

This is my best attempt at adding the feature after I saw that #781 was asking for the same functionality.

I'm definitely missing something. I can run the command, but it doesn't do anything.

If you want this feature, please let me know what I can do to get this over the finish line for you. Feel free to close otherwise.

@t-eckert t-eckert force-pushed the t-eckert/add-set-checkbox branch from 0d68c91 to 1b214e5 Compare December 31, 2024 00:58

if string.match(line, checkbox_pattern) then
-- Only set the check_char if the line contains the checkbox pattern.
line = util.string_replace(line, "- [" .. check_char .. "]", "- [" .. check_char .. "]", 1)
Copy link

@rodrigoscc rodrigoscc Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue seems to be here. You are trying to replace say - [ x ] with - [ x ], so doing nothing. You need to replace - [ <anything> ] with - [ <check_char> ].

Copy link

@rodrigoscc rodrigoscc Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could extract <anything> with the regex checkbox_pattern, just make the char a regex group and extract it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I'll make this fix and test again. Great catch!

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