joaomsa / telescope-orgmode.nvim

Neovim plugin. Telescope.nvim extension that adds orgmode.nvim integration.
MIT License
27 stars 7 forks source link

Refile Heading or TODO doesn't adapt the heading level #3

Closed lyz-code closed 8 months ago

lyz-code commented 1 year ago

When refiling a level 3 heading or TODO item to a level 1 heading or TODO the level of the heading is not transformed to a level 2 heading or TODO.

The other way around does work, when refiling a level 1 element to a level 3 element, the refiled element level is transformed from level 1 to level 4.

Steps to reproduce

  1. Open the next file called test.org with the minimal configuration below:
    * Heading 1
    ** Subheading 1
    ** Subheading 2
    * Heading 2
    *** SubSubheading 1
  2. Hover with your cursor the SubSubheading 1 section and use the refile method
  3. In the Destination enter test.org/Heading 1 and press Enter.
  4. The result of the refile is the following.
    * Heading 1
    ** Subheading 1
    ** Subheading 2
    *** SubSubheading 1
    * Heading 2

As you can see now instead of belonging to Heading 1 it is listed under Subheading 2 which is not desirable. When working with TODO items is awful because you may loose the context of what the task is about as it's listed as a subtask of the task you want it to be.

Expected behavior

The level of the SubSubheading is updated to match the first level children of the target of the refile. In this case the result file would be:

* Heading 1
** Subheading 1
** Subheading 2
** SubSubheading 1
* Heading 2

Note that it is ** SubSubheading 1 instead of *** SubSubheading 1

Additional context

This has been solved at nvim-orgmode/orgmode on this commit, but it doesn't work when using telescope-orgmode.

An example that the other way around works as expected is the following:

  1. From the original file:
    * Heading 1
    ** Subheading 1
    ** Subheading 2
    * Heading 2
    *** SubSubheading 1
  2. If you refile the Subheading 1 into SubSubheading 1 the result file is
    * Heading 1
    ** Subheading 2
    * Heading 2    
    *** SubSubheading 1
    **** Subheading 1  
lyz-code commented 1 year ago

Hi @joaomsa, can I do anything to speed up the fix of this issue? I have no Lua skills but if you point me in the good direction I might be able to hack my way through

lyz-code commented 1 year ago

Hey @joaomsa maybe you've missed the notification, can I do something to help?

lyz-code commented 8 months ago

This has been fixed in my fork