Skip to content

Commit 385dd9a

Browse files
author
Kristijan Husak
committed
Do not indent subtree content on promote/demote when org_indent_mode is noindent. Fixes #46.
1 parent 40ba3e1 commit 385dd9a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lua/orgmode/parser/headline.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,10 @@ function Headline:demote(amount, demote_child_headlines)
351351
amount = amount or 1
352352
demote_child_headlines = demote_child_headlines or false
353353
vim.fn.setline(self.range.start_line, string.rep('*', amount) .. self.line)
354-
for _, content in ipairs(self.content) do
355-
vim.fn.setline(content.range.start_line, string.rep(' ', amount) .. content.line)
354+
if config.org_indent_mode == 'indent' then
355+
for _, content in ipairs(self.content) do
356+
vim.fn.setline(content.range.start_line, string.rep(' ', amount) .. content.line)
357+
end
356358
end
357359
if demote_child_headlines then
358360
for _, headline in ipairs(self.headlines) do
@@ -368,9 +370,11 @@ function Headline:promote(amount, promote_child_headlines)
368370
return utils.echo_warning('Cannot demote top level heading.')
369371
end
370372
vim.fn.setline(self.range.start_line, self.line:sub(1 + amount))
371-
for _, content in ipairs(self.content) do
372-
if vim.trim(content.line:sub(1, amount)) == '' then
373-
vim.fn.setline(content.range.start_line, content.line:sub(1 + amount))
373+
if config.org_indent_mode == 'indent' then
374+
for _, content in ipairs(self.content) do
375+
if vim.trim(content.line:sub(1, amount)) == '' then
376+
vim.fn.setline(content.range.start_line, content.line:sub(1 + amount))
377+
end
374378
end
375379
end
376380
if promote_child_headlines then

0 commit comments

Comments
 (0)