Soft-wrap the note body

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Phil
2026-10-31 19:58:46 -06:00
co-authored by Claude Opus 5.5
parent 56b4511ac3
commit 7fb72f4d99
+19 -3
View File
@@ -2,7 +2,7 @@
use ratatui::crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
use ratatui::style::{Modifier, Style};
use ratatui_textarea::{Input, Key, TextArea};
use ratatui_textarea::{Input, Key, TextArea, WrapMode};
use crate::micropub::{self, Error, Note, ServerConfig, SyndicationTarget};
use crate::worker::{Request, Response};
@@ -78,13 +78,20 @@ fn text_area(placeholder: &str) -> TextArea<'static> {
t
}
/// The note body: soft-wraps at word boundaries (long words such as URLs break mid-word).
fn content_area() -> TextArea<'static> {
let mut t = text_area("What's on your mind? (Markdown)");
t.set_wrap_mode(WrapMode::WordOrGlyph);
t
}
impl App {
pub fn new(me: String, endpoint: String) -> Self {
let mut app = App {
me,
endpoint,
title: text_area("Optional title"),
content: text_area("What's on your mind? (Markdown)"),
content: content_area(),
tags: text_area("Comma-separated, e.g. rust, indieweb"),
targets: Vec::new(),
targets_state: Targets::Loading,
@@ -124,7 +131,7 @@ impl App {
fn clear_form(&mut self) {
self.title = text_area("Optional title");
self.content = text_area("What's on your mind? (Markdown)");
self.content = content_area();
self.tags = text_area("Comma-separated, e.g. rust, indieweb");
self.focus = Focus::Content;
self.update_cursors();
@@ -436,6 +443,15 @@ mod tests {
assert_eq!(app.mode, Mode::Editing);
}
#[test]
fn content_wraps_and_keeps_wrapping_after_publish() {
let mut app = loaded(&[]);
assert_eq!(app.content.wrap_mode(), WrapMode::WordOrGlyph);
assert_eq!(app.title.wrap_mode(), WrapMode::None);
app.handle_response(Response::Published(Ok("u".into())));
assert_eq!(app.content.wrap_mode(), WrapMode::WordOrGlyph);
}
#[test]
fn title_enter_moves_to_content() {
let mut app = loaded(&[]);