Skip to content
Merged
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
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ func (m *model) cursorValue() string {
}

if at.Kind == String {
str, err := strconv.Unquote(at.Value)
str, err := utils.Unquote(at.Value)
if err == nil {
return str
}
Expand Down
20 changes: 20 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,26 @@ func TestOutput(t *testing.T) {
tm.WaitFinished(t, teatest.WithFinalTimeout(time.Second))
}

// TestCursorValueDecodesJsonEscapesInWrappedArrayString verifies that preview
// and print decode JSON string escapes even after the viewer wraps an array item.
func TestCursorValueDecodesJsonEscapesInWrappedArrayString(t *testing.T) {
head, err := jsonx.Parse([]byte(`["before\ud83d\udd55\nsecond line after"]`))
require.NoError(t, err)

jsonx.Wrap(head, 12)
require.NotNil(t, head.Next)
require.NotNil(t, head.Next.ChunkEnd)

m := &model{
head: head,
cursor: 1,
}
require.Equal(t, "before\U0001F555\nsecond line after", m.cursorValue())

m.cursor = 2
require.Equal(t, "before\U0001F555\nsecond line after", m.cursorValue())
}

func TestNavigation(t *testing.T) {
tm := prepare(t)

Expand Down
Loading