Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/drafts/drafts.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
)

const tagSeparator = "|||"
const recordSeparator = "\x1e"

type ActionRunResult struct {
UUID string `json:"uuid"`
Expand Down Expand Up @@ -333,7 +334,7 @@ func queryDrafts(scope, queryString string, filter Filter, opt QueryOptions) ([]
if output is "" then
set output to line_out
else
set output to output & linefeed & line_out
set output to output & (ASCII character 30) & line_out
end if
end repeat
return output
Expand All @@ -348,7 +349,7 @@ end tell`, scope, whereClause)
return []Draft{}, nil
}

lines := strings.Split(output, "\n")
lines := strings.Split(output, recordSeparator)
drafts := make([]Draft, 0, len(lines))
for _, line := range lines {
if line != "" {
Expand Down
32 changes: 32 additions & 0 deletions pkg/drafts/drafts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,38 @@ func TestQueryFlagged(t *testing.T) {
assert.EqualSlice(t, []string{a}, uuids)
}

func TestQueryMultilineContent(t *testing.T) {
tag := rand()
multiline := "Line one\nLine two\nLine three"

a, err := Create(multiline, CreateOptions{Tags: []string{tag}})
requireNoError(t, err)
b, err := Create("single line", CreateOptions{Tags: []string{tag}})
requireNoError(t, err)
defer func() {
requireNoError(t, Trash(a))
requireNoError(t, Trash(b))
}()

// Get confirms the multiline draft exists
draft, err := Get(a)
requireNoError(t, err)
assert.Equal(t, multiline, draft.Content)

// Query must also find it
results, err := Query("", FilterInbox, QueryOptions{Tags: []string{tag}})
requireNoError(t, err)
uuids := getUUIDs(results)
assertSameUUIDs(t, []string{a, b}, uuids)

// Verify the multiline draft's content is intact after round-tripping through Query
for _, d := range results {
if d.UUID == a {
assert.Equal(t, multiline, d.Content)
}
}
}

// ---- Workspace tests --------------------------------------------------------

func TestQueryWorkspace(t *testing.T) {
Expand Down