From 2b32faa1ee6df5b2f217eb31f0b6910d8f47c9e2 Mon Sep 17 00:00:00 2001 From: Zack Date: Sun, 7 Feb 2016 11:11:39 -0500 Subject: [PATCH] Fixed problem with matching last item --- routes.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/routes.go b/routes.go index 180b96f..20dfdaa 100644 --- a/routes.go +++ b/routes.go @@ -140,11 +140,14 @@ func deleteListItem(c *gin.Context) { _, listItems := reorderList(p.Text) for i, lineString := range listItems { + // fmt.Println(i, lineString, lineNum) if i+1 == lineNum { + // fmt.Println("MATCHED") if strings.Contains(lineString, "~~") == false { - p.Text = strings.Replace(p.Text, lineString[2:]+"\n", "~~"+lineString[2:]+"~~"+"\n", 1) + // fmt.Println(p.Text, "("+lineString[2:]+"\n"+")", "~~"+lineString[2:]+"~~"+"\n") + p.Text = strings.Replace(p.Text+"\n", lineString[2:]+"\n", "~~"+lineString[2:]+"~~"+"\n", 1) } else { - p.Text = strings.Replace(p.Text, lineString[2:]+"\n", lineString[4:len(lineString)-2]+"\n", 1) + p.Text = strings.Replace(p.Text+"\n", lineString[2:]+"\n", lineString[4:len(lineString)-2]+"\n", 1) } p.save() break