GothenburgBitFactory / taskwarrior

Taskwarrior - Command line Task Management
https://taskwarrior.org
MIT License
4.28k stars 285 forks source link

[TW-274] rc.indent.annotation is only applied to 1st line #314

Open taskwarrior opened 6 years ago

taskwarrior commented 6 years ago

Elias Probst on 2014-01-25T21:46:37Z says:

The value defined by rc.indent.annotation is only applied to the 1st line of the annotation. Using task 2.3.0.

elias(at)moria ~ % task add A testtask for annotation indentations
TASKDATA override: /home/elias/.task/test
Created task 1.
elias(at)moria ~ % task 1 annotate This is a really long annotation supposed to span multiple lines to serve as a showcase for a bug in task which only indents the 1st line of an annotation while ignoring every following line.
Annotating task 1 'A testtask for annotation indentations'.
Annotated 1 task.
TASKDATA override: /home/elias/.task/test
elias(at)moria ~ % task long                                     
TASKDATA override: /home/elias/.task/test

ID Added      Age Description                                                                
 1 2014-01-25 1m  A testtask for annotation indentations
                    2014-01-25 This is a really long annotation supposed to span multiple
                  lines to serve as a showcase for a bug in task which only indents the 1st
                  line of an annotation while ignoring every following line.

1 task
taskwarrior commented 6 years ago

Migrated metadata:

Created: 2014-01-25T21:46:37Z
Modified: 2017-10-11T14:36:37Z
taskwarrior commented 6 years ago

Paul Beckingham on 2014-07-06T04:50:05Z says:

Needs a more extensive change to ViewTask than expected.

taskwarrior commented 6 years ago

Peter Vitt on 2017-10-11T14:36:37Z says:

As I also requested that feature several years before, I finally plucked up courage and dove into this a little.

A pseudo call tree for this looks like:

I want to print something (in this example an info report), therefore I take a Table: {code:java} Table view; view.width (context.getWidth ()); view.add (STRING_COLUMN_LABEL_NAME); view.add (STRING_COLUMN_LABEL_VALUE); setHeaderUnderline (view);

// id auto row = view.addRow (); view.set (row, 0, STRING_COLUMN_LABEL_ID); view.set (row, 1, (task.id ? format (task.id) : "-"));

// description auto description = task.get ("description"); auto indent = context.config.getInteger ("indent.annotation");

for (auto& anno : task.getAnnotations ()) description += '\n'

row = view.addRow (); view.set (row, 0, STRING_COLUMN_LABEL_DESC); view.set (row, 1, description, c); {code} Here the task's description is added to the variable description, and after that all annotations are added with their date, whereas those annotations are indented (configured via indent.annotation) and separated by a newline character. This string is passed to [Table::set|https://git.tasktools.org/TM/libshared/src/master/src/Table.cpp#L79]

When the table is rendered, the entries from _data are passed to [renderCell|https://git.tasktools.org/TM/libshared/src/master/src/Table.cpp#L337], where it is passed to [wrapText|https://git.tasktools.org/TM/libshared/src/master/src/shared.cpp#L46] where it is again passed to [extractLine|https://git.tasktools.org/TM/libshared/src/master/src/shared.cpp#L265].

In subsequent calls to extractLine, the original string is looked at character by character and converted into line after line. Thus, this is the place where the indentation has to take place. However, this routine is a generic routine, thus it doesn't know about annotations at all, it just cares about strings.

From my point of view, there are (at least) two possible ways to also indent multi-line annotations:

  1. Make extractLine aware of what it is currently dissecting.
  2. Make extractLine sensible for line indentations.
  3. ?

The first approach would result in a lot of changes to the code, as the information of what extractLine is working on has to be passed around, and it would reduce the genericity (is this actually a word?) of that routine.

The second approach is the more appealing on, I think. extractLine could be enabled to recognize the indentation width by counting white space at the beginning of the line . And if this line has to be wrapped, this indentation width could be used (e.g. doubled) to indent the next line as well.

I [added a very rough idea|https://bug.tasktools.org/secure/attachment/11606/indent.diff] of what this could look like.

pbeckingham commented 6 years ago

TW-274_indent.diff.txt

N-R-K commented 3 years ago

Any update on this? Started using TW recently and the broken indentation is extremely triggering.

tbabej commented 3 years ago

Hi @N-R-K, the issue currently sits in the backlog milestone, so it's not considered for the next release (2.6.0). That said, we could re-prioritize. Perhaps you'd be willing to help out with this?

N-R-K commented 3 years ago

Perhaps you'd be willing to help out with this?

Would love to if I could. Unfortunately I don't know much beyond shell scripts. Would appreciate if the priority on this gets bumped.

On a side note, the 1 hour long yt video you had on task warrior was very helpful in getting started and setting things up. So thanks for that.