fix: avoid E490 when using move_subtree_up
and move_subtree_down
#1013
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR contains two commits - the first fix inconsequentaial probable type regarding the cursor positioning after calling
move_subtree_up
andmove_subtree_down
. The second add additional condition to the end of these functions to ensure E490 Fold not found is not raised.Related Issues
Related #899 - I believe this issue is caused by the same underlying reason, of nvim failing to understand the updated fold structure after the rearranging of lines.
Changes
commit MarkSverdlov/orgmode@5bfa7f3
Patch a bug where E490: No fold found is raised when executing
move_subtree_up
ormove_subtree_down
in some scenarios. A minimal example is:In that case, if
foldlevel=0
(i.e.** c
isn't visible) and the cursor is on* b
, then using<leader>oK
may raise E490. This doesn't happen on the first execution of this function after loading the buffer, but does happen consistently on the next executions of the function.The adds additional condition for the last part of these functions (the parts that conditionally calls
vim.fn.cmd([[norm!zc]])
), that checks whether the fold exists. This guarantees the problematic instruction won't be called in these scenarios.It's important to note that this patch doesn't solve the underlying bug - the conditioned suite shouldn't be executed to begin with unless
foldclosed > -1
, which suggests that before the rearranging of lines, the predecessor of the offending line had a positivefoldlevel
(and the offending line should have too), but since nvim doesn't agree with it, this patch at least circumvent the red error message.Commit MarkSverdlov/orgmode@fdcfdca
This changes the column coordinate of the placement of the cursor after the rearranging of lines. Before, the column was
pos[2]
, which is the line number of the previous location. Now, the column coordinate is set to bepos[3]
which is the column number of the previous position. This change is quite inconsequential, but it's an easy fix.Checklist
I confirm that I have:
Conventional Commits
specification (e.g.,
feat: add new feature
,fix: correct bug
,docs: update documentation
).make test
.