fix(parity): close the 2026-06-02 re-audit config/command findings
Implements the remaining fourth-pass findings (gap doc updated):
- list_margin: rework to upstream's buffer-side meaning. Drop the
nuwiki-only HTML em-margin (renderer field/method + render_page_html
param removed) and prepend max(0, list_margin) leading spaces to every
generated bullet in build_toc_text / build_links_text /
build_tag_links_text / diary::build_index_body; headings stay at col 0.
From<RawWiki> derives 0 for markdown wikis when unset. Negatives can't
resolve 'shiftwidth' server-side, so they collapse to zero indent
(documented divergence).
- diary_months: per-wiki Vec<String> (default 12 English names), threaded
into the diary-index month labels; missing/empty slots fall back to the
English name.
- diary_caption_level: widen u8 -> i8 so vimwiki's -1 (min: -1) parses;
build_index_body clamps < 0 to base tree level 0.
- VimwikiRemoveDone: regain upstream's -range. All four defs are now
-bang -range, dispatched via remove_done(bang, range, l1, l2) in both
clients: ! -> whole buffer, explicit range -> new list_remove_done_range
({range:[l1-1,l2-1]}), else current list. Server remove_done_edit gained
an Option<(u32,u32)> range that filters whole-doc victims by start line.
markdown_header_style is deferred: the generators emit vimwiki syntax only
(caption_line never writes markdown headers), so there's no markdown header
to attach the style to. Logged as the "generated-content is vimwiki-only"
intentional divergence pending a later markdown generated-content effort.
Tests: list_margin indent, markdown list_margin-0 default, diary_months
custom + fallback, negative caption_level clamp/parse, ranged remove-done
(server + both keymap harnesses). 553 lsp/core tests pass; clippy clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -270,6 +270,10 @@ fn defaults_carry_vimwiki_per_wiki_keys() {
|
||||
assert_eq!(cfg.diary_caption_level, 0); // upstream default
|
||||
assert_eq!(cfg.diary_sort, "desc");
|
||||
assert_eq!(cfg.diary_header, "Diary");
|
||||
// diary_months defaults to the 12 English month names.
|
||||
assert_eq!(cfg.diary_months.len(), 12);
|
||||
assert_eq!(cfg.diary_months[0], "January");
|
||||
assert_eq!(cfg.diary_months[11], "December");
|
||||
assert_eq!(cfg.listsyms, " .oOX");
|
||||
assert!(cfg.listsyms_propagate);
|
||||
assert_eq!(cfg.list_margin, -1);
|
||||
@@ -305,6 +309,7 @@ fn raw_wiki_parses_every_new_key() {
|
||||
"diary_caption_level": 2,
|
||||
"diary_sort": "asc",
|
||||
"diary_header": "Journal",
|
||||
"diary_months": ["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez"],
|
||||
"listsyms": "abcde",
|
||||
"listsym_rejected": "✗",
|
||||
"listsyms_propagate": false,
|
||||
@@ -334,6 +339,8 @@ fn raw_wiki_parses_every_new_key() {
|
||||
assert_eq!(w.diary_caption_level, 2);
|
||||
assert_eq!(w.diary_sort, "asc");
|
||||
assert_eq!(w.diary_header, "Journal");
|
||||
assert_eq!(w.diary_months[4], "Mai");
|
||||
assert_eq!(w.diary_months[11], "Dez");
|
||||
assert_eq!(w.listsyms, "abcde");
|
||||
assert_eq!(w.listsym_rejected, "✗");
|
||||
assert_eq!(w.list_syms().rejected_glyph(), '✗');
|
||||
@@ -369,6 +376,36 @@ fn raw_wiki_parses_every_new_key() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn markdown_wiki_derives_list_margin_zero_when_unset() {
|
||||
// vimwiki sets list_margin = 0 for markdown wikis (vs -1 elsewhere) when
|
||||
// the key is absent; an explicit value still wins.
|
||||
let cfg = config_from_json(serde_json::json!({
|
||||
"wikis": [{ "root": "/tmp/md", "syntax": "markdown" }],
|
||||
}));
|
||||
assert_eq!(cfg.wikis[0].list_margin, 0);
|
||||
|
||||
let vw = config_from_json(serde_json::json!({
|
||||
"wikis": [{ "root": "/tmp/vw", "syntax": "vimwiki" }],
|
||||
}));
|
||||
assert_eq!(vw.wikis[0].list_margin, -1);
|
||||
|
||||
let explicit = config_from_json(serde_json::json!({
|
||||
"wikis": [{ "root": "/tmp/md2", "syntax": "markdown", "list_margin": 4 }],
|
||||
}));
|
||||
assert_eq!(explicit.wikis[0].list_margin, 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn diary_caption_level_accepts_negative() {
|
||||
// vimwiki allows diary_caption_level = -1 (min: -1); the field is i8 so it
|
||||
// parses instead of failing deserialization.
|
||||
let cfg = config_from_json(serde_json::json!({
|
||||
"wikis": [{ "root": "/tmp/w", "diary_caption_level": -1 }],
|
||||
}));
|
||||
assert_eq!(cfg.wikis[0].diary_caption_level, -1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn diary_calendar_defaults_to_iso_weeks() {
|
||||
let cfg = WikiConfig::empty();
|
||||
|
||||
Reference in New Issue
Block a user