From 05b64e4315ba17960f5bb2119e79eec2476459b2 Mon Sep 17 00:00:00 2001 From: Quey-Liang Kao Date: Mon, 16 Jan 2017 00:46:28 +0800 Subject: Bugfix: "todo a" no longer adds an empty todo --- todolist/parser.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'todolist/parser.go') diff --git a/todolist/parser.go b/todolist/parser.go index 433cfc6..6919bd7 100644 --- a/todolist/parser.go +++ b/todolist/parser.go @@ -13,6 +13,12 @@ import ( type Parser struct{} func (p *Parser) ParseNewTodo(input string) *Todo { + r, _ := regexp.Compile(`^(add|a)(\\ |)`) + input = r.ReplaceAllString(input, "") + if input == "" { + return nil + } + todo := NewTodo() todo.Subject = p.Subject(input) todo.Projects = p.Projects(input) @@ -24,8 +30,6 @@ func (p *Parser) ParseNewTodo(input string) *Todo { } func (p *Parser) Subject(input string) string { - r, _ := regexp.Compile(`^(add|a) `) - input = r.ReplaceAllString(input, "") if strings.Contains(input, " due") { index := strings.LastIndex(input, " due") return input[0:index] -- cgit v1.3