Skip to content

Commit 1f103a9

Browse files
Fix get date under cursor to consider missing headline
1 parent 6eee479 commit 1f103a9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lua/orgmode/org/mappings.lua

+9-4
Original file line numberDiff line numberDiff line change
@@ -864,12 +864,17 @@ end
864864
---@return Date|nil
865865
function OrgMappings:_get_date_under_cursor(col_offset)
866866
col_offset = col_offset or 0
867-
local item = Files.get_closest_headline()
868867
local col = vim.fn.col('.') + col_offset
869868
local line = vim.fn.line('.')
870-
local dates = vim.tbl_filter(function(date)
871-
return date.range:is_in_range(line, col)
872-
end, item.dates)
869+
local item = Files.get_closest_headline()
870+
local dates = {}
871+
if item then
872+
dates = vim.tbl_filter(function(date)
873+
return date.range:is_in_range(line, col)
874+
end, item.dates)
875+
else
876+
dates = Date.parse_all_from_line(vim.fn.getline('.'), line)
877+
end
873878

874879
if #dates == 0 then
875880
return nil

0 commit comments

Comments
 (0)