aziz / PlainTasks

An opinionated todo-list plugin for Sublime Text editor (version 2 and 3)
MIT License
3.29k stars 286 forks source link

Archiving tasks with indented notes underneath removes indentation #433

Open Lightborne opened 2 years ago

Lightborne commented 2 years ago

My task looks like this:

☐ my test task
    here are some indented notes
    more indented notes
☐ Another task that's not done
    so many notes
    all the notes

When I am done with "my test task" and archive it, here's what I get:

☐ Another task that's not done
    so many notes
    all the notes

___________________
Archive:
✔ my test task @done (22-03-10 10:14)
here are notes
more notes

As you can see, my task notes are no longer indented.

Is this intended behavior? If not, can it be fixed?

Lightborne commented 2 years ago

Ideally, this is what I'd expect to see:

☐ Another task that's not done
    so many notes
    all the notes

___________________
Archive:
✔ my test task @done (22-03-10 10:14)
    here are notes
    more notes
vovkkk commented 2 years ago

It is probably because of "before_tasks_bullet_margin": 1 setting, try 2 or more instead of 1.

Lightborne commented 2 years ago

Thanks for the quick response. Unfortunately I am still not seeing quite the behavior I would expect with that setting set to different values. The whitespace for the lines under my tasks isn't being left alone.

For reference, my personal settings file is this:

{
  "before_tasks_bullet_margin": 0,
  "margin": 0,
  "tab_size": 4,

  "color_scheme": "Packages/PlainTasks/tasks-eighties-colored.hidden-tmTheme",
}

But I will remove margin, and tab_size from this testing, only overwriting before_tasks_bullet_margin.

before_tasks_bullet_margin == 2

Before:

 ☐ Task A
 ☐ Task B
   note B1
     indented note B11
     indented note B12
   note B2
 ☐ Task C
   note C1
   note C2

After archiving Task B:

     ☐ Task A
     ☐ Task C
       note C1
       note C2

___________________
Archive:
  ✔ Task B @done (22-03-11 10:03)
    note B1
    indented note B11
    indented note B12
    note B2

before_tasks_bullet_margin == 4

Before:

    ☐ Task A
    ☐ Task B
      Note B1
        Indented note B11
        Indented note B12
      Note B2
    ☐ Task C

After archiving Task B:

    ☐ Task A
    ☐ Task C

___________________
Archive:
    ✔ Task B @done (22-03-11 10:07)
        Note B1
        Indented note B11
        Indented note B12
        Note B2
vovkkk commented 2 years ago

Yes, the archiving command simply strips leading and trailing whitespaces as line_content.strip():

https://github.com/aziz/PlainTasks/blob/8edb7703002c0ac6bcad432dce6b59944cdaf702/PlainTasks.py#L435-L455

The issue with maintaining whole indentations is that you would have to check if the task have higher indent level than one, i.e. the task can be a subtask of a subtask of a task of a subproject of a subproject of a project—so the level of indent would be six:

project:
  subproject:
    subproject:
      ☐ task
        ☐ subtask
          ☐ subtask
            ☐ task
              note

but under the archive it should be level one of indent:

Archive:
  ✔ task @done (22-03-14 15:01) @project(project / subproject / subproject)
    note

So we probably could match the indent of the task and then replace it with empty string for each note line (but only once for each because a note may contain whitespace in its middle for aligning and such), but then the problem could be with mixed indents if there are used whitespaces and tabs, which I guess we could ignore for simplicity. Anyway, if you are willing to send a pull request :shipit: would be great.

Lightborne commented 2 years ago

ahh, yes, I see how that would make things difficult.

Thanks for the reply! I am not an expert python programmer but I may try to take some time to work on this enhancement.