From da8bcec74d02dc133f89ded4073eb9976b013cf2 Mon Sep 17 00:00:00 2001 From: Joao Sa Date: Thu, 3 Nov 2022 14:10:24 +0100 Subject: [PATCH] Use public headline fields instead private _section --- lua/telescope-orgmode/utils.lua | 6 +++--- lua/telescope/_extensions/orgmode/refile_heading.lua | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/telescope-orgmode/utils.lua b/lua/telescope-orgmode/utils.lua index adfbd66..a7d783d 100644 --- a/lua/telescope-orgmode/utils.lua +++ b/lua/telescope-orgmode/utils.lua @@ -25,8 +25,8 @@ utils.get_entries = function(opts) local agenda_file = orgmode.load(file_entry.filename) for _, headline in ipairs(agenda_file.headlines) do - local allowed_depth = opts.max_depth == nil or headline._section.level <= opts.max_depth - local allowed_archive = opts.archived or not headline._section:is_archived() + local allowed_depth = opts.max_depth == nil or headline.level <= opts.max_depth + local allowed_archive = opts.archived or not headline.is_archived if allowed_depth and allowed_archive then local entry = { file = file_entry.file, @@ -65,7 +65,7 @@ utils.make_entry = function(opts) if headline then lnum = headline.position.start_line location = string.format('%s:%i', location, lnum) - line = string.format('%s %s', string.rep('*', headline._section.level), headline.title) + line = string.format('%s %s', string.rep('*', headline.level), headline.title) end return { diff --git a/lua/telescope/_extensions/orgmode/refile_heading.lua b/lua/telescope/_extensions/orgmode/refile_heading.lua index a4443a8..25d8e4b 100644 --- a/lua/telescope/_extensions/orgmode/refile_heading.lua +++ b/lua/telescope/_extensions/orgmode/refile_heading.lua @@ -30,11 +30,11 @@ return function(opts) local dst_headline = entry.value.headline if dst_headline then -- NOTE: adapted from Capture:refile_to_headline - if src_item and src_item.level <= dst_headline._section.level then + if src_item and src_item.level <= dst_headline.level then -- Refiling in same file just moves the lines from one position -- to another,so we need to apply demote instantly local is_same_file = dst_file.filename == src_item.root.filename - src_lines = src_item:demote(dst_headline._section.level - src_item.level + 1, true, not is_same_file) + src_lines = src_item:demote(dst_headline.level - src_item.level + 1, true, not is_same_file) end local refiled = Capture:_refile_to(dst_file.filename, src_lines, src_item, dst_headline.position.end_line) if not refiled then