Skip to content
Merged
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
52 changes: 38 additions & 14 deletions src/gui/note_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,10 +636,26 @@ impl NotePanel {
) -> bool {
let mut modified = false;
let mut offset = start;
let mut buf_offset = offset;
let mut buffer = String::new();
let old_spacing = ui.spacing().item_spacing;
ui.spacing_mut().item_spacing.y = 0.0;
for line in segment.split_inclusive('\n') {
for line in segment.lines() {
if line.starts_with("- [ ]") || line.starts_with("- [x]") || line.starts_with("- [X]") {
if !buffer.is_empty() {
ui.scope(|ui| {
ui.style_mut().override_font_id =
Some(FontId::proportional(app.note_font_size));
let processed = preprocess_note_links(&buffer, &self.note.slug);
CommonMarkViewer::new(format!("note_seg_{}", buf_offset)).show(
ui,
&mut self.markdown_cache,
&processed,
);
handle_markdown_links(ui, app);
});
buffer.clear();
}
let checked = line.as_bytes()[3] == b'x' || line.as_bytes()[3] == b'X';
let mut state = checked;
ui.horizontal(|ui| {
Expand All @@ -653,7 +669,8 @@ impl NotePanel {
ui.scope(|ui| {
ui.style_mut().override_font_id =
Some(FontId::proportional(app.note_font_size));
let rest = preprocess_note_links(&line[6..], &self.note.slug);
let rest =
preprocess_note_links(line.get(6..).unwrap_or(""), &self.note.slug);
CommonMarkViewer::new(format!("note_seg_{}", offset)).show(
ui,
&mut self.markdown_cache,
Expand All @@ -662,20 +679,27 @@ impl NotePanel {
handle_markdown_links(ui, app);
});
});
offset += line.len() + 1;
buf_offset = offset;
} else {
ui.scope(|ui| {
ui.style_mut().override_font_id =
Some(FontId::proportional(app.note_font_size));
let processed = preprocess_note_links(line, &self.note.slug);
CommonMarkViewer::new(format!("note_seg_{}", offset)).show(
ui,
&mut self.markdown_cache,
&processed,
);
handle_markdown_links(ui, app);
});
if !buffer.is_empty() {
buffer.push('\n');
}
buffer.push_str(line);
offset += line.len() + 1;
}
offset += line.len();
}
if !buffer.is_empty() {
ui.scope(|ui| {
ui.style_mut().override_font_id = Some(FontId::proportional(app.note_font_size));
let processed = preprocess_note_links(&buffer, &self.note.slug);
CommonMarkViewer::new(format!("note_seg_{}", buf_offset)).show(
ui,
&mut self.markdown_cache,
&processed,
);
handle_markdown_links(ui, app);
});
}
ui.spacing_mut().item_spacing = old_spacing;
modified
Expand Down
Loading