Repository navigation
Description
Context — In a Note's editor, when a bullet list holds items long enough to wrap on several lines, selecting all (Ctrl+A, or a drag from the last sentence to the first) highlights only the first line of each item, the one beside the bullet; the wrapped lines below stay unlit although they are selected (a copy holds them). And the copied text has no list markers: the items come out as bare lines, without the - that tells them apart. Reported on 1.2.1.
Change — Every selected line is highlighted, wrapped lines included, in lists and paragraphs alike. Copying (Ctrl+C, Cut, the menu) puts the selection on the clipboard as text that keeps its blocks: - before a bullet item, 1. before a numbered one, - [ ] / - [x] before a task, > before a quoted line, two spaces of indent per nesting level. No inline Markdown: bold, italic, code and links come out as their text. A second copy, « Copy as Markdown » (Ctrl+Shift+C, and the editor's right-click menu), puts the selection on the clipboard as the Markdown the Note is stored in, marks included.
To do
-
selection_rects: resolve the start of each row on that row, not at the end of the previous one. - A new
richtext::edit::copied(the selected leaves, each prefixed by the marker of the list item or quote it sits in, indented by its depth), used by copy and cut;selected_textstays plain (search's replace and the link dialog read it). - Headings and paragraphs come out as their text; a numbered item keeps its own number (
start+ its index). -
richtext::edit::copied_markdown: the selected fragment as aDocument, written byrichtext::write::write. - « Copy as Markdown »:
Mod-Shift-cin the editor's shortcut table, shown in its keys help; a right-click menu on the Note editor (Cut, Copy, Copy as Markdown, Paste, Select all), as the code editor has; keys in both locales. - A selection inside one paragraph copies its text alone (no block marker for a part of a line).
Tests — Unit in widgets/editor for selection_rects: a galley wrapped on 3 rows with the whole text selected returns 3 rects, each of positive width, on rows 0, 1 and 2. Unit in richtext/src/edit/tests.rs: copying a whole two-item bullet list gives - one\n- two; a numbered list from 3, a task list, a nested list, a quote; a bold word comes out without **; a selection within one item gives its text alone; copied_markdown of the same selections gives Markdown that richtext reads back to the same blocks. kittest in rich/tests.rs: select all over a wrapped item paints a highlight on each of its rows. e2e 03_editing_a_note: a Note with a long bullet item, Ctrl+A, Ctrl+C, the clipboard holds - .
Technical analysis
Cause — the highlight. ui/src/widgets/rich.rs:373 paint_leaf paints the selection with widgets::editor::selection_rects (widgets/editor/mod.rs:619). For each row of the galley it computes x0 = galley.pos_from_cursor(CCursor::new(from)). CCursor::new sets prefer_next_row: false, and on a wrapped row boundary (a row not ending in \n) epaint's layout_from_cursor (epaint 0.37, text_layout_types.rs:1273) resolves an index equal to the end of row n to row n, not to the start of row n+1. So for every row after the first, from = row_start is placed at the right end of the previous row: the rect spans from that x to the end of the selected text on the current row. On a row shorter than the one above (the last line of an item, a paragraph's last line) x0 > x1 and the rect is negative, which epaint does not fill; on a full row it is a sliver. Only the first row, starting at index 0, is right — the line beside the bullet. Lists make it visible because their items are long and indented; any wrapped paragraph and a snippet in the code editor's wrap mode (editor/mod.rs:554, same function) and the search highlights (rich.rs:383) have the same defect.
Fix. let start = CCursor { index: from, prefer_next_row: true } for x0, keep prefer_next_row: false for x1 (the end of a row stays on that row). Nothing else changes in the drawing.
Cause — the copy. rich.rs:601 copy puts richtext::edit::selected_text on the clipboard (crates/richtext/src/edit.rs:28): it walks the selected leaves and joins inlines::plain of each with \n, so a list item's marker, a heading's level, a quote and inline marks are dropped. A card's Copy of the same Note copies its stored Markdown (DisplayNote::content, state/apply_notes.rs:796-800), so the two copies disagree.
Fix. Keep the walk of selected_text over tree::leaves and the trimming of the first and last leaves at their offsets, and give each leaf the prefix of the blocks around it: walking its path through the document, each Block::List crossed adds the indent of its depth and, on the item's first leaf, its marker (- , {start + index}. , - [ ] / - [x] ); each quote adds > . Inline content stays inlines::plain. Pasting it back into a Note inserts it as text, as today (paste reads HTML first, then plain text through insert_text).
Copy as Markdown. No copy of a part of a Note as Markdown exists today. What exists: a card's Copy (the whole note's stored body, state/apply_notes.rs:796-800), the selection bar's « Copier en Markdown » (whole notes with their title and metadata, transfer::model::to_markdown, through Menu::CopyMarkdown), and « Copier tel quel » for a snippet's {{fields}}. The Note editor has no right-click menu: rich.rs handles Event::Copy/Event::Cut only. The code editor's menu (widgets/editor/mod.rs:648) is the model to follow. Mod-Shift-c is free: no table binds it, and egui-winit 0.37 turns only Ctrl+C with no other modifier into Event::Copy (is_copy_command uses command_only()), so Ctrl+Shift+C reaches the editor as a key event its shortcuts::find can match. The fragment is built once (the selection cut out of the document, the first and last leaves trimmed at their offsets) and either walked for the plain copy or written by richtext::write::write for Markdown.
Decided. Two copies. Ctrl+C gives plain text with the block markers: a bullet list copied out of a Note must not become a block of text, and inline marks (**bold**) would be noise there. « Copy as Markdown » gives the Markdown, for pasting where Markdown is read.
Risk. Low for the highlight (one cursor flag, a shared function with tests). Medium for the copy: what lands on the clipboard changes for every copy from a Note; search's « replace » keeps selected_text.
Activity
Captures: 1.2.2 #1674, before and after
vmillet-dev commentedon Nov 27, 2026
Fixed by #1682, merged into
dev/1.2.2.