@@ -460,24 +460,26 @@ end
460
460
function Section :demote (amount , demote_child_sections , dryRun )
461
461
amount = amount or 1
462
462
demote_child_sections = demote_child_sections or false
463
+ local should_indent = config .org_indent_mode == ' indent'
463
464
local lines = {}
464
465
local headline_line = string.rep (' *' , amount ) .. self .line
465
466
table.insert (lines , headline_line )
466
467
if not dryRun then
467
468
vim .api .nvim_call_function (' setline' , { self .range .start_line , headline_line })
468
469
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 })
481
483
end
482
484
end
483
485
end
659
661
660
662
--- @param date Date
661
663
--- @param type string
662
- --- @param active boolean
664
+ --- @param active ? boolean
663
665
--- @return string
664
666
function Section :_add_planning_date (date , type , active )
665
667
local date_string = date :to_wrapped_string (active )
0 commit comments