Skip to content

Commit b88483f

Browse files
Fix refile with noindent mode
1 parent bb4afa8 commit b88483f

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

lua/orgmode/parser/section.lua

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -460,24 +460,26 @@ end
460460
function Section:demote(amount, demote_child_sections, dryRun)
461461
amount = amount or 1
462462
demote_child_sections = demote_child_sections or false
463+
local should_indent = config.org_indent_mode == 'indent'
463464
local lines = {}
464465
local headline_line = string.rep('*', amount) .. self.line
465466
table.insert(lines, headline_line)
466467
if not dryRun then
467468
vim.api.nvim_call_function('setline', { self.range.start_line, headline_line })
468469
end
469-
if config.org_indent_mode == 'indent' then
470-
local contents = self.root:get_node_text_list(self.node)
471-
for i, content in ipairs(contents) do
472-
if i > 1 then
473-
if content:match('^%*+') then
474-
break
475-
end
476-
local content_line = string.rep(' ', amount) .. content
477-
table.insert(lines, content_line)
478-
if not dryRun then
479-
vim.api.nvim_call_function('setline', { self.range.start_line + i - 1, content_line })
480-
end
470+
local contents = self.root:get_node_text_list(self.node)
471+
for i, content in ipairs(contents) do
472+
if i > 1 then
473+
if content:match('^%*+') then
474+
break
475+
end
476+
local content_line = content
477+
if should_indent then
478+
content_line = string.rep(' ', amount) .. content
479+
end
480+
table.insert(lines, content_line)
481+
if not dryRun and should_indent then
482+
vim.api.nvim_call_function('setline', { self.range.start_line + i - 1, content_line })
481483
end
482484
end
483485
end
@@ -659,7 +661,7 @@ end
659661

660662
---@param date Date
661663
---@param type string
662-
---@param active boolean
664+
---@param active? boolean
663665
---@return string
664666
function Section:_add_planning_date(date, type, active)
665667
local date_string = date:to_wrapped_string(active)

0 commit comments

Comments
 (0)