diff --git a/README.md b/README.md index d2dd9aa..4a0a632 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Manage todo lists with ease. Powerful, easy to use and customizable. [View the d - **Portable**: being a plain text format you can read and edit it using any editor - **Custom symbols**: you can replace the default symbols with any of the supported ones - **Box**: `-` `❍` `❑` `■` `⬜` `□` `☐` `▪` `▫` `–` `—` `≡` `→` `›` `[]` `[ ]` + - `NEW` **Started**: `⭘` `⭕` `◯` `o` `O` `[o]` `[O]` - **Done**: `✔` `✓` `☑` `+` `[x]` `[X]` `[+]` - **Cancelled**: `✘` `x` `X` `[-]` - **Custom colors**: all colors can be customized @@ -77,6 +78,7 @@ It adds 6 shortcuts when editing a `Todo` file: "todo.symbols.box": "☐", // Box symbol "todo.symbols.done": "✔", // Done symbol "todo.symbols.cancelled": "✘", // Cancelled symbol + "todo.symbols.started": "⭘", // Started symbol "todo.colors.done": "#a6e22e", // Done todo color "todo.colors.cancelled": "#f92672", // Cancelled todo color "todo.colors.code": "#fd971f", // Code color @@ -171,6 +173,7 @@ The following tokens can be used in `todo.statistics.project.text`, `todo.statis | `[projects]` | Number of projects | | `[tags]` | Number of tags | | `[pending]` | Number of pending todos | +| `[doing]` | Number of doing/on progress todos | | `[done]` | Number of done todos | | `[cancelled]` | Number of cancelled todos | | `[finished]` | Number of finished todos | diff --git a/package.json b/package.json index da68a17..a2c211d 100755 --- a/package.json +++ b/package.json @@ -128,6 +128,11 @@ "description": "Todo cancelled string", "default": "✘" }, + "todo.symbols.started": { + "type": "string", + "description": "Todo started string", + "default": "⭘" + }, "todo.colors.done": { "type": "string", "description": "Done todo color", @@ -138,6 +143,11 @@ "description": "Cancelled todo color", "default": "#f92672" }, + "todo.colors.started": { + "type": "string", + "description": "Started todo color", + "default": "#FF9EFB" + }, "todo.colors.code": { "type": "string", "description": "Code color", @@ -217,6 +227,9 @@ "cancelled": { "type": "string" }, + "started": { + "type": "string" + }, "code": { "type": "string" }, @@ -259,6 +272,9 @@ "cancelled": { "type": "string" }, + "started": { + "type": "string" + }, "code": { "type": "string" }, @@ -359,6 +375,11 @@ "description": "Format used for displaying time inside @created", "default": "YY-MM-DD HH:mm" }, + "todo.timekeeping.started.enabled": { + "type": "boolean", + "description": "Enable the @started tag", + "default": true + }, "todo.timekeeping.started.time": { "type": "boolean", "description": "Insert the time inside the @started tag", @@ -493,7 +514,7 @@ "todo.statistics.statusbar.tooltip": { "type": "string", "description": "Template used for rendering the tooltip", - "default": "[pending] Pending - [done] Done - [cancelled] Cancelled" + "default": "[pending] Pending - [doing] Doing - [done] Done - [cancelled] Cancelled" }, "todo.embedded.regex": { "type": "string", diff --git a/src/commands.ts b/src/commands.ts index 621971e..de64431 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -6,13 +6,13 @@ import * as path from 'path'; import * as vscode from 'vscode'; import Config from './config'; import Consts from './consts'; -import Document from './todo/document'; -import ItemFile from './views/items/item'; -import ItemTodo from './views/items/todo'; import StatusbarTimer from './statusbars/timer'; +import Document from './todo/document'; import Utils from './utils'; import ViewEmbedded from './views/embedded'; import ViewFiles from './views/files'; +import ItemFile from './views/items/item'; +import ItemTodo from './views/items/todo'; /* CALL TODOS METHOD */ @@ -152,11 +152,11 @@ function toggleStart () { return callTodosMethod ({ checkValidity: true, - filter: todo => todo.isBox (), + filter: todo => todo.isBox () || ! todo.isFinished (), method: 'toggleStart', errors: { invalid: 'Only todos can be started', - filtered: 'Only not done/cancelled todos can be started' + filtered: 'Only not done/cancelled todos can be started/unstarted' } }); @@ -283,5 +283,6 @@ function viewEmbeddedShowActiveFile () { /* EXPORT */ -export {open, openEmbedded, toggleBox, toggleDone, toggleCancelled, toggleStart, toggleTimer, archive, viewOpenFile, viewRevealTodo, viewFilesOpen, viewFilesCollapse, viewFilesExpand, viewEmbeddedCollapse, viewEmbeddedExpand, viewEmbeddedFilter, embeddedFilter, viewEmbeddedClearFilter, embeddedClearFilter, viewEmbeddedToggleAllFiles, viewEmbeddedShowAllFiles, viewEmbeddedShowActiveFile}; -export {toggleBox as editorToggleBox, toggleDone as editorToggleDone, toggleCancelled as editorToggleCancelled, toggleStart as editorToggleStart, archive as editorArchive} +export { open, openEmbedded, toggleBox, toggleDone, toggleCancelled, toggleStart, toggleTimer, archive, viewOpenFile, viewRevealTodo, viewFilesOpen, viewFilesCollapse, viewFilesExpand, viewEmbeddedCollapse, viewEmbeddedExpand, viewEmbeddedFilter, embeddedFilter, viewEmbeddedClearFilter, embeddedClearFilter, viewEmbeddedToggleAllFiles, viewEmbeddedShowAllFiles, viewEmbeddedShowActiveFile }; +export { toggleBox as editorToggleBox, toggleDone as editorToggleDone, toggleCancelled as editorToggleCancelled, toggleStart as editorToggleStart, archive as editorArchive }; + diff --git a/src/consts.ts b/src/consts.ts index 13258c9..75f451c 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -18,6 +18,7 @@ const Consts = { return { done: _.get ( config, `${root}.done` ), cancelled: _.get ( config, `${root}.cancelled` ), + started: _.get ( config, `${root}.started` ), code: _.get ( config, `${root}.code` ), comment: _.get ( config, `${root}.comment` ), project: _.get ( config, `${root}.project` ), @@ -40,6 +41,7 @@ const Consts = { box: _.get ( config, 'symbols.box' ), done: _.get ( config, 'symbols.done' ), cancelled: _.get ( config, 'symbols.cancelled' ), + started: _.get ( config, 'symbols.started' ), tag: '@' }, colors: _.extend ( getColors ( 'colors' ), { @@ -52,18 +54,18 @@ const Consts = { regexes: { impossible: /(?=a)b/gm, empty: /^\s*$/, - todo: /^[^\S\n]*((?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+]|\[[ xX+-]?\])\s[^\n]*)/gm, - todoSymbol: /^[^\S\n]*(?!--|––|——)([-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+]|\[[ xX+-]?\])\s/, + todo: /^[^\S\n]*((?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+⭘⭕◯oO]|\[[ xX+-oO]?\])\s[^\n]*)/gm, + todoSymbol: /^[^\S\n]*(?!--|––|——)([-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+⭘⭕◯oO]|\[[ xX+-oO]?\])\s/, todoBox: /^[^\S\n]*((?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›]|\[ ?\])\s(?![^\n]*[^a-zA-Z0-9]@(?:done|cancelled)(?:(?:\([^)]*\))|(?![a-zA-Z])))[^\n]*)/gm, - todoBoxStarted: /^[^\S\n]*((?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›]|\[ ?\])\s(?=[^\n]*[^a-zA-Z0-9]@started(?:(?:\([^)]*\))|(?![a-zA-Z])))[^\n]*)/gm, + todoBoxStarted: /^[^\S\n]*((?!--|––|——)(?:(?:(?:[⭘⭕◯oO]|\[[oO]\])\s[^\n]*)|(?:(?:[-❍❑■⬜□☐▪▫–—≡→›]|\[ ?\])\s[^\n]*[^a-zA-Z0-9]@started(?:(?:\([^)]*\))|(?![a-zA-Z]))[^\n]*)))/gm, todoDone: /^[^\S\n]*((?!--|––|——)(?:(?:(?:[✔✓☑+]|\[[xX+]\])\s[^\n]*)|(?:(?:[-❍❑■⬜□☐▪▫–—≡→›]|\[ ?\])\s[^\n]*[^a-zA-Z0-9]@done(?:(?:\([^)]*\))|(?![a-zA-Z]))[^\n]*)))/gm, todoCancelled: /^[^\S\n]*((?!--|––|——)(?:(?:(?:[✘xX]|\[-\])\s[^\n]*)|(?:(?:[-❍❑■⬜□☐▪▫–—≡→›]|\[ ?\])\s[^\n]*[^a-zA-Z0-9]@cancelled(?:(?:\([^)]*\))|(?![a-zA-Z]))[^\n]*)))/gm, todoFinished: /^[^\S\n]*((?!--|––|——)(?:(?:(?:[✔✓☑+✘xX]|\[[xX+-]\])\s[^\n]*)|(?:(?:[-❍❑■⬜□☐▪▫–—≡→›]|\[ ?\])\s[^\n]*[^a-zA-Z0-9]@(?:done|cancelled)(?:(?:\([^)]*\))|(?![a-zA-Z]))[^\n]*)))/gm, todoEmbedded: new RegExp ( _.get ( config, 'embedded.regex' ), _.get ( config, 'embedded.regexFlags' ) ), - project: /^(?![^\S\n]*(?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+]|\[[ xX+-]?\])\s[^\n]*)[^\S\n]*(.+:)[^\S\n]*(?:(?=@[^\s*~(]+(?::\/\/[^\s*~(:]+)?(?:\([^)]*\))?)|$)/gm, + project: /^(?![^\S\n]*(?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+⭘⭕◯oO]|\[[ xX+-oO]?\])\s[^\n]*)[^\S\n]*(.+:)[^\S\n]*(?:(?=@[^\s*~(]+(?::\/\/[^\s*~(:]+)?(?:\([^)]*\))?)|$)/gm, projectParts: /(\s*)([^]+):(.*)/, - archive: new RegExp ( `^(?![^\\S\\n]*(?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+]|\\[[ xX+-]?\\])\\s[^\\n]*)([^\\S\\n]*${_.escapeRegExp ( archiveName )}:.*$)`, 'gm' ), - comment: /^(?!\s*$)(?![^\S\n]*(?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+]|\[[ xX+-]?\])\s[^\n]*)(?![^\S\n]*.+:[^\S\n]*(?:(?=@[^\s*~(]+(?::\/\/[^\s*~(:]+)?(?:\([^)]*\))?)|$))[^\S\n]*([^\n]+)/gm, + archive: new RegExp ( `^(?![^\\S\\n]*(?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+⭘⭕◯oO]|\\[[ xX+-oO]?\\])\\s[^\\n]*)([^\\S\\n]*${_.escapeRegExp ( archiveName )}:.*$)`, 'gm' ), + comment: /^(?!\s*$)(?![^\S\n]*(?!--|––|——)(?:[-❍❑■⬜□☐▪▫–—≡→›✘xX✔✓☑+⭘⭕◯oO]|\[[ xX+-oO]?\])\s[^\n]*)(?![^\S\n]*.+:[^\S\n]*(?:(?=@[^\s*~(]+(?::\/\/[^\s*~(:]+)?(?:\([^)]*\))?)|$))[^\S\n]*([^\n]+)/gm, tag: /(?:^|[^a-zA-Z0-9`])(@[^\s*~(]+(?::\/\/[^\s*~(:]+)?(?:\([^)]*\))?)/gm, tagSpecial: new RegExp ( `(?:^|[^a-zA-Z0-9])@(${tagsNames.map ( n => _.escapeRegExp ( n ) ).join ( '|' )})(?:(?:\\([^)]*\\))|(?![a-zA-Z]))`, 'gm' ), tagSpecialNormal: new RegExp ( `(?:^|[^a-zA-Z0-9])(?:${tagsNames.map ( n => `(@${_.escapeRegExp ( n )}(?:(?:\\([^)]*\\))|(?![a-zA-Z])))` ).join ( '|' )}|(@[^\\s*~(]+(?::\/\/[^\\s*~(:]+)?(?:(?:\\([^)]*\\))|(?![a-zA-Z]))))`, 'gm' ), diff --git a/src/statusbars/timer.ts b/src/statusbars/timer.ts index dcbdb3d..65a60af 100644 --- a/src/statusbars/timer.ts +++ b/src/statusbars/timer.ts @@ -69,7 +69,7 @@ class Timer { updateData ( doc: Document ) { - const todo = doc.getTodosBoxStarted ()[0]; + const todo = doc.getTodosStarted ()[0]; if ( !todo ) { diff --git a/src/todo/decorators/document.ts b/src/todo/decorators/document.ts index 006a196..289ab22 100644 --- a/src/todo/decorators/document.ts +++ b/src/todo/decorators/document.ts @@ -13,6 +13,7 @@ import Project from './project'; import Tag from './tag'; import TodoDone from './todo_done'; import TodoCancelled from './todo_cancelled'; +import TodoStarted from './todo_started'; /* DOCUMENTS LINES CACHE */ @@ -166,7 +167,8 @@ const Document = { tags: doc.getTags (), todosBox: doc.getTodosBox (), todosDone: doc.getTodosDone (), - todosCancelled: doc.getTodosCancelled () + todosCancelled: doc.getTodosCancelled (), + todosStarted: doc.getTodosStarted () }; }, @@ -179,7 +181,8 @@ const Document = { new Tag ().getDecorations ( items.tags ), new Project ().getDecorations ( items.projects ), new TodoDone ().getDecorations ( items.todosDone ), - new TodoCancelled ().getDecorations ( items.todosCancelled ) + new TodoCancelled ().getDecorations ( items.todosCancelled ), + new TodoStarted ().getDecorations ( items.todosStarted ) ); } diff --git a/src/todo/decorators/todo_started.ts b/src/todo/decorators/todo_started.ts new file mode 100644 index 0000000..98744c2 --- /dev/null +++ b/src/todo/decorators/todo_started.ts @@ -0,0 +1,42 @@ +/* IMPORT */ + +import * as vscode from "vscode"; +import Consts from "../../consts"; +import TodoStartedItem from "../items/todo_started"; +import Line from "./line"; + +/* DECORATION TYPES */ + +const TODO_STARTED = vscode.window.createTextEditorDecorationType({ + color: Consts.colors.started, + rangeBehavior: vscode.DecorationRangeBehavior.ClosedOpen, + dark: { + color: Consts.colors.dark.started, + }, + light: { + color: Consts.colors.light.started, + }, +}); + +/* TODO DONE */ + +class TodoStarted extends Line { + TYPES = [TODO_STARTED]; + + getItemRanges( + todoStarted: TodoStartedItem, + negRange?: vscode.Range | vscode.Range[] + ) { + return [ + this.getRangeDifference( + todoStarted.text, + todoStarted.range, + negRange || [Consts.regexes.tag, Consts.regexes.formattedCode] + ), + ]; + } +} + +/* EXPORT */ + +export default TodoStarted; diff --git a/src/todo/document.ts b/src/todo/document.ts index f1280bd..7e80c2b 100644 --- a/src/todo/document.ts +++ b/src/todo/document.ts @@ -6,7 +6,7 @@ import stringMatches from 'string-matches'; import * as vscode from 'vscode'; import Consts from '../consts'; import Utils from '../utils'; -import {Line, Archive, Comment, Formatted, Project, Tag, Todo, TodoBox, TodoFinished, TodoDone, TodoCancelled} from './items'; +import {Line, Archive, Comment, Formatted, Project, Tag, Todo, TodoBox, TodoFinished, TodoDone, TodoCancelled, TodoStarted} from './items'; /* DOCUMENT */ @@ -42,7 +42,7 @@ class Document { /* GET */ - getItems ( Item: typeof Line | typeof Archive | typeof Comment | typeof Formatted | typeof Project | typeof Tag | typeof Todo | typeof TodoBox | typeof TodoFinished | typeof TodoDone | typeof TodoCancelled, regex: RegExp ) { + getItems ( Item: typeof Line | typeof Archive | typeof Comment | typeof Formatted | typeof Project | typeof Tag | typeof Todo | typeof TodoBox | typeof TodoFinished | typeof TodoDone | typeof TodoCancelled | typeof TodoStarted, regex: RegExp ) { const matchText = _.isString ( this.text ) ? this.text : this.textDocument.getText (), matches = stringMatches ( matchText, regex ); @@ -53,7 +53,7 @@ class Document { } - getItemAt ( Item: typeof Line | typeof Archive | typeof Comment | typeof Formatted | typeof Project | typeof Tag | typeof Todo | typeof TodoBox | typeof TodoFinished | typeof TodoDone | typeof TodoCancelled, lineNumber: number, checkValidity = true ) { + getItemAt ( Item: typeof Line | typeof Archive | typeof Comment | typeof Formatted | typeof Project | typeof Tag | typeof Todo | typeof TodoBox | typeof TodoFinished | typeof TodoDone | typeof TodoCancelled | typeof TodoStarted, lineNumber: number, checkValidity = true ) { const line = this.textDocument.lineAt ( lineNumber ); @@ -141,9 +141,15 @@ class Document { } - getTodosBoxStarted () { + getTodosStarted () { - return this.getItems ( TodoBox, Consts.regexes.todoBoxStarted ); + return this.getItems ( TodoStarted, Consts.regexes.todoBoxStarted ); + + } + + getTodosStartedAt ( lineNumber: number, checkValidity? ) { + + return this.getItemAt ( TodoStarted, lineNumber, checkValidity ); } diff --git a/src/todo/items/index.ts b/src/todo/items/index.ts index d8f93d2..bd9b1ed 100644 --- a/src/todo/items/index.ts +++ b/src/todo/items/index.ts @@ -13,7 +13,8 @@ import TodoBox from './todo_box'; import TodoFinished from './todo_finished'; import TodoDone from './todo_done'; import TodoCancelled from './todo_cancelled'; +import TodoStarted from './todo_started'; /* EXPORT */ -export {Archive, Comment, Formatted, Item, Line, Project, Tag, Todo, TodoBox, TodoFinished, TodoDone, TodoCancelled}; +export {Archive, Comment, Formatted, Item, Line, Project, Tag, Todo, TodoBox, TodoFinished, TodoDone, TodoCancelled, TodoStarted}; diff --git a/src/todo/items/todo.ts b/src/todo/items/todo.ts index dcca5be..6b586d4 100644 --- a/src/todo/items/todo.ts +++ b/src/todo/items/todo.ts @@ -3,7 +3,6 @@ import * as _ from 'lodash'; import * as moment from 'moment'; -import * as vscode from 'vscode'; import Config from '../../config'; import Consts from '../../consts'; import Utils from '../../utils'; @@ -41,6 +40,7 @@ class Todo extends Item { box: false, done: false, cancelled: false, + started: false, other: false }; @@ -55,9 +55,10 @@ class Todo extends Item { const box = this.isBox (), done = !box && this.isDone (), cancelled = !box && !done && this.isCancelled (), - other = !box && !done && !cancelled; + started = !box && !done && !cancelled && this.isStarted(), + other = !box && !done && !cancelled && !started; - return { box, done, cancelled, other }; + return { box, done, cancelled, started, other }; } @@ -79,13 +80,13 @@ class Todo extends Item { } - if ( ( was.done || was.cancelled ) && is.box ) { + if ( ( was.done || was.cancelled ) && ( is.started || is.box ) ) { this.unfinish (); } - if ( ( ( was.box || was.other ) && ( is.done || is.cancelled ) ) || ( was.cancelled && is.done ) || ( was.done && is.cancelled ) ) { + if ( ( ( was.box || was.started || was.other ) && ( is.done || is.cancelled ) ) || ( was.cancelled && is.done ) || ( was.done && is.cancelled ) ) { this.finish ( is.done ); @@ -165,7 +166,7 @@ class Todo extends Item { toggleStart () { - if ( this.hasTag ( Consts.regexes.tagStarted ) ) { + if ( this.isStarted() ) { this.unstart (); @@ -179,29 +180,37 @@ class Todo extends Item { start () { - if ( Config.getKey ( 'timekeeping.started.time' ) ) { + if ( Config.getKey ( 'timekeeping.started.enabled' ) ) { - const date = moment (), - format = Config.getKey ( 'timekeeping.started.format' ), - time = date.format ( format ), - tag = `@started(${time})`; + if ( Config.getKey ( 'timekeeping.started.time' ) ) { - this.replaceTag ( Consts.regexes.tagStarted, tag ); + const date = moment (), + format = Config.getKey ( 'timekeeping.started.format' ), + time = date.format ( format ), + tag = `@started(${time})`; - } else { + this.replaceTag ( Consts.regexes.tagStarted, tag ); + + } else { + + const tag = '@started'; - const tag = '@started'; + this.replaceTag ( Consts.regexes.tagStarted, tag ); - this.replaceTag ( Consts.regexes.tagStarted, tag ); + } } + this.toggleStarted( true ); + } unstart () { this.removeTag ( Consts.regexes.tagStarted ); + this.toggleStarted ( false ); + } finish ( isPositive?: boolean ) { @@ -307,8 +316,12 @@ class Todo extends Item { toggleDone ( force: boolean = !this.isDone () ) { - const symbol = force ? Consts.symbols.done : Consts.symbols.box, - state = force ? 'done' : 'box'; + const nextSymbol = this.isStarted () ? Consts.symbols.started : Consts.symbols.box; + + const nextState = this.isStarted () ? 'started' : 'box'; + + const symbol = force ? Consts.symbols.done : nextSymbol, + state = force ? 'done' : nextState; this.setSymbolAndState ( symbol, state ); @@ -328,8 +341,12 @@ class Todo extends Item { toggleCancelled ( force: boolean = !this.isCancelled () ) { - const symbol = force ? Consts.symbols.cancelled : Consts.symbols.box, - state = force ? 'cancelled' : 'box'; + const nextSymbol = this.isStarted () ? Consts.symbols.started : Consts.symbols.box; + + const nextState = this.isStarted () ? 'started' : 'box'; + + const symbol = force ? Consts.symbols.cancelled : nextSymbol, + state = force ? 'cancelled' : nextState; this.setSymbolAndState ( symbol, state ); @@ -347,6 +364,15 @@ class Todo extends Item { } + toggleStarted ( force: boolean = !this.isStarted () ) { + + const symbol = force ? Consts.symbols.started : Consts.symbols.box, + state = force ? 'started' : 'box'; + + this.setSymbolAndState ( symbol, state ); + + } + /* IS */ isBox () { @@ -355,6 +381,14 @@ class Todo extends Item { } + isStarted () { + + // NOTE: may only need to call this.hasTag ( Consts.regexes.tagStarted ), not really sure + + return Item.is ( this.text, Consts.regexes.todoBoxStarted ) || this.hasTag ( Consts.regexes.tagStarted ); + + } + isDone () { return Item.is ( this.text, Consts.regexes.todoDone ); diff --git a/src/todo/items/todo_started.ts b/src/todo/items/todo_started.ts new file mode 100644 index 0000000..f95f3b6 --- /dev/null +++ b/src/todo/items/todo_started.ts @@ -0,0 +1,22 @@ + +/* IMPORT */ + +import Consts from '../../consts'; +import Item from './item'; +import Todo from './todo'; + +/* TODO STARTED */ + +class TodoStarted extends Todo { + + static is ( str: string ) { + + return Item.is ( str, Consts.regexes.todoBoxStarted ); + + } + +} + +/* EXPORT */ + +export default TodoStarted; diff --git a/src/utils/statistics.ts b/src/utils/statistics.ts index db4dbb4..6bac1ed 100644 --- a/src/utils/statistics.ts +++ b/src/utils/statistics.ts @@ -5,7 +5,7 @@ import * as _ from 'lodash'; import * as vscode from 'vscode'; import Config from '../config'; import Consts from '../consts'; -import {Comment, Project, Tag, TodoBox, TodoDone, TodoCancelled} from '../todo/items'; +import {Comment, Project, Tag, TodoBox, TodoDone, TodoCancelled, TodoStarted} from '../todo/items'; import AST from './ast'; import Tokens from './statistics_tokens'; import Time from './time'; @@ -175,6 +175,7 @@ const Statistics = { projects: items.projects.length, tags: items.tags.length, pending: items.todosBox.length, + doing: items.todosStarted.length, done: items.todosDone.length, cancelled: items.todosCancelled.length }); @@ -209,7 +210,7 @@ const Statistics = { } - const groups = [items.projects, items.todosBox, items.todosDone, items.todosCancelled, items.tags], + const groups = [items.projects, items.todosBox, items.todosStarted, items.todosDone, items.todosCancelled, items.tags], lines = groups.reduce ( ( arr1, arr2 ) => mergeSorted ( arr1, arr2 ) ); items.projects.forEach ( project => { @@ -255,13 +256,14 @@ const Statistics = { tokens.tags += nextTokens.tags; tokens.pending += nextTokens.pending; tokens.done += nextTokens.done; + tokens.doing += nextTokens.doing; tokens.cancelled += nextTokens.cancelled; tokens.estSeconds += nextTokens.estSeconds; tokens.estTotalSeconds += nextTokens.estTotalSeconds; tokens.lastedSeconds += nextTokens.lastedSeconds; tokens.wastedSeconds += nextTokens.wastedSeconds; - i += nextTokens.comments + nextTokens.projects + nextTokens.tags + nextTokens.pending + nextTokens.done + nextTokens.cancelled; // Jumping + i += nextTokens.comments + nextTokens.projects + nextTokens.tags + nextTokens.pending + nextTokens.doing + nextTokens.done + nextTokens.cancelled; // Jumping } if ( nextItem instanceof Comment ) { @@ -271,6 +273,10 @@ const Statistics = { tokens.pending++; + } else if ( nextItem instanceof TodoStarted ) { + + tokens.doing++; + } else if ( nextItem instanceof TodoDone ) { tokens.done++; diff --git a/src/utils/statistics_tokens.ts b/src/utils/statistics_tokens.ts index 5e1836e..f9c69d7 100644 --- a/src/utils/statistics_tokens.ts +++ b/src/utils/statistics_tokens.ts @@ -9,13 +9,14 @@ import Time from './time'; class StatisticsTokens { - static supported = ['comments', 'projects', 'tags', 'pending', 'done', 'cancelled', 'finished', 'all', 'percentage', 'est', 'est-total', 'lasted', 'wasted', 'elapsed', 'est-finished', 'est-finished-percentage']; + static supported = ['comments', 'projects', 'tags', 'pending', 'done', 'doing', 'cancelled', 'finished', 'all', 'percentage', 'est', 'est-total', 'lasted', 'wasted', 'elapsed', 'est-finished', 'est-finished-percentage']; comments = 0; projects = 0; tags = 0; pending = 0; done = 0; + doing = 0; cancelled = 0; estSeconds = 0; estTotalSeconds = 0; @@ -29,7 +30,7 @@ class StatisticsTokens { @memoize get all () { - return this.pending + this.finished; + return this.pending + this.doing + this.finished; } @memoize