Skip to content
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

Archiving tasks with indented notes underneath removes indentation #433

Open
Lightborne opened this issue Mar 10, 2022 · 5 comments
Open

Comments

@Lightborne
Copy link

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
Copy link
Author

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
Copy link
Collaborator

vovkkk commented Mar 11, 2022

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

@Lightborne
Copy link
Author

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
Copy link
Collaborator

vovkkk commented Mar 14, 2022

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

PlainTasks/PlainTasks.py

Lines 435 to 455 in 8edb770

for task in all_tasks:
line_content = self.view.substr(task)
match_task = re.match(r'^\s*(\[[x-]\]|.)(\s+.*$)', line_content, re.U)
current_scope = self.view.scope_name(task.a)
if rds in current_scope or rcs in current_scope:
pr = self.get_task_project(task, projects)
if self.project_postfix:
eol = u'{0}{1}{2}{3}\n'.format(
self.before_tasks_bullet_spaces,
line_content.strip(),
(u' @project(%s)' % pr) if pr else '',
' ' if line_content.endswith(' ') else '')
else:
eol = u'{0}{1}{2}{3}\n'.format(
self.before_tasks_bullet_spaces,
match_task.group(1), # bullet
(u'%s%s:' % (self.tasks_bullet_space, pr)) if pr else '',
match_task.group(2)) # very task
else:
eol = u'{0}{1}\n'.format(self.before_tasks_bullet_spaces * 2, line_content.lstrip())
line += self.view.insert(edit, line, eol)

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants