Skip to content

Commit

Permalink
fix: enable clear time keymap consistently
Browse files Browse the repository at this point in the history
To be able to clear times if no timestamp was set when the picker was
loaded, we need to set the clear-time keymapping during rerendering of
time.
  • Loading branch information
seflue committed May 28, 2024
1 parent 3162550 commit 377b5eb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lua/orgmode/objects/calendar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ function Calendar:open()
self:set_time()
end, map_opts)
if self:has_time() then
print('apply clear_time')
vim.keymap.set('n', 'T', function()
self:clear_time()
end, map_opts)
Expand Down Expand Up @@ -579,6 +580,9 @@ function Calendar:rerender_time()
vim.api.nvim_set_option_value('modifiable', true, { buf = self.buf })
vim.api.nvim_buf_set_lines(self.buf, 8, 9, true, { self:render_time() })
if self:has_time() then
vim.keymap.set('n', 'T', function()
self:clear_time()
end, { buffer = self.buf, silent = true, nowait = true })
vim.api.nvim_buf_set_lines(self.buf, 13, 14, true, { ' [t] - enter time [T] - clear time' })
vim.api.nvim_buf_add_highlight(self.buf, namespace, 'Normal', 8, 0, -1)
vim.api.nvim_buf_add_highlight(self.buf, namespace, 'Comment', 13, 0, -1)
Expand Down

0 comments on commit 377b5eb

Please sign in to comment.