Skip to content
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

refactor(date): improve type hints #751

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

seflue
Copy link
Contributor

@seflue seflue commented Jun 10, 2024

  • introduce types for internal date tables
  • introduce some helper to encapsulate interaction with os api

@seflue
Copy link
Contributor Author

seflue commented Jun 10, 2024

@kristijanhusak As promised here the cleaned up type hints in Date.
The failing test is unrelated, but when I had a look at it, it seems to be a flaky candidate. I don't think it can be made 100% deterministic, but at least if we cache the current time right after the command (before vim.wait we can reduce the probability to fail:

vim.fn.cursor(3, 3)
vim.cmd([[norm citd]])
vim.wait(50)
assert.are.same({
'* PHONECALL Daily stand-up with the team',
' SCHEDULED: <2021-09-08 Wed 09:00 +1d>',
' :PROPERTIES:',
' :REPEAT_TO_STATE: PHONECALL',
' :LAST_REPEAT: [' .. Date.now():to_string() .. ']',
' :END:',
' :LOGBOOK:',
' - State "DONE" from "MEET" [' .. Date.now():to_string() .. ']',
' :END:',
}, vim.api.nvim_buf_get_lines(0, 2, 11, false))

Copy link
Member

@kristijanhusak kristijanhusak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks ok. I just skimmed through it. See if we need to address some of these comments and then I'll check it thoroughly.

lua/orgmode/objects/date.lua Outdated Show resolved Hide resolved
lua/orgmode/objects/date.lua Outdated Show resolved Hide resolved
lua/orgmode/objects/date.lua Outdated Show resolved Hide resolved
lua/orgmode/objects/date.lua Show resolved Hide resolved
lua/orgmode/objects/date.lua Show resolved Hide resolved
lua/orgmode/objects/date.lua Show resolved Hide resolved
- introduce types for internal date tables
- introduce some helper to encapsulate interaction with os api
Copy link
Member

@kristijanhusak kristijanhusak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok this looks good now. I'll do some minor changes after merging, but I don't want to bother you with those nits. Thanks!

@kristijanhusak kristijanhusak merged commit f1f3b82 into nvim-orgmode:master Jun 11, 2024
6 checks passed
@seflue seflue deleted the typesafe_date branch June 13, 2024 21:46
SlayerOfTheBad pushed a commit to SlayerOfTheBad/orgmode that referenced this pull request Aug 16, 2024
- introduce types for internal date tables
- introduce some helper to encapsulate interaction with os api

Co-authored-by: Sebastian Flügge <seflue@users.noreply.github.com>
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.

2 participants