Skip to content

Add timestamp insertion in notes editor context menu#927

Merged
multiplex55 merged 1 commit intomasterfrom
codex/implement-timestamp-insertion-in-notes-dialog
Mar 13, 2026
Merged

Add timestamp insertion in notes editor context menu#927
multiplex55 merged 1 commit intomasterfrom
codex/implement-timestamp-insertion-in-notes-dialog

Conversation

@multiplex55
Copy link
Copy Markdown
Owner

Motivation

  • Provide a quick way for users to insert timestamps into note content using the same stable timestamp format used elsewhere in the project.
  • Ensure timestamp insertion is Unicode-safe and respects the current caret position in the multiline editor.

Description

  • Add format_note_timestamp(dt: DateTime<Local>) and format_note_timestamp_now() that format timestamps as %Y-%m-%d %H:%M:%S to match existing conventions.
  • Add insert_at_char_boundary(text, idx, insert) which inserts by character index, clamps out-of-range indices to the end, and avoids splitting UTF-8 code units.
  • Replace TextEdit::multiline(...).show(...) output usage to capture cursor_range and obtain the caret character index, and attach a context menu item with the exact label Insert timestamp that inserts the formatted timestamp at the caret (or appends as a fallback) and closes the menu.
  • Preserve existing Enter key consumption logic and the Save/Cancel flow in the edit-mode block.
  • Add unit tests for middle/start/end insertion, out-of-range fallback, Unicode-safe boundaries, and deterministic timestamp formatting using a fixed datetime.

Testing

  • Ran cargo fmt -- src/gui/notes_dialog.rs which completed successfully.
  • Ran cargo test --lib notes_dialog -- --nocapture, which could not complete in this environment due to a missing system dependency (alsa pkg-config/alsa.pc) required by a transitive crate; the failure is environmental and not from the newly added unit tests or logic.
  • Unit tests were added under src/gui/notes_dialog.rs in the #[cfg(test)] module covering the insertion and timestamp formatting cases.

Codex Task

@multiplex55 multiplex55 merged commit 5748e7f into master Mar 13, 2026
1 check passed
@multiplex55 multiplex55 deleted the codex/implement-timestamp-insertion-in-notes-dialog branch March 25, 2026 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant