Skip to content

Conversation

@ganskef
Copy link

@ganskef ganskef commented May 12, 2023

Notes:

  • Is it needed to have a template for the creation date?
  • What's about the dateFormat? It's ignored and always ISO by now.
  • Redundant test code should be reorganized maybe.

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?

@PKief PKief requested a review from Copilot July 18, 2025 10:05
Copy link

Copilot AI left a 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 dateWhenCreated configuration 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 hasDate is misleading since it actually checks for a specific date format at the beginning of the line, not just any date. Consider renaming to hasDatePrefix or startsWithDate for clarity.
  const hasDate = helpers

dateWhenChecked: true,
showStatusBarItem: true,
dateFormat: 'YYYY-MM-DD',
dateWhenCreated: false,
Copy link

Copilot AI Jul 18, 2025

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.

Suggested change
dateWhenCreated: false,
dateWhenCreated: true,

Copilot uses AI. Check for mistakes.
const checkboxCharacters = '[ ] ';
const hasDate = helpers
.getPlainLineText(line.text)
.match(/^(?:[+*-]\s)?\d{4}-\d{2}-\d{2} /);
Copy link

Copilot AI Jul 18, 2025

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.

Copilot uses AI. Check for mistakes.
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.

Add timestamp if checkbox is created

2 participants