jasonwilliams / anki

Anki VSCode Plugin
MIT License
273 stars 31 forks source link

Parse nodeIDs #92

Closed benjamin-weller closed 1 year ago

benjamin-weller commented 1 year ago

This change allows for a parsing of note IDs. This is the first step in allowing (eventually) the automatic storing of the created note ID in the markdown file.

jasonwilliams commented 1 year ago

@benjamin-weller could you explain where these noteIDs come from? Why are they added and what is generating them, the markdown would be hand written most of the time. I may be missing some context here

benjamin-weller commented 1 year ago

These note IDs are uniquely generated by Anki. image

See the note/card ID section of the browser search documentation here.

IIUC these IDs uniquely identify the note in question; as such you could eventually update a specific note given its parsed note ID.

How I intend to eventually allow for updating of already created notes:

Now that there's a way for us to update notes, I would like to have a way for us to automatically insert the note IDs into the markdown during the deck/note creation command.

How I intend to get/insert the note ID into markdown:

jasonwilliams commented 1 year ago

Hey @benjamin-weller great work on making a start on this, I wasn't ignoring, it was just the holidays and I didn't have time to look over this. Hopefully I should have a bit more time now.

Thinking about the workflow here... Someone will create a note in VS Code, when they send it to Anki, AnkiConnect gives us an ID back in the response I believe. Are you planning to take the ID and insert it back into the markdown once sent? (I understand this PR doesn't deal with that right now)

Do you have an idea how this comment will look like?

benjamin-weller commented 1 year ago

100% no worries, you've been very responsive before and honestly I have no expectations around super prompt responses, this is OSS; not much money changing hands here.

Someone will create a note in VS Code, when they send it to Anki, AnkiConnect gives us an ID back in the response I believe. Are you planning to take the ID and insert it back into the markdown once sent? (I understand this PR doesn't deal with that right now)

Yes, that's the ultimate goal

Do you have an idea how this comment will look like?

Yes the comment should look like <!-- notecardId: ###### --> or <!-- notecardId = ###### -->. I've generally tried to be tolerant of spaces in my regex.

jasonwilliams commented 1 year ago

Hey @benjamin-weller, maybe im doing something wrong here but could you explain why noteId isn't coming through when I test it?

noNoteId

jasonwilliams commented 1 year ago

I've also realised this repo doesn't support proper linting on CI so im going to sort that out. I will PR it, you may need to rebase apologies in advance

benjamin-weller commented 1 year ago

Sounds good I'll rebase here.

The unit tests pass and that's what I tested against, can you give me a direction as to how to set up your testing environment?

Is it like building a trial/test version of the extension and installing that?

jasonwilliams commented 1 year ago

Sure

https://github.com/jasonwilliams/anki/blob/main/CONTRIBUTING.md#debugging I clicked "Run & Debug" icon on the left, then clicked the play button next to "Run Extension".

This should launch another instance of VSCode, I used that to test. In the original instance you should be able to set breakpoints and inspect the code

benjamin-weller commented 1 year ago

Preliminary investigation is leading me to confusing places: image

I'll continue to debug.

benjamin-weller commented 1 year ago

I don't know why the regex wasn't working with my previous setup, but I manually tested, and ran the unit tests; both now pass.

Here's what I get during manual debugging: image

jasonwilliams commented 1 year ago

Awesome work thanks, I’ll take another look. Also it seems there’s a conflict with package.json, you may need to try and rebase

jasonwilliams commented 1 year ago

Your lockfile causes conflicts, like its trying to set it back to version 1, what version of nodejs/npm are you using? Everything else seems ok

benjamin-weller commented 1 year ago

Ok, I'm relatively new to the git flow, please let me know if my changes here match up and can be merged.

jasonwilliams commented 1 year ago

LGTM

jasonwilliams commented 1 year ago

Hey @benjamin-weller now this is merged what are your next steps?

benjamin-weller commented 1 year ago

I've outlined what I intend to do next here.