fix(ui): ensure pattern matching for time section matches new config#90
fix(ui): ensure pattern matching for time section matches new config#90
Conversation
WalkthroughThe code in the time-machine UI module was updated to support multiple time formats for parsing time strings in lines. Instead of a single pattern, a table of patterns is now used, and the appropriate pattern is selected based on user configuration. Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
lua/time-machine/ui.lua (2)
164-164: Consider improving unix timestamp pattern flexibility.The unix timestamp pattern
(%d%d%d%d%d%d%d%d%d%d)assumes exactly 10 digits, but unix timestamps can be 9 digits (before 2001) or 13+ digits (millisecond precision). This could cause matching failures for edge cases.Consider using a more flexible pattern:
- unix = "(%d%d%d%d%d%d%d%d%d%d)%s*(.*)$", -- e.g., "1720048500 #tag" + unix = "(%d%d%d%d%d%d%d%d%d+)%s*(.*)$", -- e.g., "1720048500 #tag"
167-167: Consider caching config to improve performance.Loading the config module inside the highlighting function (which may be called frequently) could impact performance. Consider caching the config or moving this logic to module initialization.
Move config loading to module level:
+local config = require("time-machine.config").config --- Set highlights for the UI local function set_highlights(bufnr, seq_map, curr_seq, lines) -- ... existing code ... - local config = require("time-machine.config").config
Unix timestamps can be 9 digits (before 2001) or 13+ digits (millisecond precision)
Summary by CodeRabbit