-
-
Notifications
You must be signed in to change notification settings - Fork 12
Insert date while creating a checkbox #51
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
base: main
Are you sure you want to change the base?
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.
Pull Request Overview
This PR implements a feature to automatically insert the current date when creating checkboxes, addressing issue #17. The feature adds a new configuration option to control this behavior and includes logic to prevent duplicate date insertion.
- Adds
dateWhenCreatedconfiguration setting (defaults to true) to enable/disable automatic date insertion - Modifies checkbox creation logic to include current date when enabled and no existing date is detected
- Implements date detection regex to prevent duplicate dates when converting existing content
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| package.json | Adds new dateWhenCreated boolean configuration option with default value true |
| src/createCheckbox.ts | Implements date insertion logic with duplicate detection using regex pattern |
| src/test/spec/defaultSettings.ts | Sets test default for dateWhenCreated to false |
| src/test/spec/checkbox/createCheckbox.spec.ts | Adds comprehensive tests for date insertion scenarios |
Comments suppressed due to low confidence (1)
src/createCheckbox.ts:25
- The variable name
hasDateis misleading since it actually checks for a specific date format at the beginning of the line, not just any date. Consider renaming tohasDatePrefixorstartsWithDatefor clarity.
const hasDate = helpers
| dateWhenChecked: true, | ||
| showStatusBarItem: true, | ||
| dateFormat: 'YYYY-MM-DD', | ||
| dateWhenCreated: false, |
Copilot
AI
Jul 18, 2025
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.
The test default for dateWhenCreated is set to false, but the package.json default is true. This inconsistency could lead to confusion and test scenarios that don't match the actual user experience. Consider aligning the test default with the production default.
| dateWhenCreated: false, | |
| dateWhenCreated: true, |
| const checkboxCharacters = '[ ] '; | ||
| const hasDate = helpers | ||
| .getPlainLineText(line.text) | ||
| .match(/^(?:[+*-]\s)?\d{4}-\d{2}-\d{2} /); |
Copilot
AI
Jul 18, 2025
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.
The hardcoded regex pattern /^(?:[+*-]\s)?\d{4}-\d{2}-\d{2} / assumes ISO date format, but the code ignores the dateFormat configuration. This creates inconsistency between date insertion and detection logic, potentially causing issues if users have different date formats configured.
dateWhenCreatedadded, defaults to true, to disable this feature.Notes:
I would like to remove the creation date if checked at the same day, and use the checked date for creation when reopen without a create date later. What do you think?