-
-
Notifications
You must be signed in to change notification settings - Fork 243
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: find tasks in blockquotes and Obsidian callouts #953
fix: find tasks in blockquotes and Obsidian callouts #953
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, clear change.
Let me know if you would like to address the issues raised separately. If so, I'll just go ahead and merge this, and bear in mind not to do the next released until exclude sub-items
Is updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This was supposed to point directly at the ToggleDone.ts file changes in the "fix: More regexes needed updating" commit. I don't know how to github, I guess.)
@claremacrae Do these have/need tests? I cannot totally tell what is going on here.
Also any idea what is supposed to happen at line 39 of that file? Because the results in regex101 do not make any sense to me. Is it supposed to match on the content inside the checkbox (because it does, as long as that content is not a space)? If so, the comment in the file does not make a lot of sense.
EDIT: Maybe the comment in the file is wrong? #460 and #449 seem potentially related. I am very confused!
Edit (several hours later): I think the comment at line 37 of ToggleDone is just wrong: for LivePreview and Source Mode, editor.setLine()
moves the cursor to the beginning of the line, not the end.
EDIT (again!): No, that is not quite right either. If and only if the cursor is at the end of the line, it will go to the new end of the line after the text is replaced. (This happens if the line becomes shorter, longer, or stays the exact same.) If the cursor is anywhere else in the line, it goes to the beginning of the line instead.
Never mind all that, not related to this PR, will make a separate one.
Ok I think this is ready for review again. You were very right about looking for other uses of Outstanding problems I am aware of:
Please let me know any problems I am not currently aware of, happy to iterate again! Would rather get this right now and not have to stare at the regexes again later. |
Just as a quick check before merging I tried this code out in my own vault. With the updated code, I'm not able to get the tasks in block quotes and callouts to be found by Tasks. What am I doing wrong, @AnnaKornfeldSimpson ? Code changesFirst of all, here is the evidence that I have got the updated code in my vault: Also, I've restarted Obsidian. My Test FileI created the attached test file... Here is the content... Note the paths to the file in my vault in 2 locations. They will need to be updated before anyone else uses this file.
What I seeThe |
I removed the callouts from the 2 tasks blocks, and they still didn't find the tasks that are in callouts and block quotes. |
Oh bother! I will investigate within the next couple of hours. Thank you for smoke testing this. I should have realized that it needed smoke testing even though there were automated tests. |
Working on this now.
I am pretty confident that I did not touch anything related to task query blocks. If behavior had changed when moving those I would have been extremely confused. |
I may be running into issues here with not knowing the codebase well enough. Changed the last test in Query.test.ts (arbitrarily, was searching for a test that called "applyQueryToTasks") to have the input be inside blockquote and that passed just fine... (commit with that change should hopefully show up below this comment, but I rebased to pull in the changes from upstream/main so maybe I confused things?) If you have any intuition or pointers about what functions to check for the query flow, please do share! Even wrong guesses are going to be more helpful than me trying to read the entire codebase. |
4d93ee9
to
d1896d5
Compare
Firstly, can you reproduce the behaviour that I reported, from a build of the plugin? I just had a look at the code for ideas...
Lines 207 to 208 in d1896d5
In haste... Clare |
I'm suspecting that if the tests of |
The indentation is in Great, I was having trouble understanding |
Unrelated - and for later: whilst I think of it... I noticed that there are very few tests of reading tasks beginning with |
OK good luck - I really, really need sleep now... |
Found the bug, and it was in Cache.ts - thank you so much for the pointer! Obsidian's Are there ways we can test the processing code in Cache.ts to make sure there is not a regression in the future? |
Still chasing issues, but now they are in LivePreview only. Not-a-tasks-issue but fun-fact: Obsidian renders the contents of callouts in Live Preview as long as the cursor is somewhere else, and does the same for checkboxes on normal lines of Markdown but it does not do the same for checkboxes inside blockquotes! Surprising! |
I resolved the part of this that seemed feasibly resolvable. @claremacrae new stuff to code review, but I did smoke test it thoroughly this time.
Outstanding things I will get to tomorrow (my time):
Things that I think need tests added, but I do not know where to add them, any suggestions @claremacrae or would you rather add them yourself in a different PR?
Other unresolved:
|
Excellent.
When I did my talk on testing plugin code, I was unable to find a way to call any code that used Obsidian code in tests... It's possible others have found a way to do so since then, but I am unaware. |
I think the Obsidian Linter devs were working on this recently. I will ask! |
Excellent. Thank you. I would prefer to wait for the review until all changes are made.
I think that showing a popup is a great idea. When testing this, I will see if it fixes #688. If it does not, this will at least give enough pointers to enable the pop-up and warning to be extended to also work for #688.
I'm not sure that you need to do that. You have tested that the parsing is fine, so the tasks will be recognised by Query, as all it does is loop over the recognised tasks. By all means add perhaps 1 example - but it does not need to repeat testing done at the Task level.
Thank you. Feel free to modify a sprinkling of existing tests to try with
Thanks.
I do not think that is going to possible in the short term. As an alternative, maybe slightly modify the file and text for the smoke test, to include a task in block quote and/or callout, so accidental regression would be spotted when running the smoke tests?
I'm not sure what that is about. Are they not already covered by the toggle tests in
Please add any comments for this PR to the page at: Getting Started - Obsidian Tasks. Thank you. |
b815d98
to
bc905aa
Compare
Argh, I did
Ah nope, I think this may help explain #688 (all rendered widget content are considered to be at the same line number) but it does not fix it. I made my selector searches as narrow as possible. Someone will have to extend. Not a lot of luck on the mocking of Obsidian code, so I agree that changing the Smoke Test instructions is the best way to go here. Docs change complete, test and comment changes incoming. |
You are right, since Query already worked once the Tasks tests passed, going to skip.
Done.
Done.
Much better idea! Done.
No, because "ToggleDone" handles adding a
Done. That is now everything resolved that I have been keeping track of! Happy to fix anything you find, of course. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few minor questions and comments - it's very, very nearly there!
resources/sample_vaults/Tasks-Demo/Manual Testing/Smoke Testing the Tasks Plugin.md
Outdated
Show resolved
Hide resolved
2e333c2
to
78f3005
Compare
Once again I seem to have borked the git history, sorry! First new commit since your last review is "fix: Lengthen Notice in LP for callouts from 3s to 30s" |
resources/sample_vaults/Tasks-Demo/Manual Testing/Smoke Testing the Tasks Plugin.md
Outdated
Show resolved
Hide resolved
Commit from the web editor to avoid lefthook issues due to space in filename. Signed-off-by: Anna Kornfeld Simpson <[email protected]>
@claremacrae I will finish this "tomorrow" your time but I really could use some suggestions on the wording for the Notice in LP! You are correct about the behavior and I have no idea how to word that succinctly. The Notice is already pretty large... |
Maybe after this PR is done we can try to figure out what the problem is. I'd love to try and get to the bottom of it. |
I am not sure of the wording, but here is an attempt at a simpler way of wording this. BackgroundThe Tasks plugin installation notes say:
Here is what I see in my command palette: - which refers to checkbox status... The Observable BehaviourI think that what is being said is:
The docs could show raw markdown examples of both these cases... Possible idea for this error messageSlightly evading the question on wording at the moment - but is it possible for the popup banner thing to have a hyperlink in it? If so, could it link to a section in the user manual with chapter and verse on the problem? Perhaps I could start an FAQ file, and add:
|
@AnnaKornfeldSimpson I am starting to think that this is already such a major improvement that it is good enough to release... and we could improve the wording of the banner over time, if there any many people asking questions about it. I'm just thinking that you have spent SOOO much time on this, and it is definitely a huge improvement.... Feel free to declare it edit: ... after the sections change has been reverted, probably - sorry! |
Since clicking on the popup closes it, I am not sure. It would be easy to add a link in the console warning, which can also be longer, but I do not think users on mobile OSes have any way to access it. |
@claremacrae I reverted the unrelated Cache change, did my best at fixing up the wording in the LP Notice, and I am going to declare this done now! Please feel free to assign me a docs issue if you want me to add something further to the docs on this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent!
I really, really like the new wording in the LP notice - thank you! |
I wonder whether the git problems were due to rebasing? In my experience, there's very rarely any need to rebase a PR during development or review. The rare times when there are conflicts it might be worth it, but even they can often be fixed on merge. So the workaround would be to not rename, and then not have to force-push. (Also, sometimes when reviewing a PR I will create a branch off of the contributor's fork, with changes I would like to make as a separate follow-up PR. If anyone force-pushes, I have to remember to save those edits and re-apply them later) |
Fantastic stuff - huge thanks @AnnaKornfeldSimpson! ❤️ 😄 🎉 |
This was useful when manually testing the changes in #953
This was useful when manually testing the changes in #953
Description
Now that I am familiar with the dataview codebase, I found their regex for parsing list items, which works with Obsidian callouts, and it turns out the fix is super easy to add to Tasks! Blockquote/callout indicators are now stored along with spaces and tabs in the
indentation
field of the Task, so they are preserved when the task is rendered out to string.Motivation and Context
Fixes #656 including nested blockquotes/callouts
How has this been tested?
Added unit tests for parsing the task, parsing tags out of the task, and toString. Something mentioned in the issue thread is testing specifically that the
indentation
is preserved when a new instance of a recurring task is generated - I could not figure out where in the tests to put that, if you still think it is needed, could you give me a pointer please to where in the tests it should go?Types of changes
Checklist
yarn run lint
.By creating a Pull Request I agree to the Code of Conduct.