fabiospampinato / vscode-todo-plus

Manage todo lists with ease. Powerful, easy to use and customizable.
MIT License
908 stars 227 forks source link

Support toggling time tracking for a task #88

Open micxer opened 6 years ago

micxer commented 6 years ago

Just switched from SublimeText and PlainTasks. I am missing the option to toggle the time tracking on a task when switching to another one. That would make the time tracking even more useful.

Otherwise the extension made the migration to VS Code a least possible. Thanks.

fabiospampinato commented 6 years ago

That's definitely a feature to implement, thanks for the suggestion.

jods4 commented 6 years ago

I am not sure if this is the same or I should open another issue:

This is useful because it enables people to use time tracking when work on a task is split over multiple sessions, e.g.: you're working on something and are interrupted (phone call, lunch break, urgent stuff to do, work on a task across two days); or you can re-open a "done" task if you need to revisit it with a little extra work.

If this is OK with you I could PR this feature.

fabiospampinato commented 6 years ago

@jods4 there are a few differences between your proposed solution and @micxer's. Yours has the ability to re-open a "done" task, but it deviates from PlainTasks' behavior, and being as much compatible as possible with PlainTasks is important for this extension.

I'd be willing to consider a PR that implements the ability to toggle the timer the same way that PlainTasks does it.

jods4 commented 6 years ago

Could you elaborate? I'm not familiar with PlainTasks.

fabiospampinato commented 6 years ago

@jods4 you should just try it. I'm not sure I can explain it clearly, but basically each odd @toggle(date) pauses the timer and each even @toggle(date) resumes the timer. So the time between a pause and a resume is subtracted from the lasted/wasted time.

jods4 commented 6 years ago

@fabiospampinato I don't have Sublime and I'm happy with VS Code.

Sooo.... given TODO+ doesn't use @toggle, something like this?

Bonus points:

fabiospampinato commented 6 years ago

@jods4 we are currently appending @done/@cancelled if the task is completed, and, respectively, @lasted/@wasted if time tracking for that task was active.

If we are going to implement this I want it done the way PlainTasks does it, no @stopped, no multiple @started. What you're proposing, if I'm understanding it correctly, might be easier to read (but I don't think this matters much in this case) but it will make it more difficult for folks to switch from PlainTasks to Todo+, which I'm more interested in.

jods4 commented 6 years ago

Being able to track time across multiple work sessions is very useful to me. I can try to produce a PR if you spec the behavior you'd like.

fabiospampinato commented 6 years ago

@jods4 I would like it to work like this:

☐ Rename the `Todo: Toggle Timer` command to `Todo: Toggle Status Bar Timer`
  ☐ Maybe we should also assign this to `alt+shift+t` 🤔
☐ Add a `Todo: Toggle Timer` command
  ☐ Assign it to `alt+t`
  ☐ If the item where it's being used is not a todo (comment, project) it displays an error
  ☐ Else if the todo is completed it displays an error
  ☐ Else if the todo is not started it displays an error
  ☐ Else it adds the `@toggle(date)` tag
    ☐ `date` is formatted using `todo.timekeeping.started.format`
  ☐ an uncompleted todo with `@started` and an odd number of `@toggle` _after_ its `@started` tag is considered not active
  ☐ an uncompleted todo with `@started` and an even number of `@toggle` _after_ its `@started` tag is considered active
    ☐ the first active started todo is the one whose timer is being displayed in the status bar
  ☐ when a started todo is completed the `@lasted`/`@wasted` time is computed like this:
    FYI IIRC there is a bit of code in there to synchronize the seconds with the current ones (in order to avoid displaying weird stuff into the status bar timer), unless the seconds are specified in `date`
    ☐ [PAUSE] If there is a `@toggle` tag _after_ `@started` do `elapsed += ( difference between this toggle and started )`
    ☐ [RESUME] If there is another `@toggle` tag resume counting from it's date
    ☐ [PAUSE] if there is another `@toggle` tag do `elapsed += ( difference between this toggle and the previous toggle )`
    ☐ and so on...
    ☐ [END] if there isn't another `@toggle` and the timer is not paused do `elapsed += ( difference between the last toggle, or the started date, and now )`
☐ Update the readme

Let me know if there are unclear points.

jods4 commented 6 years ago

@jods4 That's a bigger change than I expected. I'm interested but won't have the time to tackle that right now. Maybe later, I'll stay in touch.

MadcowD commented 4 years ago

Hey, just wondering if any progress on this has been made?

DiegoTheWolf commented 4 years ago

Hey guys, another year later i want to revive this. I don't know what would be easier to implement:

  1. @paused(_time_) and @resumed(_time_)
  2. multiple started(_time) and @stopped(_time)

If i'd know how, i'd offer my help, but i've never done any work on extensions.

arkadianriver commented 3 years ago

Being compatible with PlainTasks @toggle(<datetime>) would be awesome, particularly when migrating over, but I wonder if that design could also be improved upon, because as often as I jump between tasks my toggles would stack up, which is kinda messy.

image

What do you think of an option (for those of us that don't share the same todo file between both) to gather those toggles into a @pausedFor(<duration>). ie. calculate the elapsed pause duration with each toggle action and rewrite with that instead of leaving all the toggles listed one after the other? That is ..

In each case, the duration(s) of any existing @pausedFors would be summed together along with the latest calculated duration, and replaced with just one entry.

Then, at the end, the entry would look something like this instead image

Plus, if I'd need to manually update my pause time for those times I forget to toggle the pause on or off (happens a lot), it would be easier to edit just one duration value instead (before pressing my next toggle or done).

Or, actually, I guess the pausedFor duration would map directly to the @wasted label when it's done.

shaielc commented 3 years ago

@arkadianriver

  1. Are there any plans to implement this feature?
  2. I think that for manual revision it will be harder to track if you already applied for gaps where you forgot to pause - so is there any way for VSCode to display the @pausedFor and hide all of the @toggle and automatically wrap them together on the @done / a VSCode command - i.e. Todo: Calculate paused time