Skip to content

fix: avoid E490 when using move_subtree_up and move_subtree_down #1013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lua/orgmode/org/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,8 @@ function OrgMappings:move_subtree_up()
local foldclosed = vim.fn.foldclosed('.')
vim.cmd(string.format(':%d,%dmove %d', range.start_line, range.end_line, target_line))
local pos = vim.fn.getcurpos()
vim.fn.cursor(target_line + 1, pos[2])
if foldclosed > -1 and vim.fn.foldclosed('.') == -1 then
vim.fn.cursor(target_line + 1, pos[3])
if foldclosed > -1 and vim.fn.foldlevel('.') > 0 and vim.fn.foldclosed('.') == -1 then
vim.cmd([[norm!zc]])
end
end
Expand All @@ -830,8 +830,8 @@ function OrgMappings:move_subtree_down()
local foldclosed = vim.fn.foldclosed('.')
vim.cmd(string.format(':%d,%dmove %d', range.start_line, range.end_line, target_line))
local pos = vim.fn.getcurpos()
vim.fn.cursor(target_line + range.start_line - range.end_line, pos[2])
if foldclosed > -1 and vim.fn.foldclosed('.') == -1 then
vim.fn.cursor(target_line + range.start_line - range.end_line, pos[3])
if foldclosed > -1 and vim.fn.foldlevel('.') > 0 and vim.fn.foldclosed('.') == -1 then
vim.cmd([[norm!zc]])
end
end
Expand Down
Loading