fix(review): close all 2026-06-03 codebase-review findings (R1-R18)
Resolves the 18 findings from the parallel codebase review, tracked in development/vimwiki-gap.md. Correctness / perf: - Wiki.config -> Arc<WikiConfig> so cloning a Wiki is a refcount bump (R5) - WorkspaceIndex::remove is no longer O(n^2): a per-source contributions map limits the scan to buckets the source actually wrote into (R6) - render_color now expands color_tag_template (__STYLE__/__CONTENT__), consuming the previously-dead field; ColorNode documented as an extension point; 3 renderer tests added (R3/R4) - wiki_root_for returns empty/nil on no-match instead of falling back to the first wiki (R2); auto_header honours links_space_char (R7) Cleanup / dedup: - Remove dead #[allow(dead_code)] stubs + uncalled pub helpers, narrow imports (R10/R11) - Dedup span_of_inline x3 -> InlineNode::span() (R12) - diary_step single read lock; page_captions single pass (R13) - Lua auto_header loop -> wiki_list(); detect_current_symbol cleanup (R14/R18) Client / docs: - :VimwikiNormalizeLink Vim cmds -> <q-args> (R17); ftplugin header fix (R16); vars.vim multi-wiki limitation documented (R15) - Document 19 config options in README.md + doc/nuwiki.txt; fix list_margin/shiftwidth doc and stale comments (R1/R9) - R8 investigated, confirmed not a real bug (documented) Verified: Neovim harness 307, Vim harness 301/18/21, Rust suite 568, all 0 failed; clippy clean; fresh parallel-agent audit found no regressions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -328,6 +328,64 @@ fn template_substitutes_vimwiki_percent_placeholders() {
|
||||
assert!(!out.contains('%'), "no placeholder left: {out}");
|
||||
}
|
||||
|
||||
// ===== Colour spans =====
|
||||
|
||||
// `ColorNode` is an extension point the vimwiki parser never emits, so build
|
||||
// a document around one by hand and render it directly.
|
||||
fn doc_with_color(color: &str) -> DocumentNode {
|
||||
use nuwiki_core::ast::{ColorNode, ParagraphNode};
|
||||
let color_node = InlineNode::Color(ColorNode {
|
||||
span: Span::default(),
|
||||
color: color.to_string(),
|
||||
children: vec![InlineNode::Text(TextNode {
|
||||
span: Span::default(),
|
||||
content: "hi".to_string(),
|
||||
})],
|
||||
});
|
||||
DocumentNode {
|
||||
children: vec![BlockNode::Paragraph(ParagraphNode {
|
||||
span: Span::default(),
|
||||
children: vec![color_node],
|
||||
})],
|
||||
..DocumentNode::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn color_dic_name_uses_inline_style_via_default_template() {
|
||||
let doc = doc_with_color("red");
|
||||
let renderer =
|
||||
HtmlRenderer::new().with_colors([("red".to_string(), "crimson".to_string())].into());
|
||||
let out = renderer.render_to_string(&doc).unwrap();
|
||||
assert!(
|
||||
out.contains("<span style=\"color:crimson\">hi</span>"),
|
||||
"got: {out}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn color_tag_template_override_is_honored() {
|
||||
let doc = doc_with_color("red");
|
||||
let renderer = HtmlRenderer::new()
|
||||
.with_colors([("red".to_string(), "crimson".to_string())].into())
|
||||
.with_color_template("<em data-style=\"__STYLE__\">__CONTENT__</em>");
|
||||
let out = renderer.render_to_string(&doc).unwrap();
|
||||
assert!(
|
||||
out.contains("<em data-style=\"color:crimson\">hi</em>"),
|
||||
"got: {out}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_color_name_falls_back_to_class() {
|
||||
let doc = doc_with_color("plaid");
|
||||
let out = HtmlRenderer::new().render_to_string(&doc).unwrap();
|
||||
assert!(
|
||||
out.contains("<span class=\"color-plaid\">hi</span>"),
|
||||
"got: {out}"
|
||||
);
|
||||
}
|
||||
|
||||
// ===== End-to-end smoke =====
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user