Skip to content

Hover preview card displays "Empty note" for notes with custom titles and single-line bodies #30

Description

@yifjfgup

Describe the bug

When a note has a custom independent title and only 1 line in its body (e.g.
☐ Task item), the tab hover preview card (and library list subtitle)
mistakenly renders "Empty note" / blank preview instead of showing the first
line.

Root cause

In NotePreviewCard (DeckViews.swift) and Note.preview (Core.swift),
the preview extraction logic unconditionally drops the first line
(lines.dropFirst()) and checks lines.count <= 1:

let lines = note.body.split(whereSeparator: \.isNewline).map(String.init)
let previewLines = Array(lines.dropFirst().prefix(4))
...
} else if note.body.isEmpty || lines.count <= 1 {
    Text(L10n.text("note.empty"))
}
This assumption was based on the old behavior where the first line was
strictly used as the title. Now that notes support custom independent titles,
the first line of the body is actual content and should be included in the
preview when note.hasCustomTitle is true.

Expected behavior

- If note.hasCustomTitle == true: Preview should start from line 1 of the
body.
- If note.hasCustomTitle == false: Preview keeps skipping line 1 (as it's
already displayed as the derived title).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions